Repository navigation
Mask a configured credential a capability's error body echoes into the prompt - #3277
Conversation
The security read at 57bdaa6 found two gaps in ThinkFlowLab#3275's mask. A `Cookie` or session header is a whole credential and was not matched by name; `pat` was missing entirely, though only as a whole segment so `X-Patch-Id` and `X-Path-Id` keep their values. And the replacement ran in entry order, so `{'X-Api-Key': 'abc123', Authorization: 'Bearer abc123XYZ'}` stored `Bearer [hidden]XYZ` while the same pair written the other way masked both — one credential can contain another, so the values are now replaced longest first, the way `secrets.js` sorts its own. The name list, the whole-segment `pat` rule and the ordering are written in the `core-host.md` prompt row and the changelog fragment as well.
57bdaa6 to
48f1eb4
Compare
|
Verdict: PASS at 48f1eb4 Ran at this tip: Full Points checked:
|
|
@Birfy review request at 48f1eb4 Tip At this tip: 15 success + 2 skipped + 1 failure — the only red is Scope: store-side masking of credential-looking header/env values in a failed capability's status line, before the 300-char cut in |
Fixes #3275
Written-by: FlyBot Dev-1
Owner: Dev-1
Reviewer: Reviewer
Tier: T2 (
core/src/host/**is T2 in.github/agent/risk-rules.json; the test, the doc, the fragment and the generated patches are T0/T1) — no gate file, noPolicy-sign:lineClaim-Id: d502a1267d0d4ec696aefc9d09021969
Base: e3caccb
What changed
A capability's failure reason is printed into that Bot's system prompt on every turn. The reason is the mount error, and a
streamable-httptransport builds that error from the server's own response body (Error POSTing to endpoint: <body>), so a server that echoes a request header writes a value the user typed into the capability into a host-stored string.redactSecretsis value-based — it replaces this host's saved secrets — so a literal configured value passed through untouched.core/src/host/capabilities.jsnow masks, before the 300-character cut, the value of any configured header or environment name that promises a credential (key,token,secret,auth,password,passwd,credential,signature,cookie,session,bearer, andpatas a whole segment —X-Github-Patcounts,X-Patch-IdandX-Path-Iddo not) wherever the joined error repeats it — the same place, and the same ordering, as the URL userinfo masking from #3273. Values are replaced longest first, the waysecrets.jssorts its own, because one credential can contain another:{'X-Api-Key': 'abc123', Authorization: 'Bearer abc123XYZ'}now masks the wholeBearer abc123XYZ, where entry order used to leaveBearer [hidden]XYZ— and the answer no longer depends on which entry was written first. Before:- echo (mcp): Error POSTing to endpoint: {"echoed":"X-Tenant-Key: abc123"} — tell the user before acting.After:- echo (mcp): Error POSTing to endpoint: {"echoed":"X-Tenant-Key: [hidden]"} — tell the user before acting.An ordinary configured header in the same body (Accept: application/json) survives, and a value under six characters is left alone rather than replace the ordinary words around it.Why mask at the store and not refuse a credential-shaped literal at input: a literal header is legal today, and a capability saved before this fix is still in the field, so an input refusal would neither clean it nor let it mount; it also needs a shape rule broad enough to reject a value the user may legitimately hold. What such a literal may be kept at rest, and what the Settings client gets back, is the separate product question in #3276 and is untouched here — as is the stored item, the library view, the client badge and
prompt.js. The issue's other half is unchanged: a plain reason is still stored byte for byte (401 bad credentials), andcore/src/host/prompt.jskeeps its line format, itsnot connectedfallback and its byte-identical healthy-prompt case.Verification at the tip
Tip SHA:
48f1eb43702d3f429fefa380bee3fc81034a475c— tree70faf63ea3c90a50b07c6fd466644ceb7863f00c, parente3caccbab4e59ccdf006e1ad5074642d8dddddee. Everything below ran on this exact tree (the push path rebuilt the commit from it).Ran:
# tests 27 / # pass 24 / # fail 3for the security read's two gaps — aCookie: sid=supersecretsession42value stored verbatim, aX-Github-Patvalue stored verbatim, and the ordering pair ({'X-Api-Key': 'abc123', Authorization: 'Bearer abc123XYZ'}→Bearer [hidden]XYZ, while the same pair written the other way round already masked both). The earlier red was# tests 23 / # pass 21 / # fail 2forX-Tenant-Key: abc123andSERVICE_TOKEN=tok-abcdef.test/capabilities.test.jstwice — 27/27 both runs, the original 23 included,401 bad credentialsstill byte-identical and A Bot says it can do the work before it knows its MCP capability is down — tell it in the system prompt #3273's userinfo case untouched.TZ=UTC npm run verifyat this tree — exit 0: core 3409/3409/0, plane 25/25, social 758/758, tree 152/152, timeline 172/172, workflow 538/538, project 151/151,.github/scripts+ policy 724/724, interop 37/37, live-e2e 34/34; the lint stage ran oxlint (0 errors) andarch-docs.ARCH_DOCS_BASE=e3caccbab4e59ccdf006e1ad5074642d8dddddee npm run arch-docson the committed tree —arch-docs: OK (6 changed file(s)).node scripts/ds-bot-patches.mjs generatethencheck—ok ds-bot/ = Fei2411/DeepSeek-Bot@2b10c70,ok 10 patches apply cleanly in order,ok core/ equals ds-bot/ + patches/ds-bot/;git statusclean after a second generate.node .github/scripts/changelog.mjs check— 2 fragments well formed.node .github/scripts/check-mojibake.mjs --check— 0 occurrences of U+FFFD.Not run (and why):
dev/bench.sh smoke— needs a DSH checkout and a free port on this box; the change is the text of a stored mount error, and neitherindex.jsnor any host startup path changed.verifyis the gate CI runs.npm run build— nocore/src/client/**change;build-client.mjs --checkis part ofverifyand passed.command/argsvalue or to a server-echoed URL — the security read named both, and they are outside this pull request by the Lead's decision; they get their own issue.Checkpoint
{ "pr": 3277, "claim": "Dev-1", "issue": 3275, "summary": "#3275: a capability's stored failure reason no longer repeats a credential the user typed into that capability. When a server echoes a request header or an environment value back in its own error body, the value of a name that promises a credential (key, token, secret, auth, password, cookie, session, bearer, and pat as a whole segment) is masked before the 300-character cut, longest value first so one credential is never left as a tail. An ordinary header survives and a plain reason is stored byte for byte; the stored item, the Settings view and prompt.js are unchanged.", "files": [ "core/src/host/capabilities.js", "core/test/capabilities.test.js", "docs/subsystems/core-host.md", "changelog.d/3275.fixed.md", "patches/ds-bot/0001-core-fixes.patch", "patches/ds-bot/0014-flybot-branding.patch" ], "checks": { "ran": "TZ=UTC npm run verify (exit 0, core 3409/3409/0); capabilities.test.js red 27/24/3 then green 27/27 x2; ARCH_DOCS_BASE=e3caccba arch-docs OK (6 changed files); ds-bot-patches generate+check ok; changelog check; mojibake check", "result": "green", "at": "48f1eb43702d3f429fefa380bee3fc81034a475c" }, "next": "none — ready for review" }