Skip to content

Avoid PowerShell command interpolation by using environment variables (hardening)#291

Merged
zooba merged 1 commit intopython:mainfrom
l3tchupkt:fix/powershell-env-hardening
Mar 26, 2026
Merged

Avoid PowerShell command interpolation by using environment variables (hardening)#291
zooba merged 1 commit intopython:mainfrom
l3tchupkt:fix/powershell-env-hardening

Conversation

@l3tchupkt
Copy link
Copy Markdown
Contributor

This change removes direct string interpolation in the PowerShell fallback downloader
and replaces it with environment variable-based parameter passing.

  • URL, method, headers, and output path are passed via environment variables
  • Headers are serialized as JSON and reconstructed using ConvertFrom-Json
  • Eliminates potential command injection risks from untrusted input
  • Simplifies script construction and improves safety

This follows recommended practice for avoiding command construction vulnerabilities.

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot bot commented Mar 26, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@l3tchupkt l3tchupkt force-pushed the fix/powershell-env-hardening branch from 1c574f6 to fdc6660 Compare March 26, 2026 20:07
@zooba
Copy link
Copy Markdown
Member

zooba commented Mar 26, 2026

Looks great, nice work.

@zooba zooba merged commit 4a8e8b2 into python:main Mar 26, 2026
1 check passed
@l3tchupkt
Copy link
Copy Markdown
Contributor Author

@zooba Thank you, I appreciate the review and the quick merge.

Glad this approach aligns with the intended direction for improving safety in that part of the code. It was a great learning experience working through the implementation and discussion.

Please let me know if there are any further improvements or related areas where I can contribute.

@zooba
Copy link
Copy Markdown
Member

zooba commented Mar 27, 2026

Please let me know if there are any further improvements or related areas where I can contribute.

Not so much in this part of the project, I hope (we're mostly in careful bug fixing mode now, to minimise disruption to our users), but have a look through https://github.com/python/cpython for issues that interest you.

@l3tchupkt
Copy link
Copy Markdown
Contributor Author

l3tchupkt commented Mar 27, 2026 via email

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.

2 participants