Skip to content

MAL-2026-17807 Malicious code in py2ops (PyPI)

Unknown
Published
Updated
Exploit status
No public exploit known

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.


-= Per source details. Do not edit below this line.=-

Source: amazon-inspector (a9a74f3074cecc3664413a77f71721857d30a0012b630af60731e6480c11dac3)

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.

Upgrade path

1 package: 0 fixed.

PackageAffectedFixed inStatus
pypi py2ops(PyPI) = 2.2; = 2.2.1; = 2.3; = 2.3.1 No fix listed Versions listed

Affected products

ProductAffected versionsFixed in
pypi py2ops(PyPI) = 2.2 No fix listed
pypi py2ops(PyPI) = 2.2.1 No fix listed
pypi py2ops(PyPI) = 2.3 No fix listed
pypi py2ops(PyPI) = 2.3.1 No fix listed

References