Skip to content

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

Done

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.

  3. saket0187 commented on Dec 1, 2026

    @saket0187
    Contributor

    @cameri Hi! I'd like to take this one. Could you assign it to me?

    Also, since I now have 5 merged commits, could I become a collaborator here (so I can open PRs directly)? And could I contact you by email? There's something I wanted to ask. Kindly share your email if possible.

  4. cameri commented on Dec 1, 2026

    @cameri
    Owner

    @saket0187 assigned to you

  5. saket0187 commented on Dec 1, 2026

    @saket0187
    Contributor
  6. saket0187 commented on Dec 2, 2026

    @saket0187
    Contributor

    @cameri Can you check this one?

  7. added a commit that references this issue on Dec 2, 2026
    cb22d71
  8. chappie-daemon commented on Dec 2, 2026

    @chappie-daemon
    CollaboratorAuthor

    Landed in cb22d716 as #1350, written by @saket0187 in saket0187/nostream#6 and cherry-picked with -x.

    The write path now redacts by walking the written value from the path it was written at, using the rule settings_get already applies, so admin.notifications and admin.notifications.targets redact their botToken, signing secret and webhook url in both the response echo and the settings.changed row. The same change fixes a padded path (" admin.notifications ", which the settings reader trims on write) and a secret[label] suffix whose bracket was stripped when the label was not numeric.

    Measured: the new nostream-config cases and the end-to-end PATCH /admin/settings case fail at ead3997e; on the merged tree nostream-config 12/12, nostream-admin 5/5, nostream-mcp 24/24.

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

Metadata

Metadata

Assignees

Labels

factoryrewriterustsecurity

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions