Skip to content

fix(security): pass file paths to R and PowerShell linters as data - #9403

Closed
nvuillam wants to merge 2 commits into
mainfrom
fix/ghsa-c32q-filename-injection
Closed

nvuillam wants to merge 2 commits into
mainfrom
fix/ghsa-c32q-filename-injection

Conversation

@nvuillam

@nvuillam nvuillam commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Improves security of RLinter, PowershellLinter and ArmLinter: they wrote the scanned file path between single quotes inside the script sent to R -e / pwsh -Command, so file names containing quotes or special characters were not handled safely.

  • File and config paths are now passed through MEGALINTER_LINT_* environment variables (new Linter.lint_command_env, merged into the subprocess env) and read with Sys.getenv() / $env: — no path is written in a script anymore, so ASCII and Unicode smart quotes are inert
  • Files whose name contains control characters are skipped by these linters with a warning (Linter.drop_files_unsafe_for_interpreter)
  • powershell_formatter: -LiteralPath for Get-Content / Out-File, output encoding validated
  • Hardening found while auditing the other wrappers:
    • PhpCsFixerLinter: PHP-escapes excluded directory names and the included config path in the generated config
    • RakuLinter: zef install runs without shell=True

Test plan

  • New unit tests interpreter_path_injection_test.py (names with quotes incl. U+2018/U+2019/U+201B/U+2032, config paths, fix mode, env merge, skip, PHP escaping)
  • CI Docker tests: r_lintr, powershell_powershell, powershell_powershell_formatter, arm_arm_ttk, php_php_cs_fixer, raku_raku

…HSA-c32q-gm5x-gjxh)

R_LINTR, POWERSHELL_POWERSHELL, POWERSHELL_POWERSHELL_FORMATTER and
ARM_ARM_TTK wrote the scanned file path between single quotes in the
R / PowerShell script they run, so a quote in a file name ran as
interpreter code. Paths and config files are now passed through
MEGALINTER_LINT_* environment variables read by the script, and files
whose name contains control characters are skipped with a warning.

Hardening: php-cs-fixer generated config escapes directory names and
the included config path; raku zef install no longer goes through a shell.

TEST_KEYWORDS=r_lintr_test or powershell_powershell_test or powershell_powershell_formatter_test or arm_arm_ttk_test or php_php_cs_fixer_test or raku_raku_test or interpreter_path_injection_test
TEST_KEYWORDS=r_lintr_test or powershell_powershell_test or powershell_powershell_formatter_test or arm_arm_ttk_test or php_php_cs_fixer_test or raku_raku_test or interpreter_path_injection_test
@nvuillam nvuillam changed the title fix(security): pass file paths to R and PowerShell linters as data (GHSA-c32q-gm5x-gjxh) fix(security): pass file paths to R and PowerShell linters as data Oct 30, 2026
@nvuillam nvuillam closed this Oct 30, 2026
@nvuillam

Copy link
Copy Markdown
Member Author

Superseded by #9404

@nvuillam
nvuillam deleted the fix/ghsa-c32q-filename-injection branch October 30, 2026 23:46
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