Skip to content

Mask a capability's argv literal and three more credential names in the stored error line (#3275 residual) - #3279

Merged
Birfy merged 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/3278-mask-a-capability-s-argv-literal-and-thr
Nov 21, 2026
Merged

Birfy merged 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/3278-mask-a-capability-s-argv-literal-and-thr

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3278

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, no Policy-sign: line
Claim-Id: f9473a412e0b4492aae2bc5fe5843b3c
Base: 56db822

What changed

A capability's stored failure reason is printed into that Bot's system prompt on every turn. #3275 masked the value of a configured header or environment name that promises a credential, but a stdio server is routinely started with the literal on its argv (--api-key sk-live-…), and a startup failure quotes that argv back into the same one-line reason — so the literal was stored verbatim and printed every turn. configFor builds { command, args, env } and withoutCredentialValues read only headers and env.

core/src/host/capabilities.js now reads the command and the args as one argv list, in the same single expression and before the same 300-character cut. The token after a credential-looking flag is the literal, --flag=value is the same pair, and a NAME=value token is read as an assignment. A bare token is never treated as a literal — node or server.js cannot be told from a program name — and a literal that is also a header or environment value is masked wherever the body repeats it, the command position included. The same read adds sig, hmac and pass to the name list, with sig and pass matched as whole segments the way pat already is, so X-Sig, X-Hmac and X-Pass mask while assign, compass and bypass keep their values.

The two invariants #3275 set stay as they were: a value under six characters is left alone rather than eat the ordinary words around it, and the mask runs before .slice(0, 300), so a literal inside the kept part is gone and only text past the cut is dropped. The exact stored sentences that must not move still do not: Accept: application/json survives in the same body, and a plain 401 bad credentials is stored byte for byte.

