-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
Docs: Clarify that -I is not a security boundary
#150790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -294,8 +294,11 @@ Miscellaneous options | |
|
|
||
| .. option:: -E | ||
|
|
||
| Ignore all ``PYTHON*`` environment variables, e.g. | ||
| Ignore all ``PYTHON*`` environment variables, for example, | ||
| :envvar:`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set. | ||
| This is useful for running commands that should not take into account the | ||
| user's current environment settings, but does not necessarily mean that the | ||
| current environment will have no effect. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure that this sentence is useful. In the first sentence, the effect of the option is well defined: "Ignore all
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's exactly what the rest of the sentence says, so maybe if we rephrase to put "other environment variables may still be used, such as for locale or terminal options, but those that are used by Python to initialise runtime settings will be ignored and default values used instead." The point of this line is to not just say "this is not a security boundary" without also actually saying what it is. We're better off implying the security aspects and being explicit about the intent, since that's more helpful for everyone. |
||
|
|
||
| See also the :option:`-P` and :option:`-I` (isolated) options. | ||
|
|
||
|
|
@@ -324,8 +327,9 @@ Miscellaneous options | |
|
|
||
| In isolated mode :data:`sys.path` contains neither the script's directory nor | ||
| the user's site-packages directory. All ``PYTHON*`` environment | ||
| variables are ignored, too. Further restrictions may be imposed to prevent | ||
| the user from injecting malicious code. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the REPL, |
||
| variables are ignored, too. This feature is not a security boundary. | ||
| Further restrictions need to be imposed to prevent the user from injecting | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't know the "security boundary" expression. What does it mean? I don't think that security is a all-or-nothing thing, it's more complicated.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security boundary means that if you can bypass it, you've found a vulnerability. If something is not a security boundary, then bypassing it is just a normal bug (or feature). |
||
| malicious code. | ||
|
|
||
| .. versionadded:: 3.4 | ||
|
|
||
|
|
@@ -362,6 +366,8 @@ Miscellaneous options | |
| * ``python -c code`` and ``python`` (REPL) command lines: Don't prepend an | ||
| empty string, which means the current working directory. | ||
|
|
||
| This feature is not a security boundary. Further restrictions need to be | ||
| imposed to prevent the user from injecting malicious code. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that the current -P option documentation implies that it protects you from any malicious code injection. I don't see the value of adding this paragraph. It doesn't explain how to block all entry points for malicious code. |
||
| See also the :envvar:`PYTHONSAFEPATH` environment variable, and :option:`-E` | ||
| and :option:`-I` (isolated) options. | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This paragraph explains how to harden Python command line interface, to protect against some issues. It doesn't imply that it protects from all possible attacks.
I would prefer to keep the paragraph here. If you consider that the intent of this paragraph is unclear, I suggest rephrasing it, and maybe explain somehow what are all ways to inject code, and what are means to harden Python.