Repository navigation
fix(admin): refuse a write at a path above a protected value - #1353
Conversation
`PATCH /admin/settings` and the MCP `settings_set` tool checked the paths the request
named, so a change at a path that holds `admin.passwordHash` — replacing `admin` — wrote
it too: one change with `{"path":"admin","value":{"passwordHash":"…"}}` answered 200 and
the stored hash became the one sent, and a token holding only the `write` scope could
reach it through `settings_set`.
What is protected is now read from the stored document and from the document as it would
be saved, and a write that moves one is refused with `Path is write-protected`, as the
console on `main` already does (`settings-redaction.ts:56-86`,
`patch-settings-controller.ts:92-100`). The comparison covers a value that is added or
removed as well as one that changes.
Closes #1352.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
🦋 Changeset detectedLatest commit: 6cc9a33 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Confidence Score: 5/5
[Critical impact] The PR appears safe to merge; no actionable issues were found.
|
The settings write path checked the paths a request named and let through a write at a path that holds
admin.passwordHash. Replacingadminreplaced the hash, so a settings write could take over the console. Closes #1352.Measured before
On
cb22d716:The echo redacts the value, so the answer looks correct while the write lands. MCP
settings_setcalls the samepatch_settings::apply, so a token holding only thewritescope reached it too.Why
patch_settings.rs:108refused only a change whose path is write-protected.validate.rs:578deliberately allowspasswordHashas a key underadmin, so the value validated, andset_by_paththen replaced the subtree.mainguards this by comparing documents rather than paths:patch-settings-controller.ts:92-100callschangedWriteProtectedSettingsPaths(protectedBefore, nextUserSettings)and refuses when any protected value moved, with a comment naming this exact case.Change
collect_write_protected_settingsandchanged_write_protected_settings_pathsinnostream-config, ported fromsettings-redaction.ts:56-86: every protected path in a document, and the ones whose value differs between two documents, added or removed ones included.patch_settings::applycollects the protected values of the stored user document and of the document as it would be saved, after the changes are applied and before anything is written, and refuses withPath is write-protectedon any difference.Testing
cargo test -p nostream-config --test redactioncargo test -p nostream-admin --test write_pathcargo fmt --check,cargo clippy -D warningsThe end-to-end test asserts the 400, that
settings.yamlstill holds the old hash, and that nothing is queued to the outbox.