BUG-HUNT: [security/auth] Settings.show_secrets env var (CLEVERAGENTS_SHOW_SECRETS=true) is silently ignored — shared/redaction._show_secrets is never updated from Settings #6716

Open
opened 2026-04-09 23:49:11 +00:00 by HAL9000 · 1 comment
Owner

Bug Report: [spec-alignment / security] Settings.show_secrets Not Wired to shared.redaction.set_show_secrets()

Severity Assessment

  • Impact: Users who set CLEVERAGENTS_SHOW_SECRETS=true (or cleveragents_show_secrets=true in config) expect API keys and tokens to be visible in logs and CLI output for debugging, but they remain masked. The env var is a no-op. Conversely, a user who doesn't know about the env var wouldn't accidentally expose secrets — so the security posture is not degraded — but the configuration contract is violated.
  • Likelihood: Any user or operator trying to use CLEVERAGENTS_SHOW_SECRETS for debugging will be silently surprised.
  • Priority: Medium (spec-alignment bug, not an active security exposure)

Location

  • File: src/cleveragents/config/settings.py
  • Lines: 496–500 (show_secrets field definition)
  • File: src/cleveragents/shared/redaction.py
  • Lines: 81–104 (_show_secrets global and set_show_secrets())
  • File: src/cleveragents/cli/main.py
  • Lines: 285–290 (show_secrets_callback)

Description

Settings defines show_secrets as a validated field backed by the CLEVERAGENTS_SHOW_SECRETS environment variable:

# src/cleveragents/config/settings.py lines 496-500
show_secrets: bool = Field(
    default=False,
    validation_alias=AliasChoices("CLEVERAGENTS_SHOW_SECRETS"),
    description="When True, secrets are shown in CLI output and logs.",
)

shared/redaction.py has a completely separate module-level boolean that controls actual redaction:

# src/cleveragents/shared/redaction.py lines 81, 85-104
_show_secrets: bool = False

def get_show_secrets() -> bool:
    with _flag_lock:
        return _show_secrets

def set_show_secrets(value: bool) -> None:
    ...
    global _show_secrets
    with _flag_lock:
        _show_secrets = value

The CLI callback in main.py wires the CLI flag --show-secrets to set_show_secrets():

# src/cleveragents/cli/main.py lines 285-290
def show_secrets_callback(value: bool) -> None:
    if value:
        from cleveragents.shared.redaction import set_show_secrets
        set_show_secrets(True)

However, nowhere in the codebase is Settings.show_secrets read and applied to set_show_secrets().

This means:

  1. CLEVERAGENTS_SHOW_SECRETS=true agents <command> — env var is read into Settings.show_secrets=True, but _show_secrets stays False. Redaction is still active.
  2. agents --show-secrets <command> — CLI callback fires, _show_secrets=True. Works correctly.
  3. Setting show_secrets = true in ~/.cleveragents/config.toml — same as #1: no effect.

Evidence

Search across the codebase confirms there is no code path from Settings.show_secrets to set_show_secrets():

grep -rn "show_secrets" src/ --include="*.py"
# Only these files reference Settings.show_secrets:
#   config/settings.py: field definition
# Only cli/main.py calls set_show_secrets():
#   cli/main.py:290: set_show_secrets(True)  # from CLI --show-secrets flag only

No startup code in container.py, __init__.py, or anywhere else reads Settings.show_secrets and calls set_show_secrets().

Expected Behavior

Per specification (spec comment: "When True, secrets are shown in CLI output and logs"), setting CLEVERAGENTS_SHOW_SECRETS=true should cause shared.redaction._show_secrets to be set to True, enabling secrets to be visible in structured logs and CLI output. The env var should have the same effect as the --show-secrets CLI flag.

Actual Behavior

Setting CLEVERAGENTS_SHOW_SECRETS=true populates Settings.show_secrets=True but has zero effect on log or output redaction. _show_secrets remains False. API keys and tokens continue to be masked regardless.

Suggested Fix

Add a startup call — ideally in model_post_init in Settings or in the container initialization — to synchronize the two flags:

# Option A: in Settings.model_post_init (settings.py)
def model_post_init(self, __context: Any) -> None:
    ...
    if self.show_secrets:
        from cleveragents.shared.redaction import set_show_secrets
        set_show_secrets(True)

# Option B: in get_container() (container.py), after Settings is constructed
settings = _container.settings()
if settings.show_secrets:
    from cleveragents.shared.redaction import set_show_secrets
    set_show_secrets(True)

Category

spec-alignment

TDD Note

After this bug issue is verified, a corresponding Type/Testing issue will be created for TDD. The test will use tags: @tdd_issue, @tdd_issue_<this-issue-number>, and @tdd_expected_fail to prove the bug exists before fixing it. Specifically: a test asserting that CLEVERAGENTS_SHOW_SECRETS=true causes get_show_secrets() to return True after Settings() is constructed.


Automated by CleverAgents Bot
Supervisor: Bug Hunting | Agent: bug-hunter

## Bug Report: [spec-alignment / security] `Settings.show_secrets` Not Wired to `shared.redaction.set_show_secrets()` ### Severity Assessment - **Impact**: Users who set `CLEVERAGENTS_SHOW_SECRETS=true` (or `cleveragents_show_secrets=true` in config) expect API keys and tokens to be visible in logs and CLI output for debugging, but they remain masked. The env var is a no-op. Conversely, a user who *doesn't* know about the env var wouldn't accidentally expose secrets — so the *security posture is not degraded* — but the configuration contract is violated. - **Likelihood**: Any user or operator trying to use `CLEVERAGENTS_SHOW_SECRETS` for debugging will be silently surprised. - **Priority**: Medium (spec-alignment bug, not an active security exposure) ### Location - **File**: `src/cleveragents/config/settings.py` - **Lines**: 496–500 (`show_secrets` field definition) - **File**: `src/cleveragents/shared/redaction.py` - **Lines**: 81–104 (`_show_secrets` global and `set_show_secrets()`) - **File**: `src/cleveragents/cli/main.py` - **Lines**: 285–290 (`show_secrets_callback`) ### Description `Settings` defines `show_secrets` as a validated field backed by the `CLEVERAGENTS_SHOW_SECRETS` environment variable: ```python # src/cleveragents/config/settings.py lines 496-500 show_secrets: bool = Field( default=False, validation_alias=AliasChoices("CLEVERAGENTS_SHOW_SECRETS"), description="When True, secrets are shown in CLI output and logs.", ) ``` `shared/redaction.py` has a completely separate module-level boolean that controls actual redaction: ```python # src/cleveragents/shared/redaction.py lines 81, 85-104 _show_secrets: bool = False def get_show_secrets() -> bool: with _flag_lock: return _show_secrets def set_show_secrets(value: bool) -> None: ... global _show_secrets with _flag_lock: _show_secrets = value ``` The CLI callback in `main.py` wires the CLI flag `--show-secrets` to `set_show_secrets()`: ```python # src/cleveragents/cli/main.py lines 285-290 def show_secrets_callback(value: bool) -> None: if value: from cleveragents.shared.redaction import set_show_secrets set_show_secrets(True) ``` **However, nowhere in the codebase is `Settings.show_secrets` read and applied to `set_show_secrets()`.** This means: 1. `CLEVERAGENTS_SHOW_SECRETS=true agents <command>` — env var is read into `Settings.show_secrets=True`, but `_show_secrets` stays `False`. Redaction is still active. 2. `agents --show-secrets <command>` — CLI callback fires, `_show_secrets=True`. Works correctly. 3. Setting `show_secrets = true` in `~/.cleveragents/config.toml` — same as #1: no effect. ### Evidence Search across the codebase confirms there is no code path from `Settings.show_secrets` to `set_show_secrets()`: ```bash grep -rn "show_secrets" src/ --include="*.py" # Only these files reference Settings.show_secrets: # config/settings.py: field definition # Only cli/main.py calls set_show_secrets(): # cli/main.py:290: set_show_secrets(True) # from CLI --show-secrets flag only ``` No startup code in `container.py`, `__init__.py`, or anywhere else reads `Settings.show_secrets` and calls `set_show_secrets()`. ### Expected Behavior Per specification (spec comment: "When True, secrets are shown in CLI output and logs"), setting `CLEVERAGENTS_SHOW_SECRETS=true` should cause `shared.redaction._show_secrets` to be set to `True`, enabling secrets to be visible in structured logs and CLI output. The env var should have the same effect as the `--show-secrets` CLI flag. ### Actual Behavior Setting `CLEVERAGENTS_SHOW_SECRETS=true` populates `Settings.show_secrets=True` but has zero effect on log or output redaction. `_show_secrets` remains `False`. API keys and tokens continue to be masked regardless. ### Suggested Fix Add a startup call — ideally in `model_post_init` in `Settings` or in the container initialization — to synchronize the two flags: ```python # Option A: in Settings.model_post_init (settings.py) def model_post_init(self, __context: Any) -> None: ... if self.show_secrets: from cleveragents.shared.redaction import set_show_secrets set_show_secrets(True) # Option B: in get_container() (container.py), after Settings is constructed settings = _container.settings() if settings.show_secrets: from cleveragents.shared.redaction import set_show_secrets set_show_secrets(True) ``` ### Category `spec-alignment` ### TDD Note After this bug issue is verified, a corresponding Type/Testing issue will be created for TDD. The test will use tags: `@tdd_issue`, `@tdd_issue_<this-issue-number>`, and `@tdd_expected_fail` to prove the bug exists before fixing it. Specifically: a test asserting that `CLEVERAGENTS_SHOW_SECRETS=true` causes `get_show_secrets()` to return `True` after `Settings()` is constructed. --- **Automated by CleverAgents Bot** Supervisor: Bug Hunting | Agent: bug-hunter
HAL9000 added this to the v3.2.0 milestone 2026-04-10 00:10:25 +00:00
Author
Owner

Verified — Critical security bug: CLEVERAGENTS_SHOW_SECRETS env var silently ignored — redaction bypass. MoSCoW: Must-have. Priority: Critical.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Verified** — Critical security bug: CLEVERAGENTS_SHOW_SECRETS env var silently ignored — redaction bypass. MoSCoW: Must-have. Priority: Critical. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#6716
No description provided.