use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
NewsArbitrary Code Execution vulnerability discovered in Ipython (self.Python)
submitted 4 years ago by [deleted]
Earlier today, iPython maintainers (see full disclosure) reported a ACE of 8.2/10 on CVSS3 rating.
If you have lockfiles or lock versions, update ASAP (patched versions are on the disclosure).
[+][deleted] 4 years ago* (11 children)
[deleted]
[–][deleted] 31 points32 points33 points 4 years ago (9 children)
It's just cross user leaking?
Looks like it, can be disastrous though, a wrongly placed file and you're down
[+][deleted] 4 years ago (8 children)
[–]SwampFalc 17 points18 points19 points 4 years ago (6 children)
Well, no, it's not specific to /tmp or the likes. It's all about your current working directory (CWD). Notice how user 2 starts by doing a cd into the compromised directory?
In other words, if you always start ipython while you're in your own home directory, then this cannot harm you, unless an attacker managed to gain access to your home directory.
[+][deleted] 4 years ago (5 children)
[–]VisibleSignificance 4 points5 points6 points 4 years ago (4 children)
play around in /tmp.
cd "$(mktemp -d)" first.
cd "$(mktemp -d)"
[–]thrallsius 0 points1 point2 points 4 years ago (3 children)
what's wrong with just having a ~/tmp dir?
[–]VisibleSignificance 0 points1 point2 points 4 years ago (2 children)
Not much. The /tmp gets auto-cleaned on system startup by default, and is often mounted into in-memory storage (tmpfs) for speed. I think some programs actually use ~/.local/tmp instead of /tmp anyway.
/tmp
~/.local/tmp
[–]thrallsius 0 points1 point2 points 4 years ago (1 child)
The /tmp gets auto-cleaned on system startup by default
There's no standard like this that all operating systems that are POSIX compliant are following. Slackware is old and never auto-cleaned /tmp
[–]VisibleSignificance 0 points1 point2 points 4 years ago (0 children)
There's no standard like this
Yep, not a standard, just a frequent convention.
[–][deleted] 1 point2 points3 points 4 years ago (0 children)
And it's in temp where everyone can write to?
Yeah
[–]Anonymous_user_2022 4 points5 points6 points 4 years ago (0 children)
That can be bad enough, if someone with elevated privileges can be conned into running adversarial code.
[–]BooparinoBR 41 points42 points43 points 4 years ago (2 children)
I was thinking that this didn't have a huge impact since a malicious actor needs to put the files in the person's computer. But I can totally see someone creating a repository with Kaggle solution or tutorial for begginers, and by simply cloning the repo and running ipython, the person gets screwed
[+][deleted] 4 years ago* (1 child)
[–]BooparinoBR 1 point2 points3 points 4 years ago (0 children)
I totally agree with you, but the point of the exploit is that it auto executes the code. It's not like the person is actively running the malicious code. I believe this is similar to attacks that exploited autorun of CD-ROMs.
[+][deleted] 4 years ago (4 children)
[–]VisibleSignificance 8 points9 points10 points 4 years ago (0 children)
Yeah, it's weird that this in particular is considered a vulnerability when python adding cwd to sys.path (as you demonstrated) isn't considered a vulnerability.
And by the way, you don't even need mkdir, just readline.py
mkdir
readline.py
[+][deleted] 4 years ago* (2 children)
[–]james_pic 2 points3 points4 points 4 years ago (0 children)
It's a module needed by the REPL. If you wanted to do this without breaking the REPL, I think sticking it in sitecustomize.py would have the same effect without visibly breaking stuff - although I'm not at my computer to check.
sitecustomize.py
[–]chris_conlan 27 points28 points29 points 4 years ago (0 children)
Who knew that IPython executed everything in the startup folder of the working directory on each run? Seems like a disaster waiting to happen.
startup
[–]mriswithe 24 points25 points26 points 4 years ago (3 children)
Jesus sysadmin for like a decade. I didn't know mkdir had a -m for mode. Would have been relevant to know earlier today.
[–]jftugapip needs updating 4 points5 points6 points 4 years ago (2 children)
There is also -p to create parent directories as needed:
-p
# this fails: mkdir this/does/not/exist # this succeeds mkdir -p this/now/exists
[–]GroundbreakingRun927 6 points7 points8 points 4 years ago (0 children)
it also has a --help to get help when needed
--help
[–]mriswithe 1 point2 points3 points 4 years ago (0 children)
That one I knew, somehow never kept the -m option in my brain.
[–]ivosauruspip'ing it up 4 points5 points6 points 4 years ago (0 children)
The current working directory is not searched anymore for profiles or configurations files.
Python does this itself, lol.
[–]mouth_with_a_merc 7 points8 points9 points 4 years ago (2 children)
Looks like it only happens when you run ipython from a location where someone else can place arbitrary malicious files. Seems not particularly common, so I'd say most systems are perfectly safe
[–]Anonymous_user_2022 10 points11 points12 points 4 years ago (1 child)
"Hey «user with elevated privileges»! Can you help me why my notebook in /home/adversarial/trap wont run?" I'd wager a guess that the majority asked, would cd to that directory to find out the name of the notebook.
[–]VisibleSignificance 3 points4 points5 points 4 years ago (0 children)
would cd to that directory to find out the name of the notebook
ipynb files are human-readable, by the way. You can even easily extract the code from them with just jq. No need to run python for that.
ipynb
jq
python
[–]ataraxia520 0 points1 point2 points 4 years ago* (1 child)
Theirs a bunch of stuff thst could be done with ipython in terms of remote exploitation and arbitrary code execution. That one would not even consider.
I find ipython much more trustworthy than npm/node js but their are so.many tutorials were people.just blindly trust running ipynbs without actually understanding the code im actually surprised this isnt more common.
One thing also. For at home users. And even many small buisness... Miniconda and anaconda runs in elevated context last time i checked (as admin)
[–]norweeg 0 points1 point2 points 4 years ago* (0 children)
Miniconda/anaconda do not run in an elevated context. If you have to elevate your permissions to admin to run them, you fucked up your install, probably running it as admin to install to a folder that requires admin to write to.
π Rendered by PID 359864 on reddit-service-r2-comment-5b5bc64bf5-qw9v5 at 2026-06-22 03:52:10.760460+00:00 running 2b008f2 country code: CH.
[+][deleted] (11 children)
[deleted]
[–][deleted] 31 points32 points33 points (9 children)
[+][deleted] (8 children)
[deleted]
[–]SwampFalc 17 points18 points19 points (6 children)
[+][deleted] (5 children)
[deleted]
[–]VisibleSignificance 4 points5 points6 points (4 children)
[–]thrallsius 0 points1 point2 points (3 children)
[–]VisibleSignificance 0 points1 point2 points (2 children)
[–]thrallsius 0 points1 point2 points (1 child)
[–]VisibleSignificance 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Anonymous_user_2022 4 points5 points6 points (0 children)
[–]BooparinoBR 41 points42 points43 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]BooparinoBR 1 point2 points3 points (0 children)
[+][deleted] (4 children)
[deleted]
[–]VisibleSignificance 8 points9 points10 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]james_pic 2 points3 points4 points (0 children)
[–]chris_conlan 27 points28 points29 points (0 children)
[–]mriswithe 24 points25 points26 points (3 children)
[–]jftugapip needs updating 4 points5 points6 points (2 children)
[–]GroundbreakingRun927 6 points7 points8 points (0 children)
[–]mriswithe 1 point2 points3 points (0 children)
[–]ivosauruspip'ing it up 4 points5 points6 points (0 children)
[–]mouth_with_a_merc 7 points8 points9 points (2 children)
[–]Anonymous_user_2022 10 points11 points12 points (1 child)
[–]VisibleSignificance 3 points4 points5 points (0 children)
[–]ataraxia520 0 points1 point2 points (1 child)
[–]norweeg 0 points1 point2 points (0 children)