fix(vault): validate credential input safely - #294
Conversation
Co-authored-by: Yigtwxx <yigiterdogan023@gmail.com>
|
Exact-head maintainer proof for Redaction behaviorCurrent main reproduced the leak with fake credential input: V8's The built exact-head CLI received the same distinctive fake marker and emitted only: The complete marker, its partial prefix, parser reason, source contents, Expiry boundary and compatibility
Commands and results
Exact-head CI run 31281799202 passed on macOS, Ubuntu, and Windows. GitHub reports CLEAN/MERGEABLE. Contributor credit: the parsing wrapper and expiry-field analysis are materially adapted from @Yigtwxx's superseded PR #287; the commit carries |
|
Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 6:33 PM ET / 22:33 UTC. ClawSweeper reviewWhat this changesThe PR converts malformed vault JSON into source-specific safe errors and rejects non-finite Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessKeep this PR open for normal maintainer merge review. The patch narrowly prevents credential fragments from reaching parser diagnostics and aligns write-time expiry validation with the existing vault read guard; no actionable patch defect was found. Priority: P2 Review scores
Verification
How this fits togetherThe vault command accepts OAuth tokens and client metadata from stdin or a file, validates them, and stores them for later OAuth use. Input errors reach terminal or CI logs, while stored token expiry fields are consumed by vault and refresh paths. flowchart LR
A[Vault input file or stdin] --> B[JSON parsing]
B --> C[Payload validation]
C --> D[Credential vault storage]
D --> E[OAuth refresh and runtime]
B --> F[Safe usage error]
Before merge
Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Merge the focused parser-redaction and expiry-boundary repair while retaining the existing permissive handling of valid OAuth metadata. Do we have a high-confidence way to reproduce the issue? Yes—current main has a direct source-reproducible path: malformed vault JSON reaches raw Is this the best way to solve the issue? Yes—the patch fixes both defects at the vault input boundary, preserves accepted finite values and metadata, and adds direct and built-CLI regressions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 607ec3e342ac. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Summary
This is the bounded follow-up preserved when contributor PR #287 was superseded by the narrower DCR compatibility fix in #288.
vault setJSON into source-specific usage errors that never include V8 parser text or credential-input prefixes.tokens.expires_atandtokens.expiresAtas finite numbers at the same input boundary that already validatesexpires_in.No client-information policy, token persistence format, refresh behavior, or token schema is redesigned here.
Behavior
Malformed stdin now reports only:
Malformed files report only the file path:
The original parser reason is deliberately discarded because V8 may quote a prefix of credential input in the diagnostic.
Expiry validation mirrors the existing
isStoredOAuthTokensread guard exactly.expires_in,expires_at, andexpiresAtaccept any finite number, including zero, negative values, and fractions. Strings, null/serialized NaN, and numeric overflow to positive or negative infinity reject. If both aliases are present and finite, both remain accepted; this PR does not invent conflict or timestamp policy.Unknown token fields, valid DCR client information, null-compatible client fields, and provider metadata still pass through unchanged.
Provenance
The parsing wrapper and expiry-field analysis are materially adapted from @Yigtwxx's commits in #287, especially
df2956fdfb6ad9a645c706393398a5efdcd30805and2733f0c98895e781db609243e294792bae321f0a. Contributor credit is preserved in the commit trailer and changelog.PR #288 intentionally did not carry these adjacent findings because it retained partial-object and null-compatible client information semantics while resolving issue #286. This PR is the separate follow-up promised in the #287 close comment.
Proof
Exact head:
38168dc5b48281d44fdec0e790be69601b82b8fb.Built CLI redaction proof with a distinctive fake marker:
The marker, its prefix,
SyntaxError, parser reason, and source contents were absent. The built CLI also rejected1e999as non-finite and persisted bothexpires_at: 0and fractionalexpiresAt, alongside unrelated fake token/client metadata.pnpm docs:list— passedpnpm check— passedpnpm test— 187 files passed, 4 skipped; 1,438 tests passed, 26 skippedpnpm docs:site— passedgit diff --check— passedNo live provider proof is required: the changed boundary is local JSON parsing, validation, and persistence using fake credentials only.