fix(workspace): redact GitHub tokens in container logs#81
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a security issue where GitHub access tokens could be leaked into host/container logs by ensuring token-bearing clone URLs and Docker command arguments are redacted before being written to logs, strengthening the workspace runner’s operational security.
Changes:
- Redacts URL-embedded credentials when logging the root clone URL for multi-push-target workspace preparation.
- Introduces
redactDockerArgs()to sanitize Docker argv arrays (sensitiveNAME=VALUEenvs, URL credentials, and token-shaped values) before debug logging. - Adds unit tests to ensure redaction removes GitHub token formats across common leak patterns.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/workspace/workspaceRunner.ts |
Applies redaction to clone URL and Docker argv debug logs for agent/review containers to prevent token leakage. |
src/utils/redactUrl.ts |
Adds redactDockerArgs() and supporting patterns for masking sensitive env assignments and token-like values. |
tests/unit/redactUrl.test.ts |
Adds unit coverage validating URL and Docker-argv redaction against multiple token leak scenarios. |
There was a problem hiding this comment.
✅ Ready to approve
It removes the identified credential leaks by redacting logged URLs/Docker args and adds targeted tests to prevent regressions.
Note: this review does not count toward required approvals for merging.
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 0 new
- Review effort level: Low
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
Redact authenticated clone URLs, Docker environment arguments, and clone errors before they reach logs or callers. Avoid over-redacting benign environment names and cover both workspace and VCS clone paths.
f6461da to
e91702c
Compare
Summary
Fixes Redmine #22792. GitHub access tokens were written to the orchestrator logs in plaintext, so anyone with read access to
docker logs ve-orchestrator(or host journald/log files) could recover live GitHub credentials (OWASP A09:2021 — Security Logging Failures).Leak locations (both in
src/workspace/workspaceRunner.ts)rootCloneUrl: root.cloneUrl, which containshttps://x-access-token:gho_...@github.com/....GITHUB_TOKENenv var — the "agent container command" (and "review container command") debug log dumped the fulldockerArgsarray, including-e GITHUB_TOKEN=ghu_...in cleartext.Fix
redactUrlshelper for therootCloneUrlfield.redactDockerArgshelper (src/utils/redactUrl.ts) that masks the value of any sensitiveNAME=VALUEargument (*TOKEN*,*SECRET*,*PASSWORD*,*AUTH*, etc.), strips URL-embedded credentials, and masks stray GitHub token-shaped values. Applied to both the agent and review container command debug logs.Tests
tests/unit/redactUrl.test.ts— 5 new tests asserting tokens never survive redaction (clone URLs, sensitive env assignments, URL-bearing args, stray token-shaped values).Operational note
Tokens already captured in existing logs should be rotated independently of this code fix.
Validation
npm run typecheck— zero errorsnpm run lint— cleannpx vitest run tests/unit/redactUrl.test.ts— 5 passed