Skip to content

Builds: obfuscate Git clone token in build command output - #13239

Draft
ericholscher wants to merge 1 commit into
mainfrom
claude/rtd-token-exposure-protection-ycisc6
Draft

Builds: obfuscate Git clone token in build command output#13239
ericholscher wants to merge 1 commit into
mainfrom
claude/rtd-token-exposure-protection-ycisc6

Conversation

@ericholscher

Copy link
Copy Markdown
Member

A user's build output exposed the clone token used for private repositories. The token is passed to the checkout step via the READTHEDOCS_GIT_CLONE_TOKEN environment variable and ends up stored in .git/config as part of the remote URL, so any command that echoes the environment or the remote URL (e.g. git remote -v) writes it into the recorded build output, which is visible on the build page.

This obfuscates the token at the point where command output is saved (BuildCommand.sanitize_output), the same way we already handle private environment variables. Both the full <username>:<secret> value and the bare secret part are replaced, covering the remote-URL form and the env-var form.

Things a reviewer may want to double-check:

  • The token is scoped to a single repository with contents:read and expires after one hour, so the masking is about keeping it out of (potentially public) build logs rather than the only line of defense.
  • Obfuscation is an exact substring replacement, so encoded forms of the token would not be caught — same limitation as the existing private-variable obfuscation.
  • Deeper changes (keeping the token out of .git/config, revoking it after checkout) were intentionally left out since the build process is moving externally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FQsmfAx7JW6ze8rkBqeCP9


Generated by Claude Code

The token used to clone private repositories could show up in the
recorded build output (e.g. a command echoing the remote URL or the
environment). Obfuscate it like we already do for private environment
variables.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FQsmfAx7JW6ze8rkBqeCP9
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