Skip to content

Conversation

0x-Professor
Copy link

Summary: Replace python -m ruff with a direct Ruff binary invocation to avoid local module shadowing (ruff.py/ruff/). Prefer venv Scripts/bin, exclude CWD from PATH, reject .py targets, and sanitize PYTHONPATH.
Impact: Prevents arbitrary code execution on maintainer/CI when running docs formatting.
Repro (pre-fix): Place ruff.py at repo root; run format:docs; malicious file runs and writes PWNED.txt.
Result (post-fix): Malicious ruff.py does not execute; no PWNED.txt; docs format proceeds normally.
Validation: Ruff format/check passed; mypy/pyright passed; manual exploit test on Windows succeeded.
Risk: Low; same Ruff behavior/args with safer invocation and clearer failure if Ruff is missing.
Optional follow-ups

CI scan: I checked .github/workflows for “ruff”/“-m ruff”; none found. If you want, I can re-check and prepare a follow-up if needed.
Tell me your fork URL and I can push the branch for you, or I ca

…n\nUse an absolute Ruff executable (prefer venv Scripts/bin, else PATH without CWD) instead of python -m ruff. Reject .py targets and lightly sanitize PYTHONPATH. This prevents arbitrary code execution via ruff.py/ruff/ shadowing when running the docs formatter.
… absolute Ruff executable resolution on Windows/non-Windows\n- Ignore CWD on PATH and reject .py targets\n- Honor CLI line length via lowercase var to satisfy pyright\n- Format and import-sort file
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