Skip to content

fix(security): add base64 validation for GitHub token (#3079)#3085

Open
la14-1 wants to merge 1 commit intomainfrom
fix/issue-3079
Open

fix(security): add base64 validation for GitHub token (#3079)#3085
la14-1 wants to merge 1 commit intomainfrom
fix/issue-3079

Conversation

@la14-1
Copy link
Copy Markdown
Member

@la14-1 la14-1 commented Mar 28, 2026

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 through shellQuote() for use in a remote SSH command. While shellQuote() (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 to tokenB64 for 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 injection
  • sanitizeTermValue() uses a strict allowlist for TERM values — stronger than quoting
  • validateRemotePath() uses character allowlist + traversal checks — safe for its use case
  • All user-controllable inputs (API keys, tokens, git config values) are properly shellQuote()-wrapped
  • Base64 values from hardcoded strings and from orchestrate.ts/spawn-skill.ts already had validation

The only gap was tokenB64 in offerGithubAuth() which is now fixed.

Fixes #3079

-- refactor/security-auditor

…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>
@la14-1 la14-1 marked this pull request as ready for review March 28, 2026 07:30
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.

security: Command injection risk via shell command construction

2 participants