Skip to content

admin: a container-valued settings write echoes its secret in the response and the settings.changed payload #1193

Open

Description

@chappie-daemon

Found by: the security lens in review round 1 of job 033-admin-mcp-server (round-1/review-security.md, note 1), at 7a1cde0e. Note-level there because the function is byte-for-byte the HTTP surface's; filed so the fix lands once for both.

crates/nostream-admin/src/controllers/patch_settings.rs:45-50 — redacted_change redacts only a string at the exact path. A write to a container-valued path therefore echoes its secret raw: measured, settings_set on admin.notifications.targets[0].botToken returned the token in structuredContent, and the same value rides the settings.changed outbox payload that an operator's configured target then receives.

Fix direction: redact by path prefix (a sealed or secret-bearing subtree redacts everything under it), reusing the same rule settings_get already applies to the document; then one test that writes a container carrying a token and asserts the response and the outbox row both show ***.

Scope note: this reaches the HTTP console too (PATCH /admin/settings echoes the changed value), so the fix belongs in the admin crate, not in the MCP layer.

Activity

  1. added
    security
    rewrite
    rust
    factory
    on Nov 19, 2026
  2. chappie-daemon commented on Nov 20, 2026

    @chappie-daemon
    CollaboratorAuthor

    Still live at 982e6759, and the fix is smaller than the note suggests: the walking redactor the note asks for already exists two functions below the one that leaks.

    crates/nostream-config/src/redaction.rs:39 — redact_settings_value(path, value) redacts only when the value at that exact path is a Value::String; anything else falls through other => other.clone() (:44). redact_settings_value is called from exactly one place, crates/nostream-admin/src/controllers/patch_settings.rs:48, and that is the echo path.

    redaction.rs:49 — redact_settings_secrets(value) already walks sequences and mappings and rebuilds each path, so it redacts a whole subtree. It is what get_settings (:23), diagnostics (:22) and the notification fan-out (notifications.rs:230) use, which is why the read path is safe and the write echo is not.

    So the change is: for a container-valued change, walk it instead of cloning it — redact_settings_secrets applied to the parsed value under the change's own path (or redact_settings_value delegating to the walker for non-scalars). One function, one call site, no new API, and the existing get_settings tests are the shape the new write-path test should copy.

    Worth adding to the same change, since it is the same bug on a second surface: the settings.changed outbox payload built in notifications.rs:230 already redacts, so the echo in patch_settings.rs:48 is the only remaining raw path — a test that writes a container carrying targets[0].botToken and asserts it in both the controller response and the emitted payload would pin it in one go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    factoryrewriterustsecurity

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions