Repository navigation
Commit a9e648f
fix(config): reverse the readTarget raw-secret decision -- always redact (TKT-323, feedback anomalyco#191) (#32)
* fix(config): reverse the readTarget raw-secret decision -- always redact (TKT-323, feedback anomalyco#191)
REVERSES a documented decision, not a routine leak patch. document.ts:88-89
(now rewritten) argued readTarget's raw text needed to stay byte-real for
the direct-file-editing escape hatch, or a patch computed against a
redacted view would corrupt a secret on write. That concern is refuted by
the shipped write model: applyPatch never serializes text wholesale --
Patch is a typed, allowlisted field-op union applied against text the
server re-reads itself, so an unedited field is simply absent from the
patch and never written back. No consumer of readTarget's real secret
values existed (enumerated in parallel with the fix).
Confirmed live before any severity was assumed: a real secret
(mcp.servers.*.environment.KEY) round-tripped verbatim through readTarget
while the sibling effective() correctly redacted the identical value, same
protocol group, same request shape.
The rule now: every API read response is unconditionally redacted --
readTarget, effective, validatePatch's preview, every future
*.catalog.list. There is no operation that reveals a real secret value
over the API; the escape hatch is editing the config file on disk
directly. Reversible by addition (a future explicit reveal-op), never by
weakening the default -- see FORK.md's decision record.
Corollary: applyPatch now rejects (RedactedValueRejectedError -> 400) a
patch that would write the literal "[redacted]" sentinel over a secret
field -- a read-then-write UI that never touched the real value must not
silently overwrite it. Only safe to enforce now that readTarget never
returns a real value to accidentally echo back.
mcpSecretPaths is the one shared allowlist the object redactor, the
raw-text redactor (via jsonc-parser's own modify/applyEdits, the same
mechanism applyPatchToText already uses -- not a blind string
search-replace), and the write-time rejection check all read, so a future
secret-shaped field extends one list instead of three.
Pinning test at document.test.ts (previously asserting the real values
WERE present in readTarget, on purpose, per the now-reversed rationale) is
inverted to assert them absent and placeholders present, with the reason
recorded in its name and a comment. Build post's migration step 9 (the
"escape hatch...always show the selected source document" line) is
clarified in the same change: through the same redacted read API, not an
unredacted response.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JJQrqYMv43CrdbjpTT7884
* fix(config): address Copilot review findings on #32
- readTarget: derive the mcp-secret paths for text redaction from jsonc-parser's
own lenient parse, not parseAndDiagnose's diagnostics-gated `parsed`. An
unrelated syntax error anywhere in the document was zeroing `parsed` entirely,
which fell through to `mcp === undefined` and returned the raw, unredacted
text -- the exact leak this PR exists to close, reachable through a second
path. Added a regression test, confirmed red pre-fix / green post-fix.
- config-document handler: InvalidRequestError.field was set to the target ID
(a value), not a stable field name -- misleading for a client trying to
locate the invalid input. Moved the ID to `kind` and set `field: "patch"`,
matching the existing convention in handlers/session.ts.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JJQrqYMv43CrdbjpTT7884
* docs(fork): flip the "no automated review" section to the new truth
Sean enabled a Copilot Review ruleset on this fork (id 20729187) the same
session this PR was open. Its first real firing was on this PR -- two
genuine findings, both fixed above -- which settles the question the old
"No" section answered with evidence that has since gone stale. Retains the
original finding as a collapsed historical record rather than deleting it,
since the "assume no review runs" convention it backed was cited by name
across every ticket in this tree.
Adds the wrong-base caveat from the same process update: a branch cut from
a branch (not from dev directly) silently inherits that branch as its PR
base unless --base is passed explicitly, and a wrong-based PR gets no
automated review.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JJQrqYMv43CrdbjpTT7884
* fix(config): fail closed on unparseable documents, per lead ruling
Supersedes 78be611's lenient-parse fix for the same Copilot-flagged hole.
A lenient recovery parse can itself silently DROP the secret-bearing branch
when a malformed region swallows it -- the redactor would then see no
secrets while the raw text still carries them byte-for-byte. A guarantee
conditional on how badly the file is broken is not a guarantee.
readTarget now withholds `text` entirely when the document has any parse
diagnostic, returning a named RedactionWithheld({reason: "could-not-parse"})
citizen instead of a best-effort redaction -- same pattern as McpRuntime's
truthful unavailable default (TKT-323 chunk 2), never an implicit fallback.
The escape hatch for a broken config is editing it on disk directly, already
the rule for every other read path; the diagnostics already returned are the
fix-it information.
Both regression tests flipped from asserting a redacted `text` to asserting
a withheld one, and the pre-existing malformed-jsonc fixture gains a real
secret so this leak class can never return silently again. Confirmed red
against the reverted code, green against the fix.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JJQrqYMv43CrdbjpTT7884
* fix(config): redactParsed must not reshape an array-rooted document
Copilot review finding on PR #32 (Suppressed comments section): the
typeof/null guard alone lets an array through -- typeof [] === "object" and
[] !== null -- so Object.fromEntries(Object.entries(...)) silently turned an
array-rooted document into a plain object with numeric string keys, beyond
the intended mcp redaction. Excludes arrays explicitly; `parsed` now mirrors
the real document shape. Regression test confirmed red pre-fix, green
post-fix.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JJQrqYMv43CrdbjpTT7884
* chore(client): regenerate after RedactionWithheld protocol change
The check:generated CI guard caught this correctly on its first real
protocol change since the last audit -- packages/client/src/generated was
never regenerated after ReadTarget.text widened to string | RedactionWithheld
in 97011af. Regenerated via bun run --cwd packages/client generate; the
only diff is the expected type widening on ConfigDocumentTargetReadOutput.text.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JJQrqYMv43CrdbjpTT7884
---------
Co-authored-by: opencode <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>1 parent d3710b1 commit a9e648f
8 files changed
Lines changed: 457 additions & 73 deletions
File tree
- packages
- client/src/generated
- core
- src/config
- test/config
- protocol/src/groups
- schema/src
- server/src/handlers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
102 | 159 | | |
103 | 160 | | |
104 | 161 | | |
| |||
131 | 188 | | |
132 | 189 | | |
133 | 190 | | |
134 | | - | |
135 | | - | |
136 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
137 | 197 | | |
138 | 198 | | |
139 | 199 | | |
| |||
466 | 526 | | |
467 | 527 | | |
468 | 528 | | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
479 | 578 | | |
480 | 579 | | |
481 | 580 | | |
482 | 581 | | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
488 | 586 | | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
498 | 593 | | |
499 | 594 | | |
500 | 595 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1334 | 1334 | | |
1335 | 1335 | | |
1336 | 1336 | | |
1337 | | - | |
| 1337 | + | |
1338 | 1338 | | |
1339 | 1339 | | |
1340 | 1340 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3952 | 3952 | | |
3953 | 3953 | | |
3954 | 3954 | | |
3955 | | - | |
| 3955 | + | |
3956 | 3956 | | |
3957 | 3957 | | |
3958 | 3958 | | |
| |||
0 commit comments