DevGating: PyPI malware stays dormant until it spots a developer's machine
Island found eight malicious Python packages that decrypt their payload only when a library like requests is already loaded, leaving sandboxes to report them clean.
A supply-chain campaign running on PyPI, the main repository for Python software, has published eight malicious packages since 25 September 2026 that stay inert in a scanner and come alive on a working developer machine. The trick is simple and unpleasant: the payload is encrypted, and the key is derived from the name of a module already loaded in the running Python process, such as the widely used requests library. A sandbox that installs the package in isolation never loads that module, never derives the key, and dutifully reports the package clean.
Security firm Island, which published its research on 2 December 2026 and calls the technique DevGating, says the consequence for machines that do trigger it extends well past the package itself. Once run, the malware plants a Python startup hook that the package does not own, so removing the package with pip uninstall leaves the hook behind. Island told Infosecurity Magazine that the hook can affect later processes using the same Python installation, including continuous integration and deployment jobs and other services that hold source code and cloud secrets. The payload observed now is a harmless placeholder, but an earlier wave of the same campaign delivered a remote access trojan.
The packages also come in pairs. Each wave splits the malicious logic across two packages published from two separate PyPI accounts, so scanning any single package shows only half a chain that does nothing on its own. In the most recent pair, mailreader is a working mail-parsing library and pulls in confext as a dependency; a second pair, colook and basic-crypt, hides its payload in a compiled extension module rather than a pickle file.
Download counts are small. Each package had at most a few hundred downloads as of 16 November, according to Infosecurity Magazine, and Island said it did not know who installed the newest pair or whether any of those installs had the triggering module loaded at the time. Island researcher Ofek Ronen told Infosecurity Magazine on 2 December that "the packages were still available on PyPI", and that the firm had reported all still-listed packages the day before without receiving a reply.
The operator is still at work. On 1 December 2026 they published mailreader 2.7.2, which adds genuine email attachment-saving functionality while keeping the same execution chain, the same persistence and the same command-and-control endpoint, with only a minor change to the Linux launcher. Maintaining the legitimate features of the malware was a level of upkeep the campaign did not have to extend.
What to do now
- Check your Python environments and build images for the package names Island identified:
mailreader,confext,colookandbasic-crypt. Island reports the packages were still listed on PyPI as of 2 December, so a lockfile or mirror pull from recent weeks is worth inspecting. - If you find any of them, do not assume removal is enough. Uninstalling the package does not remove the
.pthstartup hook it plants, because the hook is not owned by the package. Look for unexpected Python startup files in your site-packages directories, and treat a machine that ran one of these packages as needing a rebuilt environment rather than a clean uninstall. - Review new packages together with the dependencies they pull in, not just the package named in your requirements file. Half of this attack arrives as a dependency published from a different account.
- Treat bundled pickle files and compiled modules in small utility packages as code to be audited. A mail parser that ships a pickle in a config file, or a lookup helper with a compiled extension, has made a choice that deserves an explanation.
- Run package tests with common libraries such as
requestsalready imported. Island notes that a package passing tests in isolation proves nothing, because isolation is exactly the condition this malware waits out. - On Linux, watch for Python interpreters launched from memory rather than from a file on disk, and on macOS for a
~/pip3-update.pyscript appearing briefly in a user's home directory.
For your technical team
Technical details
Island says the campaign has run four waves since 25 September 2026, totalling eight packages, four of which had not been reported before. mailreader 2.7.1 appeared on PyPI on 10 November 2026; its dependency confext was published two weeks earlier. mailreader 2.7.2 followed on 1 December 2026.
In the mailreader pair, the payload sits inside a pickle embedded in a configuration file named default.config, which is unpickled by code living in the confext dependency. Two pickle instructions call eval on a decoded string. The decryption key for the payload comes from the name of a module already present in the victim's Python process. Every malicious branch is wrapped in a silent exception handler (except: pass), so functional tests, error logs and users see nothing go wrong.
Persistence is a .pth Python startup hook that is not registered as part of the package. The colook and basic-crypt pair goes further, writing near-identical copies of setuptools' own _distutils_hack package and distutils-precedence.pth file, adding only a few lines and one extra file to conceal the loader.
Execution differs by platform. On Linux the malware can run a copy of python3 entirely from memory using memfd_create, never touching disk and so evading file-based antivirus and endpoint detection scanning. On macOS the stager writes a disguised ~/pip3-update.py script, runs it, and overwrites it with a genuine pip upgrade script after three seconds. On Windows the payload runs via exec inside a hidden python.exe with no child process to notice.
Further code is fetched from a free, operator-editable JSON bin, described by Infosecurity Magazine as a developer web service, which lets the operator change behaviour after infection without republishing anything and keeps the traffic pointed at a reputable domain.
Island counts eight distinct evasion layers in the campaign, each defeating a different control: code review and typosquat checks, per-package scanning, static analysis of source code, functional testing, sandbox detonation, install and uninstall hook monitoring, file-based endpoint scanning, and network and domain reputation checks. MITRE already tracks keying malware to the victim environment as technique T1480.001, Execution Guardrails: Environmental Keying, but Island says it had not previously seen the key derived from code the victim had already loaded.