Closed pixeebot[bot] closed 1 week ago
I'm confident in this change, but I'm not a maintainer of this project. Do you see any reason not to merge it?
If this change was not helpful, or you have suggestions for improvements, please let me know!
Just a friendly ping to remind you about this change. If there are concerns about it, we'd love to hear about them!
This change may not be a priority right now, so I'll close it. If there was something I could have done better, please let me know!
You can also customize me to make sure I'm working with you in the way you want.
This codemod sandboxes all instances of subprocess.run and subprocess.call to offer protection against attack.
Left unchecked,
subprocess.run
andsubprocess.call
can execute any arbitrary system command. If an attacker can control part of the strings used as program paths or arguments, they could execute arbitrary programs, install malware, and anything else they could do if they had a shell open on the application host.Our change introduces a sandbox which protects the application:
The default
safe_command
restrictions applied are the following:safe_command
functions attempt to parse the given command, and throw aSecurityException
if multiple commands are present./etc/passwd
, so the sandbox prevents arguments that point to these files that may be targets for exfiltration.There are more options for sandboxing if you are interested in locking down system commands even more.
Dependency Updates
This codemod relies on an external dependency. We have automatically added this dependency to your project's
requirements.txt
file.This library holds security tools for protecting Python API calls.
There are a number of places where Python project dependencies can be expressed, including
setup.py
,pyproject.toml
,setup.cfg
, andrequirements.txt
files. If this change is incorrect, or if you are using another packaging system such aspoetry
, it may be necessary for you to manually add the dependency to the proper location in your project.More reading
* [https://github.com/pixee/python-security/blob/main/src/security/safe_command/api.py](https://github.com/pixee/python-security/blob/main/src/security/safe_command/api.py) * [https://cheatsheetseries.owasp.org/cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.html](https://cheatsheetseries.owasp.org/cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.html)I have additional improvements ready for this repo! If you want to see them, leave the comment:
... and I will open a new PR right away!
🧚🤖 Powered by Pixeebot
Feedback | Community | Docs | Codemod ID: pixee:python/sandbox-process-creation