cvelo
P2 · HighMalware

Malicious code in py2ops (PyPI)

  • MAL-2026-17807

Description

Show the whole description

The package installs a console command named python2 (pyops.cli:main), so it runs when someone types python2. On first run _register() in cli.py POSTs the hostname and OS to a space-z.ai server and keeps the returned apiKey in ~/.python2/config.json. Bare python2 is a real REPL that reads input with the echo off and sends any single word typed to the server's /api/cli/unlock, and run_payload() downloads gzip and base64 code from /api/cli/payload and runs it with exec in memory, hiding failures behind Python's can't open file error. Comments in the file call this the cover. I did not see what the served code does. I read 2.2 and did not run it. The package installs a CLI binary named `python2`, colliding with the historical real Python 2 interpreter name so users who type `python2` unintentionally invoke this loader. On invocation, `cli.run_payload()` performs an HTTPS GET to a hardcoded server (`https://preview-chat-960504a9-b4e0-4b69-bc80-6ac3d4fa4ae0.space-z.ai/api/cli/payload`, with a fallback at `https://b196q82k8891-d.space-z.ai`), base64-decodes and gunzips the response, and executes it in-process via `exec(compile(src, '<adv>', 'exec'), g); g['main'](argv)`. The payload is never written to disk, is unpinned and unsigned, and is chosen by the remote server on each call — a persistent operator-controlled remote code execution channel on the installer's machine. Enrollment is performed by `_register()`, which POSTs `os.uname().nodename` and OS/platform to `/api/cli/init` and stores the returned `apiKey` under `~/.python2/state.json`, pinning the host to the operator's control plane. A `_GateConsole` prints a banner mimicking the real Python REPL and reads single-token lines with terminal echo suppressed, then POSTs each entered token to `/api/cli/unlock` on the same server and stores an XOR-scrambled copy locally — any password, API token, or secret the user types by muscle memory into what they believe is a Python interpreter is uploaded to the operator. The package's own METADATA states that it `connects this machine to your ops server` and that `what the shell may run is decided by the operator on the server side`, and comments describe the fake REPL as `the whole cover`.

Text from the OSV record.

Recommendation

Remove the package and rotate any secret the machine that installed it could reach. There is no version to update to.

Affected

  • py2opsPyPI

    No versions listed

Timeline

  1. Published

Related news

No article from the followed outlets names this vulnerability.