Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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. However, we were unable to automatically add the dependency to your project.
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. You may need to manually add this dependency to the proper location in your project.Manual Installation
For
setup.py
:install_requires=[ + "security==1.3.1", ],
For
pyproject.toml
(usingsetuptools
):[project] dependencies = [ + "security==1.3.1", ]
For
setup.cfg
:[options] install_requires = + security==1.3.1
For
requirements.txt
:+security==1.3.1
For more information on adding dependencies to
setuptools
projects, see the setuptools documentation.If you are using another build system, please refer to the documentation for that system to determine how to add dependencies.
More reading
🧚🤖 Powered by Pixeebot
Feedback | Community | Docs | Codemod ID: pixee:python/sandbox-process-creation