# MAL-2026-4231: Malicious code in pylogfmt (PyPI)


- **Type:** Malicious package
- **Package:** `pylogfmt` (PyPI)
- **Published:** 22 May 2026

## What is MAL-2026-4231?

MAL-2026-4231 is a malicious package in pylogfmt, published on 22 May 2026. 

### Official description

On `import pylogfmt`, the package's __init__.py spawns a detached background subprocess (`subprocess.Popen([sys.executable, '_check.py'], stdout=DEVNULL, stderr=DEVNULL)`) that runs an infinite loop POSTing the package install path to https://pypkg.dev/project/pylogfmt/json every 60 seconds with TLS verification explicitly disabled. The HTTP response body is base64-decoded and dispatched to a worker thread (`threading.Thread(target=check, args=(package_list.decode(),))`), which is the canonical remote-payload-dispatcher shape — the operator controls returned bytes and the client decodes and feeds them into a handler. The destination domain pypkg.dev is a lookalike of pypi.org/pypa with no relation to the package's declared logging-library purpose. Output suppression (DEVNULL on both streams), undocumented behavior (README advertises only a logging helper), TLS bypass, and lookalike C2 destination together are unambiguous attack signals. Any consumer that imports pylogfmt as a library leaks their install path to attacker infrastructure on a 60-second polling interval and is one server-side change away from arbitrary remote code execution.

Package silently executes remote code during import.

---

Category: MALICIOUS - The campaign has clearly malicious intent, like infostealers.

Campaign: 2026-05-lognest

Reasons (based on the campaign):

 - Downloads and executes a remote malicious script.

## What should I do about MAL-2026-4231?

Remove the package from your dependencies and lockfiles, then rotate any secrets on machines where it was installed.

## Fix prompt for AI coding agents

```text
MAL-2026-4231 is a malicious package: pylogfmt (PyPI). Every version was published to cause harm.

Task:
1. Search this repository's dependency manifests and lockfiles for the package, including transitive dependencies.
2. If it is present, remove it, regenerate the lockfile with the project's package manager, and replace whatever it was used for.
3. List any CI runners, developer machines or containers that installed it, so their secrets can be rotated.
4. If the package is not used anywhere, say so and change nothing.

Reference: https://insights.sbomify.com/MAL-2026-4231/ (Markdown: https://insights.sbomify.com/MAL-2026-4231/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/MAL-2026-4231

---
From sbomify Insights: https://insights.sbomify.com/MAL-2026-4231/
Summaries are generated and may contain mistakes; the official description above is the record.
