Skip to content

parser: reject shell metacharacters in extractor-plugin file path - #1202

Merged
zzet merged 1 commit into
mainfrom
fix/extractor-plugin-path-env-shell-metachars
Oct 31, 2026
Merged

zzet merged 1 commit into
mainfrom
fix/extractor-plugin-path-env-shell-metachars

Conversation

@zzet

@zzet zzet commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Problem

internal/parser/languages/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 (\x00\n\r\t\v\f) but leaves shell metacharacters untouched. A plugin that expands $GORTEX_FILE_PATH through 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 shellUnsafePathChars set. 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.

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.
@zzet
zzet merged commit 93d15fa into main Oct 31, 2026
25 checks passed
@zzet
zzet deleted the fix/extractor-plugin-path-env-shell-metachars branch October 31, 2026 12:04
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.

1 participant