Skip to content

fix(workspace): redact GitHub tokens in container logs#81

Merged
fshehadeh-sfl merged 1 commit into
mainfrom
fix/redact-github-tokens-in-logs
Jul 22, 2026
Merged

fix(workspace): redact GitHub tokens in container logs#81
fshehadeh-sfl merged 1 commit into
mainfrom
fix/redact-github-tokens-in-logs

Conversation

@fshehadeh-sfl

Copy link
Copy Markdown
Collaborator

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)

  1. Clone URL with embedded token — the "preparing project workspace (multi push target via volume)" log logged rootCloneUrl: root.cloneUrl, which contains https://x-access-token:gho_...@github.com/....
  2. GITHUB_TOKEN env var — the "agent container command" (and "review container command") debug log dumped the full dockerArgs array, including -e GITHUB_TOKEN=ghu_... in cleartext.

Fix

  • Reuse the existing redactUrls helper for the rootCloneUrl field.
  • Add a redactDockerArgs helper (src/utils/redactUrl.ts) that masks the value of any sensitive NAME=VALUE argument (*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 errors
  • npm run lint — clean
  • npx vitest run tests/unit/redactUrl.test.ts — 5 passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (sensitive NAME=VALUE envs, 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.

Comment thread src/utils/redactUrl.ts Outdated
Copilot AI review requested due to automatic review settings July 22, 2026 18:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.
@fshehadeh-sfl
fshehadeh-sfl force-pushed the fix/redact-github-tokens-in-logs branch from f6461da to e91702c Compare July 22, 2026 19:23
@fshehadeh-sfl
fshehadeh-sfl merged commit 662c339 into main Jul 22, 2026
3 checks passed
@fshehadeh-sfl
fshehadeh-sfl deleted the fix/redact-github-tokens-in-logs branch July 22, 2026 19:25
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