Skip to content

fix(transport): redact tokens from RPC debug logs; 1.0.2 - #22

Merged
gavin09527 merged 1 commit into
mainfrom
fix/redact-tokens-from-rpc-logs
Jul 29, 2026
Merged

fix(transport): redact tokens from RPC debug logs; 1.0.2#22
gavin09527 merged 1 commit into
mainfrom
fix/redact-tokens-from-rpc-logs

Conversation

@gavin09527

Copy link
Copy Markdown
Collaborator

Summary

  • token.js's _corePost() and http.js's _logRpcRequest/_logRpcResponse log full request/response bodies to stdout by default (COCO_RPC_LOG defaults ON). On the auth endpoints the body IS the access_token/refresh_token pair, so this put live credentials in plaintext into any consumer's process logs.
  • Bodies now pass through a new redactSecrets() helper (src/transport/redact.js) before logging — replaces known-sensitive field names with [REDACTED]; log structure/status/*_expires_at timestamps are unchanged, and the logging toggle itself is untouched.
  • Found while auditing the identical pattern in zylos-openmax (companion fix: fix(security): redact tokens from RPC logs + harden sensitive file perms to 0600/0700 zylos-ai/zylos-openmax#100) after another team reported it leaking tokens into their PM2 logs. This SDK doesn't persist tokens to disk itself, so the log leak is the only instance of this bug here (no file-permission fix needed in this repo).
  • Version bump 1.0.1 → 1.0.2 per RELEASING.md (patch = fix), package.json + src/index.js SDK_VERSION + package-lock.json all updated together.

Test plan

  • npm test — 316/316 pass, including the SDK_VERSION drift guard (src/version.test.js) and 7 new cases in src/transport/redact.test.js (incl. false-positive guards for *_expires_at and fields that merely contain "token"/"secret" as a substring).
  • CI required checks (test (node 20), test (node 22), semgrep, gitleaks) — pending on this PR.
  • Note: npm install surfaced a pre-existing unrelated fast-uri high-severity advisory (transitive, via ajv) — confirmed via git diff package-lock.json that this run didn't touch that dependency, so it predates this change and is out of scope here; flagging separately rather than bundling an unrelated dependency bump into a security-log fix.

Per RELEASING.md this needs an approval from someone other than the pusher (org branch ruleset) before merge, then a manual tag + release-environment approval to publish.

🤖 Generated with Claude Code

token.js's _corePost() and http.js's _logRpcRequest/_logRpcResponse log
full request/response bodies to stdout by default (COCO_RPC_LOG defaults
ON). On the auth endpoints (/auth/agent/token, /auth/refresh,
/auth/ws-ticket) the body IS the access_token/refresh_token pair, so this
put live credentials in plaintext into any consumer's process logs.

Bodies are now passed through a new redactSecrets() helper
(src/transport/redact.js) before logging — replaces known-sensitive
field names (access_token, refresh_token, id_token, api_key,
client_secret, password, secret, ticket) with [REDACTED]. Log
structure/status/non-sensitive fields (incl. *_expires_at timestamps,
useful for debugging expiry) are unchanged; the logging toggle itself
is untouched.

Found while auditing the identical pattern in zylos-openmax (which
vendors this same corePost/RPC-logging shape) after another team
reported it leaking tokens into their PM2 logs. This SDK doesn't persist
tokens to disk itself (that's left to each consumer), so the log leak
is the only instance of this bug here.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

2 participants