fix(security): add base64 validation for GitHub token (#3079)#3085
Open
fix(security): add base64 validation for GitHub token (#3079)#3085
Conversation
…terpolation The base64-encoded GitHub token in offerGithubAuth() was passed to shellQuote() without the same base64 character validation applied to other base64 values elsewhere in the file (wrapperB64, unitB64, timerB64). While shellQuote() already provides adequate protection, this adds the same defense-in-depth guard for consistency. Fixes #3079 Agent: security-auditor Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: Defense-in-depth gap — the base64-encoded GitHub token was the only base64 value in agent-setup.ts not validated before shell interpolation.
Summary
offerGithubAuth()base64-encodes the GitHub token and passes it throughshellQuote()for use in a remote SSH command. WhileshellQuote()(POSIX single-quote escaping + null byte rejection) already provides adequate protection, every other base64 value in the same file (wrapperB64,unitB64,timerB64) includes an explicit/^[A-Za-z0-9+/=]+$/validation guard before use. This PR adds the same guard totokenB64for consistency.Assessment of the broader issue
After auditing all code paths mentioned in #3079:
shellQuote()uses correct POSIX single-quote escaping ('\''technique) with null byte rejection — robust against injectionsanitizeTermValue()uses a strict allowlist for TERM values — stronger than quotingvalidateRemotePath()uses character allowlist + traversal checks — safe for its use caseshellQuote()-wrappedorchestrate.ts/spawn-skill.tsalready had validationThe only gap was
tokenB64inofferGithubAuth()which is now fixed.Fixes #3079
-- refactor/security-auditor