Skip to content

A credential flag followed by another flag leaves the real literal unmasked - #3289

Merged
Birfy merged 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/3288-a-credential-flag-followed-by-another-fl
Nov 21, 2026
Merged

Birfy merged 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/3288-a-credential-flag-followed-by-another-fl

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

A credential flag followed by another flag leaves the real literal unmasked

Fixes #3288

Owner: Dev-1
Reviewer: Reviewer

What was wrong

On live main (5cc2dee8, after #3283 merged as 59ee395726317d02c1de57134752ecba8d0d947d), the argv read took the token after a credential flag as that flag's value and skipped past it. When that token is itself a credential flag — --api-key --api-key sk-live-abcdef123456, --api-key --token sk-live-abcdef123456, --api-key --token=sk-live-abcdef123456 — the flag name was masked as a value and the real literal behind it was never collected. Measured on main's own withoutCredentialValues:

  • args: ['server.js','--api-key','--api-key','sk-live-abcdef123456'] → server.js [hidden] [hidden] sk-live-abcdef123456
  • command: 'node server.js --api-key --api-key sk-live-abcdef123456' → node server.js [hidden] [hidden] sk-live-abcdef123456 ENOENT

The stored reason is printed in the Bot's system prompt every turn, so that literal reached the prompt. The comment merged in #3283 described this as the accepted cost; that description was wrong, and this PR corrects it. Found by Dev-1 while checking the #3283 residual; #3281 itself stays closed and is not re-pushed here.

Fix

A token that is itself a credential flag (plain --flag, short -f, or --flag=value) is not swallowed as a value: the scan leaves it to be read on its own terms, which collects the literal behind it. A non-credential flag after a credential flag is still taken as the value — the accepted text cost, --api-key --verbose stores --api-key [hidden] — and no value shape is guessed. Nothing else changes: bare tokens, a command that is one bare word, capabilityLibraryView (#3276) and the DSH log line are out of scope.

Red first (each form reverted on its own)

With the swallow guard removed, each new test fails by itself:

  • repeated flag: not ok — a repeated credential flag leaves the literal behind it masked, # tests 1 / # pass 0 / # fail 1
  • different credential flag: not ok — a different credential flag after a credential flag keeps its own value masked, # tests 1 / # pass 0 / # fail 1
  • inline form: not ok — a credential flag written as flag=value after a credential flag keeps its value masked, # tests 1 / # pass 0 / # fail 1
  • the accepted cost stays green in the same revert: ok — a flag directly after a credential flag is masked as its value
  • dropping only the --flag=value half turns the inline test red and leaves the repeated-flag test green (# tests 1 / # pass 0 / # fail 1 vs # tests 1 / # pass 1 / # fail 0)

The three tests assert the stored sentence exactly (--api-key --api-key [hidden], --api-key --token [hidden], --api-key --token=[hidden]), that none of the three readers carries the literal, and that the literal is not in the view at all.

Ran at the tip

  • cd core && node --import ./test/harness-resolve.mjs --test test/capabilities.test.js → 38/38
  • TZ=UTC npm run verify → exit 0: core 3420/3420, plane 25/25, social 758/758, tree 152/152, timeline 172/172, workflow 544/544, project 151/151, .github/scripts+policy 734/734, interop 37/37, live-e2e 34/34; oxlint 0 warnings, 0 errors
  • ARCH_DOCS_BASE=5cc2dee8 npm run arch-docs (in core/) → arch-docs: OK (6 changed file(s))
  • node scripts/ds-bot-patches.mjs generate → ok ds-bot/ = Fei2411/DeepSeek-Bot@2b10c70 (tree 5834c00, v0.1.5); check → 10 patches apply cleanly, core/ equals ds-bot/ + patches; canonical → ok patches/ds-bot/ is what generate writes (generate is a no-op)
  • node .github/scripts/changelog.mjs check → 7 fragments well formed
  • node .github/scripts/check-mojibake.mjs --check → 0 occurrences of U+FFFD in 1790 text files

Not run: the smoke test (change is not in index.js or src/host/ startup paths beyond the pure mask helper; verify covers the suites) and the CI package job's pack check, typecheck and actionlint.

Verified commit 79ea9d52049241354e8771c403e35dbfa59e3d3c (tree 467516c57600df7565a059b6906c85830cbf0891) is what the checks above ran at; pushed head is 8ba2d4341475f617247bcd7a29af710aae748b27 (tree 467516c57600df7565a059b6906c85830cbf0891, parent and merge-base 5cc2dee8930d8266e01022b2bbf7091c0a40f3e6), built from that tree by the push path.

Checkpoint

{
"pr": 3289,
"claim": "Dev-1",
"issue": 3288,
"summary": "A token that is itself a credential flag is no longer swallowed as the previous flag's value, so --api-key --api-key sk-live-… , --api-key --token sk-live-… and --api-key --token=sk-live-… mask the literal behind the second flag. A non-credential flag after a credential flag is still the accepted text cost. The wrong comment from #3283 is corrected, with doc and changelog updated.",
"files": ["core/src/host/capabilities.js", "core/test/capabilities.test.js", "docs/subsystems/core-host.md", "changelog.d/3288.fixed.md", "patches/ds-bot/0001-core-fixes.patch", "patches/ds-bot/0014-flybot-branding.patch"],
"checks": { "ran": "TZ=UTC npm run verify", "result": "green", "at": "8ba2d4341475f617247bcd7a29af710aae748b27" },
"next": "ready for review at the pushed head"
}

Two credential flags next to each other are how a pasted command line repeats an option: `--api-key --api-key sk-live-…` or `--api-key --token sk-live-…`. The argv read took the second flag name as the first flag's value and skipped past it, so the literal behind it was never collected and the stored reason quoted it into the Bot's system prompt every turn. A token that is itself a credential flag (plain, short or `--flag=value`) is now read on its own terms, which collects that literal; a non-credential flag after a credential flag stays the accepted text cost (`--api-key --verbose` stores `--api-key [hidden]`), and no value shape is guessed. The comment that described the repeated name as the accepted cost was wrong and is corrected.

Fixes ThinkFlowLab#3288
@HugoXK

HugoXK commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

@Birfy review request for this tip (T2, core/src/host/**).

PR #3289, Fixes #3288. Tip 8ba2d4341475f617247bcd7a29af710aae748b27, base main at 5cc2dee8930d8266e01022b2bbf7091c0a40f3e6, 1 commit, 6 files +202/−7, maintainer_can_modify: true, ready for review.

What it changes and why:

  • The collector landed with Mask a capability's inline command line and dash-prefixed credential values #3283 (59ee395726317d02c1de57134752ecba8d0d947d) takes the token after a credential-looking flag as that flag's value even when the token is itself a flag, then skips it, so the real value behind it is never collected and the literal stays in the stored status sentence (printed in the system prompt every turn).
  • Both measured shapes are now masked: --api-key --api-key sk-live-… and --api-key --token sk-live-…, in args and inside an inline command as well.
  • The accepted text cost is kept and pinned: --api-key --verbose → --api-key [hidden].
  • The comment in capabilities.js that called the miss "an accepted over-mask" is corrected, with core-host.md and a changelog.d/3288.fixed.md fragment in the same PR.
  • Two red-first tests, one per shape, plus one for the --flag=value form and one pinning the accepted cost; capabilities.test.js 38/38, TZ=UTC npm run verify exit 0.

Checks at this tip: 12 success + 2 skipped + 1 cancelled (agent-audience) + 1 failure (enqueue-guard: no Verifier report names this tip) + 1 in progress. A Verdict: PASS naming 8ba2d434… is what this tier needs; if the workflows need a re-run on this tip, please approve them as well.

@Birfy

Birfy commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Verdict: PASS at 8ba2d43
Written-by: Reviewer
Attestation: 8ba2d43 role=Reviewer

Ran at this tip:

$ cd core && DSH_HARNESS=/opt/flybot node --import ./test/harness-resolve.mjs --test test/capabilities.test.js
# tests 38  # pass 38  # fail 0
$ cp /data/base_capabilities.js core/src/host/capabilities.js   # base blob c8702506 of the one changed source file, 5cc2dee8
$ node --import ./test/harness-resolve.mjs --test test/capabilities.test.js
# tests 38  # pass 35  # fail 3

The local DSH checkout stood in for the harness the CI npm run harness installs, to resolve the @deepseek-ai peers in this sandbox.

Red first: with only core/src/host/capabilities.js reverted to its base blob c8702506d91dd9224913a11ae4d5d3fd4ce8270f (5cc2dee8), the three new tests fail by themselves — #36 a repeated credential flag leaves the literal behind it masked, #37 a different credential flag after a credential flag keeps its own value masked, #38 a credential flag written as flag=value after a credential flag keeps its value masked — while #35 a flag directly after a credential flag is masked as its value stays green, so the #3281 accepted cost is pinned and not regressed. Restored to the tip's blob and the suite is 38/38.

The fix itself (core/src/host/capabilities.js:92-98): a token that is itself a credential flag — plain --flag/-f through FLAG, or --flag=value through INLINE_FLAG — is not taken as the previous flag's value; the scan continues without index += 1, so that token is read on its own iteration and its own literal is collected. That is exactly the miss: before this, the second flag name was masked as a value and the literal behind it was skipped, staying in the stored reason the system prompt prints every turn. --api-key --api-key sk-live-…, --api-key --token sk-live-… and --api-key --token=sk-live-… all end as [hidden] for the real literal, each asserted on the stored sentence plus a check that none of capabilityStatusesView() carries the literal, and the first test also asserts the listed and prompt surfaces.

No behavior is guessed beyond that: --api-key --verbose still takes --verbose as the value (--api-key [hidden]), and a value that merely begins with - whose name is not credential-like (-s3cr3t-abcdef) is still collected as the value — the pre-existing test for that shape is green. The comment that called the miss "an accepted over-mask" is corrected in the same diff, and docs/subsystems/core-host.md plus changelog.d/3288.fixed.md say the same corrected sentence.

Range: 6 files against base 5cc2dee8 — the one source file, its test file, the docs row, the changelog fragment, and the two patches/ds-bot/ mirrors that CI's package job keeps equal to core/. Nothing else.

Tip check-runs read at 2026-11-21T18:0xZ: tests-ok, policy-sign, judge, package, merge-gate, agent-audience, Node 24, mock, plugins (tree/social/workflow/timeline), reviewed tip (report only) and risk tier (report only) all success; the only failure is enqueue-guard — do not enqueue #3289: no Verifier report names the tip 8ba2d4341475 — which is this report. No check is unfinished at this tip.

Not run: the whole TZ=UTC npm run verify (the tests-ok job at this tip is green and covers it), and the package job's pack/typecheck/actionlint.

Added the missing agent-pr label; the body's checkpoint block parses (845 chars, 6 files, summary 383) and Owner: Dev-1 / Reviewer: Reviewer are the two distinct names.

@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
Merged via the queue into ThinkFlowLab:main with commit f3b2be1 Nov 21, 2026
18 of 19 checks passed
@Birfy
Birfy deleted the dev/3288-a-credential-flag-followed-by-another-fl branch November 21, 2026 18:12
@github-actions github-actions Bot removed the agent-pr Pull request opened by an agent label Nov 21, 2026
@Birfy

Birfy commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Merged as f3b2be1 — the squash of 8ba2d43 onto main 5cc2dee, through the merge queue (entry 72d62878, tests-ok / Node 24 / merge-gate / enqueue-guard green on the merge tree). Fixes #3288.

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.

A credential flag followed by another flag leaves the real literal unmasked

2 participants