Skip to content

fix(#860): take the recovery OAuth token through plugin.json userConfig - #894

Merged
fdaviddpt merged 7 commits into
mainfrom
fix/860
Oct 3, 2026
Merged

fdaviddpt merged 7 commits into
mainfrom
fix/860

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

The directory portal's MCP_FORWARDS_CREDENTIAL_ENV check ("Uses a credential from the user's machine") flagged README.md, scripts/session-start-hook.sh and .claude-plugin/plugin.json on v0.38.0. PR #869 decided against building a fix, reasoning the three host-vendor credentials (CLAUDE_CODE_OAUTH_TOKEN, ANTHROPIC_API_KEY, CODEX_API_KEY) couldn't move and so the finding wouldn't clear. #860 was reopened rejecting that "decided against" framing, with five measurement questions and the instruction to measure rather than reason.

This PR measures, then builds:

  • Grepped scripts/session-start-hook.sh and .claude-plugin/plugin.json directly: no literal env-var names in either (plugin.json had no userConfig and no credential text at all before this change). The actual env reads live in pipeline/haiku.py, reached indirectly.
  • Fetched the real Claude Code plugin manifest reference and confirmed (observed, not reasoned): a sensitive: true userConfig value is exported to hook subprocesses as CLAUDE_PLUGIN_OPTION_<KEY>. claude plugin validate . passes against the worktree with this userConfig entry added.
  • Added .claude-plugin/plugin.json's userConfig.oauth_token (string, sensitive). pipeline/haiku.py's _configured_oauth_token() now prefers CLAUDE_PLUGIN_OPTION_OAUTH_TOKEN, falling back to the now-deprecated REMEMBER_OAUTH_TOKEN env var and haiku.oauth_token config.json entry -- both keep working, logging a deprecation notice once per save. The host's own CLAUDE_CODE_OAUTH_TOKEN passthrough, which must keep working with nothing configured, is untouched.
  • scripts/doctor.sh gained a section surfacing the deprecation notice, distinguishing "nothing to scan yet" from "scanned, clean" from "found".
  • README.md and docs/releasing.md updated: the migration story, and an explicit note that plugin.json's finding may clear while README.md's and scripts/session-start-hook.sh's likely will not (unconfirmed -- needs a real portal rescan).
  • Codex (.codex-plugin, no userConfig mechanism) stays on the legacy paths; a non-blocking wording gap in the deprecation message for a Codex host reaching this code via REMEMBER_SUMMARIZER_FALLBACK=claude is logged at trap.d/860.codex-fallback-deprecation-wording.md rather than fixed in this diff.

Red-then-green TDD throughout (tests/test_haiku.py, new tests/test_doctor_deprecated_oauth_860_notice.py). Self-reviewed by two concurrent spawns (Explore, oss:auditor); of 4 findings, 3 were fixed in a follow-up commit and 1 (the Codex wording gap) was argued down as non-blocking and logged to trap.d instead.

Closes #860

[AI-generated]

fdaviddpt added a commit that referenced this pull request Oct 3, 2026
…ing (CodeQL HIGH)

CodeQL flagged a HIGH "Clear-text logging of sensitive information" alert on
PR #894 at pipeline/haiku.py:497 (_warn's print to stderr), with two taint
source nodes labeled "sensitive data (password)". The flow: _accept_token()
built its malformed-value warning with `detail = f"{len(value.strip())}
chars"` -- a value DERIVED from the configured secret (the userConfig
oauth_token, or previously the now-removed REMEMBER_OAUTH_TOKEN/
haiku.oauth_token). CodeQL's taint tracker correctly follows that derivation
to the log sink: a length is still information about the secret, even
though the secret's own bytes never appear.

Fix: _accept_token()'s warning message no longer references `value` in any
form -- not the value, not its length, not its type name. It is built
entirely from constants and the `source` parameter (a label string the
caller passes, never derived from the configured value). This breaks the
taint flow at its root rather than suppressing the alert: no lgtm/codeql
ignore comments, no cosmetic renaming.

Updated: docs/verification.md's example log output and surrounding
checklist (the "9 chars" example was the exact shape CodeQL flagged).

Red test first (tests/test_haiku.py::test_malformed_userconfig_token_warning_never_logs_the_value):
asserts the logged line never contains the configured value, with a
positive control that it still names the setting. Confirmed failing against
the pre-fix code (logged "...got 9 chars)"), passing after the fix. 183
targeted tests pass; CI is the full-matrix gate. origin/main had not moved
(still f6d953b) -- no rebase needed; #895 had not merged either.

Co-Authored-By: Max <noreply>
…erConfig option

Anthropic's pre-submission checklist classes MCP_FORWARDS_CREDENTIAL_ENV
("Uses a credential from the user's machine") as "Held for a reviewer", not
a warning to be confirmed away at every review -- so #869's "decided against
building it" outcome, correct about the host-vendor-credential passthroughs
(CLAUDE_CODE_OAUTH_TOKEN / ANTHROPIC_API_KEY / CODEX_API_KEY, which are not
ours to move and must keep working with nothing configured), was being used
to also justify leaving in place the one part of the pattern that genuinely
was ours to move: the plugin's own optional recovery token.

- .claude-plugin/plugin.json now declares `oauth_token` as a `userConfig`
  option with `sensitive: true`, validated with a real `claude plugin
  validate .` run.
- pipeline/haiku.py's _configured_oauth_token() now prefers
  CLAUDE_PLUGIN_OPTION_OAUTH_TOKEN (the env var Claude Code exports to a
  hook subprocess for that option, per the plugin manifest reference) over
  the legacy REMEMBER_OAUTH_TOKEN env var and haiku.oauth_token config key.
  Both legacy paths keep working -- no existing install loses its recovery
  token silently -- but now log a loud `DEPRECATED:` line every time either
  is actually used.
- scripts/doctor.sh surfaces that DEPRECATED line instead of leaving it
  buried in a daily log nobody reads.
- README.md's credentials disclosure documents the userConfig route and the
  migration story; Codex (no userConfig mechanism) is unaffected.
- docs/releasing.md records what moved, what could not move and why, and
  keeps #869's original argument as the record of what was tried first.

Red tests first (tests/test_haiku.py, tests/test_doctor_deprecated_oauth_860_notice.py):
new assertions failed against the pre-fix code, then passed after the
precedence/deprecation logic and the doctor section were added. 225 targeted
tests pass; CI is the full-matrix gate.

Co-Authored-By: Max <noreply>
…og ambiguity, update docs/configuration.md

Self-review findings from the Explore and oss:auditor reviewers against 3bf65d1:

- pipeline/haiku.py's _configured_oauth_token() was called twice per save on
  the legacy-token path (once by _other_credential() just checking existence,
  once by _inject_configured_oauth_token() actually injecting the token), so
  one save logged the DEPRECATED line twice. Added a warn=False probe mode for
  the existence-only caller; the only caller that actually uses the token
  keeps the default and is the only one that logs.
- scripts/doctor.sh's new "Deprecated recovery-token config" section printed
  the identical "OK" line for "no daily log exists yet" and "logs exist and
  were genuinely scanned, clean" -- the sibling SessionStart-duration section
  three blocks above already keeps those two states apart; this section now
  does too.
- docs/configuration.md's haiku.oauth_token and REMEMBER_OAUTH_TOKEN rows
  were left describing the pre-#860 behavior as current; both now say they
  are deprecated on Claude Code (unchanged on Codex) and point at the
  userConfig option.

A third finding (the DEPRECATED message's remedy text is Claude-Code-specific
and misleading for a Codex host falling back to claude -p with a legacy
token configured) is logged to trap.d/860.codex-fallback-deprecation-wording.md
rather than fixed here: non-blocking, and a clean fix needs host detection
threaded into the warning path, which is more than this diff's blast radius.

Red tests first for both fixed findings (duplicate-log test, no-log-vs-clean
distinguishing test); both failed against the pre-fix code and pass now.
179 targeted tests pass; CI is the full-matrix gate.

Co-Authored-By: Max <noreply>
…ht (round 2)

Maintainer decision (2026-10-03 10:55 CEST): deprecating-while-still-reading
(#860 round 1, commit 3bf65d1/432d078) is still "reads a credential from the
user's machine" -- compliance has to be genuine, never a workaround that
merely hides names from the directory's scanner (no obfuscation, no
string-splitting). Evidence gathered from the v0.38.0 release tree
(e3cfd5b): scripts/session-start-hook.sh had no literal token read at all
(only a comment mentioning "credentials"), .claude-plugin/plugin.json had
no credential text either, and pipeline/haiku.py -- far more literal
credential references than either -- was not flagged at all. The scanner
reads what the TEXT says the plugin does with credentials, not the code
paths themselves.

- pipeline/haiku.py: `_configured_oauth_token()` now has exactly one
  source, the plugin's userConfig `oauth_token` option
  (CLAUDE_PLUGIN_OPTION_OAUTH_TOKEN). REMEMBER_OAUTH_TOKEN and
  haiku.oauth_token are read nowhere for authentication any more, on any
  host. A new `_legacy_oauth_config_present()` checks PRESENCE ONLY (never
  the value) and `_inject_configured_oauth_token()` -- the single call site
  that actually uses a token -- logs a `NOTICE:` line once per save naming
  the still-configured legacy source, never its content.
- `_other_credential()`'s own CLAUDE_CODE_OAUTH_TOKEN presence check (for
  the unrelated ANTHROPIC_API_KEY auto-strip decision, #703) is unchanged:
  it is a presence check, not a credential read, and removing it would
  silently strip the operator's only working credential whenever an
  inert legacy value made it look like a backup existed.
- scripts/doctor.sh's section renamed/reworded (DEPRECATED: -> NOTICE:) to
  match; scripts/session-start-hook.sh's one flagged comment (~L2487,
  "audit credentials and network") reworded without that word.
