Repository navigation
fix(security): send GITHUB_TOKEN only to GitHub's own hosts - #63
Merged
Merged
Conversation
A Feature given as a tarball URL got `Authorization: Bearer $GITHUB_TOKEN` whenever its URL started with "https://github.com" or "https://api.github.com", so github.com.attacker.example, [email protected] and api.github.com.evil all received the token. Anyone who could put a Feature URL in a devcontainer.json, or in a Feature's dependsOn, could collect it. The token now goes only to an https URL with no userinfo whose host is github.com or api.github.com, ignoring case and one trailing dot, on any port. The reference CLI has the same prefix check, so this is a deliberate divergence, recorded in docs/DIVERGENCES.md and pinned by unit tests, including one where a TLS server reached through a userinfo look-alike receives no token. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Problem. A Feature given as a tarball URL got
Authorization: Bearer $GITHUB_TOKENwhenever the URL started withhttps://github.comorhttps://api.github.com. So these all received the token:https://github.com.attacker.example/devcontainer-feature-x.tgzhttps://[email protected]/…(userinfo)https://api.github.com.evil/…Anyone who can put a Feature URL in a
devcontainer.json, or in a Feature'sdependsOn, could collect the token.Fix.
isGitHubTarballURIparses the URL and requireshttps, no userinfo, and a host equal togithub.comorapi.github.com. Case, one trailing dot and any port are allowed: they name the same host, and TLS binds the token to GitHub's certificate. TS normalizes withnew URL(...), which lowercases the host. Before this changehttps://GitHub.com/...got no token in Go but did in TS; now both send it.Divergence. TS v0.90.0
getRequestHeaders(containerFeaturesConfiguration.ts:398-419) has the same prefix check and leaks the token the same way. This is a deliberate, documented divergence (docs/DIVERGENCES.md, "Deliberate divergences"). For real GitHub hosts the output is identical to TS: same header, sameUsing environment GITHUB_TOKEN./No environment GITHUB_TOKEN available.lines.Tests (all fail on
main)TestIsGitHubTarballURI: look-alikes, userinfo, a backslash trick, mixed case, trailing dot,:443,http://, no scheme.TestFeatureRequestHeadersSendTheTokenOnlyToGitHub: header and log lines for real and look-alike hosts, with and without a token.TestDownloadFeatureTarballKeepsTheTokenFromALookAlikeURL: a TLS server reached throughhttps://[email protected]:<port>/…receives no token.No parity case can compare this with TS without leaking a token.
Validation (local)
task lint,task vuln: pass.task test:racewithTMPDIRoutside/tmp: pass.task parity:contract: only the 2read-configuration.features-configuration-local-feature-*cases fail, as onmainon this machine (/tmp/.git).🤖 Generated with Claude Code