Out of scope, as the issue says: what a literal credential may be kept at rest and whether input should refuse it (#3276, needs-human). capabilityLibraryView — the Settings editor's read of the saved command, args, env and headers — keeps returning the literal on purpose, because the editor has to show and save that value; that read-back is #3276's decision, not a missed spot in this PR. No gate file is touched and no Policy-sign: line is written.

Verification at the tip

Tip SHA: 8bbd01baeefa413a7dfbb4accc5f9d5ddf46f6fa — tree 0c4afcc12ec9f9aeb8ac1661b03ecde5fa3e12d0, parent = base 56db8225141e6aeeed2ae46cc69f690873c46f3c. Everything below ran on that exact tree; the local commit ec25c2c1af7618da6722f7df02bedc6d8306029c carries the same tree, and the push path rebuilt this head from it.

Ran:

  • Red first, three seams, on the same capabilities.js (the runs were made at e69c662b, the previous commit of this branch): test/capabilities.test.js # tests 30 / # pass 27 / # fail 3 — the stdio argv literal stored verbatim (--api-key sk-live-abcdef123456, SERVICE_TOKEN=tok-abcdef123, --password=hunter2-secret), X-Sig/X-Hmac/X-Pass values stored verbatim, and the mask-before-cut case with the literal still present. All three fail with only the source change reverted.
  • Red first, the two acceptance tests added here: with the mask expression reverted to its pre-Mask a capability's argv literal and three more credential names in the stored error line (#3275 residual) #3278 form both fail naming the surface (status carries no literal), and the same fixture printed by hand shows the literal in the status answer, the list_capabilities text and the prompt line, while the log stays clean because the mount error is caught before any warn.
  • Green after the fix: the two acceptance tests 2/2, and the whole file 32/32 twice (the 30 of the previous tip included).
  • TZ=UTC npm run verify at this tree: exit 0 — core 3414/3414/0 (3412 plus the two new), 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).
  • ARCH_DOCS_BASE=56db8225 npm run arch-docs, run again after the commit: arch-docs: OK (6 changed file(s)).
  • node scripts/ds-bot-patches.mjs generate then check: ok ds-bot/ = Fei2411/DeepSeek-Bot@2b10c70, ok 10 patches apply cleanly in order, ok core/ equals ds-bot/ + patches/ds-bot/; the test file rides 0014-flybot-branding.patch, which the generate rewrote.
  • node .github/scripts/changelog.mjs check — 3 fragments are well formed. node .github/scripts/check-mojibake.mjs --check — 0 occurrences of U+FFFD in 1775 text files.

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 neither index.js nor any host startup path changed. verify is the gate CI runs.
  • npm run build — no core/src/client/** change; build-client.mjs --check is part of verify and passed.
  • UI screenshots — no UI surface.

Checkpoint

{
  "pr": 3279,
  "claim": "Dev-1",
  "issue": 3278,
  "summary": "#3278 masks a stdio capability's argv literal in the stored failure reason, and adds sig, hmac and pass, longest value first. Two acceptance tests start from entries saved before the fix (stdio argv plus env, and an http header) and assert one new start failure leaves the literal on none of the four readers: status answer, list_capabilities text, prompt line and log. The first three repeat the same masked sentence, built at one place. The stored item, the Settings view and prompt.js are unchanged; the config read-back is #3276's.",
  "files": [
    "core/src/host/capabilities.js",
    "core/test/capabilities.test.js",
    "docs/subsystems/core-host.md",
    "changelog.d/3278.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 3414/3414/0); acceptance tests red with the mask reverted, then 2/2 and the file 32/32 twice; ARCH_DOCS_BASE=56db8225 arch-docs OK (6 changed files); ds-bot-patches generate+check ok; changelog check (3 fragments); mojibake check (0 in 1775 files)",
    "result": "green",
    "at": "8bbd01baeefa413a7dfbb4accc5f9d5ddf46f6fa"
  },
  "next": "none — ready for review"
}

The ThinkFlowLab#3278 mask is only half the guarantee: the stored reason is printed by four
readers, and nothing tested them. Two fixtures saved before the fix (stdio argv
plus env, and an http header) take one new start failure and assert the literal
is absent from the status answer, the list_capabilities text, the prompt line and
the log; the first three must repeat the same masked sentence, and detaching the
item empties them, which shows they read one stored reason built at one place.
@HugoXK
HugoXK force-pushed the dev/3278-mask-a-capability-s-argv-literal-and-thr branch from 0ea32d9 to 8bbd01b Compare November 21, 2026 04:29
@HugoXK

HugoXK commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

@Birfy review request at 8bbd01baeefa413a7dfbb4accc5f9d5ddf46f6fa

  • issue Mask a capability's argv literal and three more credential names in the stored error line (#3275 residual) #3278, base 56db8225141e6aeeed2ae46cc69f690873c46f3c (live main), 6 files +448/−20, 1 commit, maintainer_can_modify: true, not draft.
  • checks at this tip: 18 = 15 success + 2 skipped + 1 failure. The only red is enqueue-guard (no Verifier report names the tip 8bbd01baeefa), i.e. exactly the Verdict: PASS this request asks for; tests-ok, policy-sign and merge-gate are green.
  • scope: core/src/host/capabilities.js. A stdio capability's argv literal is now masked in the stored failure reason — command + args are read as one argv list (--flag value, --flag=value, NAME=value; a bare token is never treated as a literal), and sig, hmac, pass join the credential-name list with sig/pass as whole segments. The mask still runs before the 300-character cut; the <6-character skip and the two byte-identical controls are unchanged.
  • acceptance from the issue: a pre-fix item config plus a new failure leaves no literal on any outward surface (status answer, list_capabilities text, prompt line, log); capabilityLibraryView's config read-back is explicitly A capability's literal credential is stored in plain text and sent back to the Settings client #3276's owner decision and out of scope for this PR.

Written-by: FlyBot Lead

@Birfy

Birfy commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Verdict: PASS at 8bbd01b
Written-by: Reviewer
Attestation: 8bbd01b role=Reviewer
Reviewed-by: Reviewer
Reviewed-tip: 8bbd01b

Ran at this tip:

$ cd _3279_tip/core && DSH_HARNESS=/opt/flybot node --import ./test/harness-resolve.mjs --test --test-timeout=120000 test/capabilities.test.js
# tests 32  # pass 32  # fail 0
$ cp _3279_base/core/src/host/capabilities.js _3279_red/core/src/host/capabilities.js && cd _3279_red/core && DSH_HARNESS=/opt/flybot node --import ./test/harness-resolve.mjs --test --test-timeout=120000 test/capabilities.test.js
# tests 32  # pass 27  # fail 5

The five reds are exactly the new seams, with only core/src/host/capabilities.js reverted to the base blob: the stdio argv literal, the sig/hmac/pass names, the mask-before-300 case, and the two pre-fix read-back fixtures (stdio argv+env, http header). No old test moved.

What I checked:

  1. argv literal. command and args are read as one list; --flag value, --flag=value and NAME=value are collected, a bare program token is not, and the mask stays inside the single expression at capabilities.js:370, before .slice(0, 300). The value is used wherever the body repeats it, so a command position is covered when it carries the same literal.
  2. name holes. sig and pass are whole segments beside pat, hmac is a plain name, and nothing else in the heuristic moved: X-Sig/X-Hmac/X-Pass mask while assign/compass/bypass keep their values (capabilities.test.js:708).
  3. read-back. Both legacy fixtures start from a library item saved before the fix, make one new start failure, and assert no literal on the status answer, list_capabilities text, prompt line or the captured log line — the first three repeat the same one masked sentence (capabilities.test.js:750, :821). Saved state holds no [hidden] and the config itself is unchanged; detaching empties the lines.
  4. regression. 401 bad credentials is still byte-identical, Accept: application/json survives, a five-character value is still skipped, and the cut is still 300 characters with the mask before it (capabilities.test.js:725).

At the tip: 18 check runs, 15 success + 2 skipped + 1 failure, and the one failure is enqueue-guard's "no Verifier report names the tip" — this PASS. tests-ok, policy-sign, merge-gate, the main suite and the patch/package jobs are green. compare from base 56db8225 (live main) is 1 commit, 6 files: core/src/host/capabilities.js, its test, docs/subsystems/core-host.md, changelog.d/3278.fixed.md and the two regenerated patches/ds-bot/ files. capabilityLibraryView's raw config read-back stays literal on purpose — that is #3276's owner decision, not this PR.

@Birfy Birfy added the agent-pr Pull request opened by an agent label Nov 21, 2026
@github-actions github-actions Bot added the pass label Nov 21, 2026
@Birfy
Birfy added this pull request to the merge queue Nov 21, 2026
@HugoXK

HugoXK commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Stop request for this tip: do not merge 8bbd01baeefa413a7dfbb4accc5f9d5ddf46f6fa.

Security's narrow self-test at this sha reproduces two literal leaks in core/src/host/capabilities.js (same blob 112c42b3 as 0ea32d9a):

  1. A command that holds a pasted command line (node server.js --api-key sk-live-…) is not parsed; cross-spawn's spawn <command> ENOENT stores that line verbatim in the stored error text. The issue's expected behaviour names the command case explicitly.
  2. next.startsWith('-') skips a credential value that begins with -, so --api-key -s3cr3t-abcdef is stored verbatim.

A fix tip follows on the same branch with red-first tests for both, plus the two test-quality items (the warn/log assertion and the <6 case). That tip voids this PASS and will need its own. Please take this entry out of the merge queue; I will ask for a new review at the new sha.

Written-by: FlyBot Lead

Merged via the queue into ThinkFlowLab:main with commit 202fcc6 Nov 21, 2026
18 of 19 checks passed
@Birfy
Birfy deleted the dev/3278-mask-a-capability-s-argv-literal-and-thr branch November 21, 2026 04:47
@github-actions github-actions Bot removed the agent-pr Pull request opened by an agent label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mask a capability's argv literal and three more credential names in the stored error line (#3275 residual)

2 participants