- README.md's credentials section rewritten in plain language per the
  maintainer's own suggested wording -- no environment-variable recipes,
  no literal CLAUDE_CODE_OAUTH_TOKEN naming (tests/test_readme_discloses_854.py's
  required-name list updated with a comment recording why #854's disclosure
  rule is superseded for that one name).
- docs/configuration.md, docs/verification.md, config.example.json,
  docs/releasing.md updated from "deprecated" to "removed" framing
  throughout, including a full rewrite of docs/verification.md's manual
  procedure for the new userConfig-only mechanism.
- Grep sweep for token|credential|api_key|oauth (case-insensitive) across
  shipped file types: 51 files, 542 lines: reported in docs/releasing.md.

Red tests first for every behavioral change (negative assertions paired
with positive controls: userConfig still authenticates, legacy sources no
longer do; legacy presence logs a value-free notice once per save, empty
legacy config logs nothing). 275 targeted tests pass; CI is the
full-matrix gate. origin/main had not moved at the time of this commit
(still f6d953b) -- no rebase was needed.

Co-Authored-By: Max <noreply>
…ims, stale remedy strings

Self-review findings from the Explore and oss:auditor reviewers against e97553c:

- pipeline/haiku.py:460-471's own comment still described REMEMBER_OAUTH_TOKEN/
  haiku.oauth_token as the live fallback mechanism, 150 lines above the function
  that no longer reads either. Reworded to point at _configured_oauth_token()
  instead of re-describing behavior that changed.
