Skip to content
Misconfiguration Write-up Intermediate

Pip Dreams and Security Schemes: Chaos in your Configuration Files

Pip configuration files can be modified to point pip at an attacker-controlled package index, which then injects malicious code into packages during installation. An attacker with write access to a user's pip config could backdoor every subsequent pip install.

Matt Landers Follow

Published on osec.com

Where pip's config files live on Linux and Windows, the order they load in, and how a poisoned one backdoors every install

Matt Landers, on osec.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 the pip configuration file is writable by an attacker or can be modified through another vulnerability, allowing the index URL to be redirected to a malicious server.

Impact

An attacker could execute arbitrary code on the victim's machine during pip installs, potentially leading to full system compromise.

What the attacker needed

Write access to pip config file; victim runs pip install

The fix

Restrict access to pip configuration files or make them read-only, and limit pip use in production environments.

How it was found

  1. Write a malicious pip configuration file that sets index-url to an attacker-controlled server and disables caching and virtualenv requirement.
  2. Start a rogue package index server that injects code into requested packages.
  3. Trigger a pip install, which contacts the rogue server and receives a package with injected code.
  4. The injected code executes during installation.

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.

Pip is a tool that downloads and installs Python packages. It reads settings from configuration files that tell it where to find packages. If an attacker can change those settings, they can make pip download packages from a server they control, and those packages can run harmful code when installed.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More by Matt Landers

View all

4 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.