by jwilk · 4y ago · 0 comments
https://bugs.python.org/issue33053
E.g.:
$ echo 'import os; os.execvp("cowsay", ["-", "pwned"])' > pip.py
$ python -m pip --version
_______
< pwned >
-------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||$ echo 'import os; os.execvp("cowsay", ["-", "pwned"])' > pip.py
$ python -Im pip --version
pip 22.0.2 ...
... when does that happen and why would you run any program in that case ?
https://docs.python.org/3.11/whatsnew/3.11.html#summary-rele...
However, if you tab complete a file name that’s not "dot slash" prefixed, it’ll add it for you. Not sure if sh and friends do that.
[a]: Implicitly. Echoing the $PATH variable won’t include `.`, but you can execute as if it was
The 'local directory' one is the actual concern. For example, our CI system for one of our tools runs commands like `pip install -U setuptools`. If we switched it to `python -m pip install -U setuptools`, it would continue to work fine - unless a developer accidentally committed a file called `pip.py` to the root.
At that point, Python would try to import `pip.py` as `pip` instead of the actual module pip (because current directory is checked for includes first).
https://docs.python.org/3/using/cmdline.html
> If the script name refers directly to a Python file, the directory containing that file is added to the start of sys.path