Repository navigation
parser: reject shell metacharacters in extractor-plugin file path - #1202
Merged
Merged
Conversation
extractor_plugin.go exports the repo-controlled file path into the child plugin environment as GORTEX_FILE_PATH=<path>. The existing guard rejects control characters but leaves shell metacharacters, so a plugin that expands $GORTEX_FILE_PATH through a shell can be driven by a filename containing ; $ backticks | & ( ) < > quotes = or space — to inject commands, expand variables, splice env vars, or word-split the path. Reject shell metacharacters (shared shellUnsafePathChars set) in addition to control characters before exporting. The plugin command/args remain operator-declared config; only the repo-relative path is hardened.
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
internal/parser/languages/extractor_plugin.goexports the repo-controlled file path into the child plugin environment asGORTEX_FILE_PATH=<path>.The existing guard rejects control characters (
\x00\n\r\t\v\f) but leaves shell metacharacters untouched. A plugin that expands$GORTEX_FILE_PATHthrough a shell can then be driven by a filename containing;,$,backticks,
|,&,(,),<,>, quotes,=, or a space — to inject commands, expand variables, splice env vars, or word-split the path. Repo file names are attacker-influenced whenever they commit such a name.Fix
Reject shell metacharacters in addition to control characters before the path is exported, via a shared
shellUnsafePathCharsset. The command and args remain operator-declared config; only the repo-relative path is now hardened.Test
Existing extractor-plugin tests in the package pass unchanged.