Skip to content
Path traversal Write-up Intermediate

Python Software Foundation - Python 3.11.0a3 to 3.15.0b2

On Windows, CPython built a standard-library search path from a relative path-traversal string, so a low-privileged user who could create folders two levels above the install directory could plant files that the interpreter loaded. When a privileged user or service account later ran Python, the planted code executed in that account's context, allowing privilege escalation.

bishopfox.com

Published on bishopfox.com

The following document describes identified vulnerabilities in Python versions 3.11.0a3 to 3.15.0b2.

The author, on bishopfox.com

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

Likely a build-time relative path-traversal string (VPATH) was embedded in the interpreter and used at runtime to derive the standard library location, so a landmark file outside the installation directory redirected the search path.

Impact

A low-privileged local user could execute arbitrary code as another, more privileged user or service account that later ran the interpreter, including during installer-driven installs; only Windows releases were affected.

What the attacker needed

Windows operating system; Python installed for all users in default path; Low-privilege user can create folders in C:\ root; Privileged account later runs Python

The fix

It was fixed in 3.13.15, 3.14.7 and 3.15.0b3, with patches pending for 3.11 and 3.12; the vendor also advises per-user installations instead of shared system-wide locations.

How it was found

  1. Confirm the target is a Windows all-users install of an affected Python version.
  2. Create a copy of the library and DLL folders two directories above the install directory.
  3. Place a crafted site-packages file and a build landmark file in that location.
  4. Wait for a privileged user or service account to launch the Python interpreter.
  5. Observe the planted code running in the privileged account's context.

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 starts, it works out where its own library files live so it can load them. On Windows it looked in a folder outside its own install folder, and ordinary users were allowed to create folders there. So a normal user could drop a file in that spot, and the next time an administrator ran Python, the user's code ran with administrator rights.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.