CWD-Based Module Hijacking in Python pymanager (CVE-2026-5271)
The pymanager tool set an empty entry at the front of Python's module search path, which makes Python look in the current working directory first. An attacker who can place a Python file in a directory where a user later runs a pymanager-generated command could have their file imported and executed instead of the real module.
A vulnerability in Python’s pymanager introduces a code execution risk due to unsafe manipulation of the module resolution path.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The alias wrapper code set the first entry of Python's module search path to an empty string, which Python treats as the current working directory, so imports resolved from an untrusted location before the standard library and installed packages.
Impact
A user running a pymanager-generated command such as pip or pytest inside an untrusted directory could execute attacker-supplied code with their own privileges, with no elevated rights needed.
What the attacker needed
Pymanager 26.0 installed; attacker can place a .py file in the directory; victim runs a pymanager command there
The fix
The issue was fixed in pymanager 26.1, which removes the unsafe manipulation of the module search path.
How it was found
- Create a directory and place a file named after a common module inside it.
- Run a small script that sets the first search path entry to an empty string and then imports that module.
- Observe that the file from the current directory runs instead of the real library.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When Python imports a module, it checks a list of folders in order. If the current folder is checked first, a file with the same name as a real module can be picked up and run instead. Here the tool put the current folder at the front of that list, so a malicious file dropped into a project folder could run when a developer used a normal command there.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.