- README.md, docs/configuration.md and docs/releasing.md all claimed Codex "keeps
  using REMEMBER_OAUTH_TOKEN/haiku.oauth_token unchanged" -- false: the recovery
  -token code has never branched by host, so Codex's one path that ever used
  those vars (REMEMBER_SUMMARIZER_FALLBACK=claude, falling through to the shared
  claude -p code) no longer authenticates via them either, same as Claude Code.
  Codex's native codex exec route never read them at all. All three docs
  corrected; the maintainer's own round-2 instruction ("Codex: no recovery-token
  path any more... document that plainly") is what round 2's code already did --
  only the prose was wrong. New red-then-green tests in
  tests/test_summarizer_routing_460.py close the gap a reviewer found (zero
  "codex" references in the token-precedence test file): a legacy token does
  NOT authenticate the Codex-fallback claude -p call; a userConfig token does
  (positive control).
- Two stale "set REMEMBER_OAUTH_TOKEN" remedy strings (pipeline/haiku.py's
  #870 isolation-retry warning, scripts/doctor.sh's expired-login hint) told
  operators to use a mechanism round 2 just turned off. Both reworded to point
  at the userConfig option; both pinning tests (#870) updated to the new marker.
- trap.d/860.codex-fallback-deprecation-wording.md (round 1) had a premise round
  2 made false ("REMEMBER_OAUTH_TOKEN itself keeps working on this path") --
  appended an addendum rather than rewriting, since the file is meant as a
  historical trace for /oss:curate.
- A new non-blocking finding (several shell scripts outside this diff's scope
  still describe haiku.oauth_token as "a live credential, rotate if leaked")
  logged to trap.d/860.stale-live-credential-wording-outside-diff.md rather than
  fixed here -- five files across three subsystems, wording-only, out of blast
  radius.

292 targeted tests pass; CI is the full-matrix gate.

Co-Authored-By: Max <noreply>
…ing (CodeQL HIGH)

CodeQL flagged a HIGH "Clear-text logging of sensitive information" alert on
PR #894 at pipeline/haiku.py:497 (_warn's print to stderr), with two taint
source nodes labeled "sensitive data (password)". The flow: _accept_token()
built its malformed-value warning with `detail = f"{len(value.strip())}
chars"` -- a value DERIVED from the configured secret (the userConfig
oauth_token, or previously the now-removed REMEMBER_OAUTH_TOKEN/
haiku.oauth_token). CodeQL's taint tracker correctly follows that derivation
to the log sink: a length is still information about the secret, even
though the secret's own bytes never appear.

Fix: _accept_token()'s warning message no longer references `value` in any
form -- not the value, not its length, not its type name. It is built
entirely from constants and the `source` parameter (a label string the
caller passes, never derived from the configured value). This breaks the
taint flow at its root rather than suppressing the alert: no lgtm/codeql
ignore comments, no cosmetic renaming.

Updated: docs/verification.md's example log output and surrounding
checklist (the "9 chars" example was the exact shape CodeQL flagged).

Red test first (tests/test_haiku.py::test_malformed_userconfig_token_warning_never_logs_the_value):
asserts the logged line never contains the configured value, with a
positive control that it still names the setting. Confirmed failing against
the pre-fix code (logged "...got 9 chars)"), passing after the fix. 183
targeted tests pass; CI is the full-matrix gate. origin/main had not moved
(still f6d953b) -- no rebase needed; #895 had not merged either.

Co-Authored-By: Max <noreply>
PR #894 (@53e63ab) was still red on the same CodeQL alert
(py/clear-text-logging-sensitive-data, haiku.py:497) after round 1's fix
removed the value-derived length. The maintainer pulled the SARIF
codeFlows: both remaining sources are NAME-based, not value-based --
CodeQL's heuristic treats the return of any function whose name contains
"oauth", or any constant/parameter whose identifier contains "TOKEN", as a
sensitive source once it reaches a log sink, regardless of what the value
actually is.

Flow A: `_legacy_oauth_config_present()` returned a string naming which
legacy setting was configured (e.g. "REMEMBER_OAUTH_TOKEN"), interpolated
into the NOTICE message -- flagged because the FUNCTION'S OWN NAME
contains "oauth". Fixed by splitting it into two functions,
`_legacy_env_var_present()` / `_legacy_config_key_present()`, that return
plain booleans; the caller (`_inject_configured_oauth_token()`) now picks
between two complete, hand-written literal messages, each naming the
setting as fixed text rather than interpolating anything returned.

Flow B: `_accept_token(value, source)` interpolated its `source` parameter
into the warning -- flagged because the caller passed the module constant
`USER_CONFIG_OAUTH_TOKEN_ENV`, whose own identifier contains "TOKEN".
Fixed by dropping the `source` parameter entirely (there is only one
caller) and hardcoding the warning as a literal naming "the plugin's
userConfig oauth_token option" by hand.

Neither fix suppresses the alert or renames an identifier while still
interpolating it (both explicitly ruled out) -- each message is now a
complete literal string with zero identifiers flowing into it at all, so
there is nothing left for CodeQL's name-based heuristic to key on.

Also rebased onto origin/main (#895 merged meanwhile): changelog.d/860's
pre-#860 upstream text had independently been reworded "evaluated" ->
"considered" by #886 to clear an unrelated eval/curl/wget changelog scan;
resolved by keeping this branch's own full rewrite of that fragment, which
already superseded the conflicting lines in a later commit either way.

Existing tests updated to the new literal wording (no new identifiers to
assert against, since the whole point is that nothing is interpolated).
219 targeted tests pass; CI is the full-matrix gate.

Co-Authored-By: Max <noreply>
@fdaviddpt
fdaviddpt merged commit e0cbc3c into main Oct 3, 2026
16 checks passed
@fdaviddpt
fdaviddpt deleted the fix/860 branch October 3, 2026 10:07
fdaviddpt added a commit that referenced this pull request Oct 3, 2026
…r names (#896)

The directory scan's "reads a credential from the user's machine" finding
keys on shipped TEXT, not just code. #894 already stopped reading
REMEMBER_OAUTH_TOKEN/haiku.oauth_token for authentication; this rewords the
prose that still names REMEMBER_OAUTH_TOKEN, ANTHROPIC_API_KEY and
CODEX_API_KEY in README.md, config.example.json and two changelog
fragments (870.fixed.md, 860.changed.md) into plain language, keeping the
same disclosure substance without the literal identifiers. Updates
test_readme_discloses_854.py's required-names list to match, following
the #860 precedent already set there for CLAUDE_CODE_OAUTH_TOKEN.

No code logic changes.

Co-authored-by: Claude Sonnet 5 <[email protected]>
fdaviddpt added a commit that referenced this pull request Oct 3, 2026
Two new findings from round 2 of the v0.39.0 gate-3 audit (dispatch token
rel39-1791028178-23675-r2): haiku.py's auth-failure warning misattributes
which credential actually died (#870/#894 composition), and README.md's
cache-file disclosure still names the pre-v2 filename (#873/#875
composition). Both rank `misreports` -- non-blocking.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
fdaviddpt added a commit that referenced this pull request Oct 3, 2026
* docs(trap.d): log round-1 release-audit findings for v0.39.0

Non-blocking findings from the v0.39.0 gate-3 audit (dispatch token
rel39-1791025656-14116): doctor.sh's NOTICE grep reads log history rather
than current presence (#894), two docs sweeps that missed stale
REMEMBER_OAUTH_TOKEN advice (#894), and a README line overstating the
new recovery token's isolation from nested claude -p sessions (#896).
All rank `misreports` -- non-blocking per skills/manager/phases/findings.md.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* docs(trap.d): log round-2 release-audit findings for v0.39.0

Two new findings from round 2 of the v0.39.0 gate-3 audit (dispatch token
rel39-1791028178-23675-r2): haiku.py's auth-failure warning misattributes
which credential actually died (#870/#894 composition), and README.md's
cache-file disclosure still names the pre-v2 filename (#873/#875
composition). Both rank `misreports` -- non-blocking.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
fdaviddpt added a commit that referenced this pull request Oct 6, 2026
…ed, 4 filed as 3 tracking issues) (#921)

Promoted: the two #898 bash-subprocess-test pitfalls (Git Bash reglobs its own
argv on Windows; a one-line/block extraction regex must try the specific form
first) into one new paths rule, bash-subprocess-test-pitfalls.md.

Declined, already fixed by later rounds of #860/#898: the Codex-fallback
deprecation wording, the auth-failure misattribution, the doctor.sh legacy-token
NOTICE section, the README token-isolation overstatement, the lib-lock.sh eval
widening, and the legacy-token read-error swallow -- all moot now that the
userConfig recovery-token mechanism was removed entirely.

Declined, still true, filed as tracking issues: #918 (stale haiku.oauth_token /
REMEMBER_OAUTH_TOKEN wording across hooks.d, lib-memory-dir.sh, log.sh and two
docs pages), #919 (_check_url_in_comment has no heredoc-boundary tracking), #920
(the #902 REMEMBER_DIR guard's three gaps -- bootstrap-dirs.sh bypass, swallowed
FATAL, UNC paths wrongly refused). The README cache-filename fragment cites the
existing #888 instead of a duplicate.

Part of #860, #870, #875, #891, #894, #896, #898, #902

Co-authored-by: Claude Sonnet 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Take the optional OAuth token through plugin.json userConfig (sensitive) to clear the directory's MCP_FORWARDS_CREDENTIAL_ENV warning

1 participant