Back to Newsroom

Threat intel5 min read

Malicious PyPI packages stay locked until requests is loaded

Eight PyPI packages hide encrypted malware that only unlocks when the requests library is already loaded, so scanners that test them alone see nothing. Four are still listed.

4Tify Team

Malicious PyPI packages stay locked until requests is loaded

Eight packages published to the Python Package Index (PyPI) since 25 September 2026 carry malware that stays encrypted until it lands next to a real project. The key that unlocks it is the name of a module from the popular requests library. If requests is not already loaded, the code does nothing, which is how it gets past scanners that import a package on its own and watch what happens. The technique is called DevGating. Four of the packages were still listed on PyPI on 4 December.

What happened

The packages came out in four waves, each one a pair: a "front" package with a working feature and a helper that does the hidden work. The two halves of every pair were uploaded from different PyPI accounts, and each account published only that one project. Looked at alone, the front package only loads a config file, and the helper only contains a config parser.

The pairs, oldest first:

  • webreader 2.3.8 with pafer 0.9.7 and 0.9.8 (from 25 September)
  • resion 22.0.1 with pafex 2.3 (20 October)
  • colook 1.1.3 with basic-crypt 1.5.2 and 1.5.3 (21 October)
  • mailreader 2.7.1 and 2.7.2 with confext 0.7.2 (27 October to 1 December)

The first two pairs are gone from PyPI and have malware entries in the OSV database. mailreader, confext, colook and basic-crypt were still available on 4 December. basic-crypt also has a newer version, 1.5.4, uploaded on 30 November, which no published analysis covers yet. Treat it as suspect.

Who is affected

Anyone who installed one of the eight packages, directly or as a dependency, on a developer laptop, a build runner or a server. Download counts were low, a few hundred at most per package by mid-November, and a download does not mean the malware ran. The front packages are small generic tools (a web reader, a mail parser, a terminal colour library) that someone might pick up from a quick PyPI search. None of them copies the name of a well-known project.

How it works

In the newest pair, mailreader ships a file called default.config. It is really a pickle, a Python serialisation format that can run code when it is loaded. confext provides the config loader that unpickles it. The decoded code is XOR-encrypted. To get the key, it looks through the modules Python has already loaded for requests.packages.urllib3.util.connection and builds the key from that name. The colook pair looks for requests.packages.urllib3.util.request instead.

A sandbox that installs and imports mailreader by itself never loads requests, so the payload stays locked and the package looks clean. A developer whose application imports requests first and then mailreader unlocks it without noticing.

Once it runs, the malware writes a .pth file into the Python install. Python executes .pth files at every start, so the code keeps running after pip uninstall. For mailreader the file is py_abi2-log.pth, which imports a module called py_log2. The colook variant hides its launcher in copies of setuptools' _distutils_hack package and distutils-precedence.pth. On Linux it starts Python from memory and pulls the next stage from a JSON bin on npoint.io, which the operator can change at any time. The macOS and Windows paths were read from the code but not run.

The bin currently serves a harmless placeholder, so the final payload for the latest wave is not known. An earlier wave delivered a remote access trojan. It is not confirmed whether any machine actually ran the latest chain.

What to do now

  1. Search lockfiles, requirements files, container images, CI caches and developer machines for mailreader, confext, colook, basic-crypt, webreader, pafer, resion and pafex. Check every version of basic-crypt.
  2. If you find one, removing the package is not enough. Look in each site-packages directory for py_abi2-log.pth, a py_log2 folder, the file /tmp/pylog.txt, and any _distutils_hack copy or distutils-precedence.pth that your setuptools install did not put there.
  3. Treat an affected machine as compromised. Rebuild it, and rotate the tokens, SSH keys and cloud credentials it could reach, including CI secrets.
  4. Block build and production systems from reaching paste sites and hosted JSON stores such as npoint.io unless something there needs them.
  5. Pin dependencies with hashes, and check new packages before a developer or a coding agent adds them.

Import-time tests miss this kind of malware, because it waits for the right neighbours. Our AI-assisted code review reads a project's dependency tree and the code that runs at install and import time, and flags packages that load executable data from config files or drop startup hooks, before they reach a build.

NEWSLETTER

The week’s news,
every Friday.

A short email with what we published that week. You can unsubscribe from any of them.

FRIDAY DIGEST · SAMPLE4TIFY NEWSROOM

This week in security

  • 01Fake UNO game installer hides a Java RAT that steals passwords
  • 02Woolworths says attackers accessed a database of 14 million customer records
  • 03AWS decoy caught a suspected AI agent taking 94 actions in 12.7 minutes

+ 6 MORE IN THIS ISSUE · UNSUBSCRIBE IN ONE CLICK

ONE OFFER

More than one product?
Get one offer.

Tell us what you need to protect and your budget, monthly or yearly. We combine the products into one offer and one contract, sized to that budget, and we stay with you after it is signed.

Ask for an offer Just tell us how many assets you have and what you want to spend.