fix: reject control characters in PATH_TO_CLAUDE_CODE_EXECUTABLE#1161
Closed
qozle wants to merge 1 commit into
Closed
fix: reject control characters in PATH_TO_CLAUDE_CODE_EXECUTABLE#1161qozle wants to merge 1 commit into
qozle wants to merge 1 commit into
Conversation
An embedded newline in PATH_TO_CLAUDE_CODE_EXECUTABLE would propagate through dirname() and be written to GITHUB_PATH, injecting an attacker- controlled directory into the runner PATH for all subsequent job steps. Add a fail-closed guard that throws if the derived claudeDir contains any control characters (0x00-0x1f, 0x7f). A valid filesystem path should never contain these; rejecting loudly is better than silent sanitization that hides misconfiguration. Fixes anthropics#1160 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
Closing — duplicate of #1185 which was already merged. |
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
PATH_TO_CLAUDE_CODE_EXECUTABLEis passed throughdirname()and written directly to theGITHUB_PATHfile without sanitizing control characters:GITHUB_PATHis newline-delimited — each line becomes a directory added toPATHfor subsequent steps. IfcustomExecutablecontains an embedded newline (e.g. set from an untrusted workflow input),dirname()passes it through andappendFilewrites two lines, injecting an attacker-controlled directory into the runner PATH for all subsequent job steps.Fix
Add a fail-closed guard before the
appendFilecall that throws ifclaudeDircontains any control characters (\x00–\x1f,\x7f):Fail-closed rather than silently stripping: a path with embedded control characters is almost certainly a misconfiguration or injection attempt. Throwing loudly is better than quietly sanitizing and continuing — the latter hides the problem.
All 653 existing tests continue to pass.
Fixes #1160