Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sat, 24 Jul 2021 18:33:44 +0300
From: Georgi Guninski <>
Subject: Potential symlink attack in python3 __pycache__

Not sure if this is vulnerability, but it looks like
classical symlink attack.

In python3, if a script in directory DIR1 does "import another",
then python3 creates directory __pycache__ in DIR1 and puts
some files in __pycache__.

According to our tests, if DIR1/__pycache__ is symlink to something,
then python3 follows the symlink.

We suspect the attacker has little to no control on the created files,
except that the files are created.

Here is an artificial session of root shooting herself in the leg
on ubuntu 20:

root@...lokote:~# python3 --version
Python 3.8.10
root@...lokote:~# cat /tmp/
try:  import joro2
except:  print("error in import (2)")
root@...lokote:~# cat /tmp/
print("in joro 2")
root@...lokote:~# rm ~/tests/*
root@...lokote:~# rm /tmp/__pycache__ #XXX
root@...lokote:~# ls -l ~/tests
total 0
root@...lokote:~# ln -s ~/tests/ /tmp/__pycache__ #XXX shooting in leg
root@...lokote:~# python3 /tmp/
in joro 2
root@...lokote:~# ls -l ~/tests
total 4
-rw-r--r-- 1 root root 144 Jul 24 16:58 joro2.cpython-38.pyc

Powered by blists - more mailing lists

Please check out the Open Source Software Security Wiki, which is counterpart to this mailing list.

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.