Skip to content

fix: pass user inputs via env vars to prevent shell/code injection#1

Open
nbuckwalt wants to merge 1 commit intomainfrom
fix/cmd-exec-input-sanitization
Open

fix: pass user inputs via env vars to prevent shell/code injection#1
nbuckwalt wants to merge 1 commit intomainfrom
fix/cmd-exec-input-sanitization

Conversation

@nbuckwalt
Copy link
Copy Markdown

Summary

All user-controlled inputs (extras, package-dir, output-dir, config-file, only) were previously interpolated directly into run: directives via ${{ inputs.* }} expressions, enabling command injection.

Vulnerabilities fixed

inputs.extras — arbitrary code execution (critical)
Interpolated as a string literal inside a Python heredoc. An attacker controlling this input can escape the string and execute arbitrary Python/system commands.

inputs.package-dir, inputs.output-dir, inputs.config-file, inputs.only — argument/shell injection
Interpolated directly into shell run: steps. A " in any value breaks out of the quoting applied by format(), enabling flag injection into the cibuildwheel invocation.

Fix

Route all inputs through environment variables. The shell reads them via $VAR / $env:VAR, which is immune to injection regardless of content. Array-based command construction (cmd=()) is used on bash; equivalent on PowerShell.

Notes

  • Behavior is identical for all valid inputs
  • inputs.extras now read from $CIBW_EXTRAS_INPUT env var in the Python heredoc via os.environ.get()
  • Windows (PowerShell) step updated with the same env-var pattern

Reported by Contrast Security labs-action-scanner.

All user-controlled inputs (extras, package-dir, output-dir, config-file,
only) were previously interpolated directly into run: directives via
${{ inputs.* }} expressions. This allows command injection:

- inputs.extras was interpolated into a Python heredoc as a string literal,
  enabling arbitrary Python/system code execution via string escape.
- inputs.package-dir, output-dir, config-file, and only were interpolated
  directly into shell commands; a double-quote in the value breaks out of
  the quoting applied by format().

Fix: route all inputs through environment variables. GitHub Actions resolves
env: values safely and the shell reads them via $VAR / $env:VAR, which
is not subject to word splitting or injection regardless of content.

Reported by Contrast Security labs-action-scanner.
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