{"id":"MAL-2026-17807","summary":"Malicious code in py2ops (PyPI)","details":"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.\n\n---\n_-= Per source details. Do not edit below this line.=-_\n\n## Source: amazon-inspector (a9a74f3074cecc3664413a77f71721857d30a0012b630af60731e6480c11dac3)\nThe 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, '\u003cadv\u003e', '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`.\n","modified":"2026-11-25T07:00:04.183663335Z","published":"2026-10-09T16:02:15Z","database_specific":{"iocs":{"domains":["preview-chat-960504a9-b4e0-4b69-bc80-6ac3d4fa4ae0.space-z.ai","b196q82k8891-d.space-z.ai"],"urls":["https://preview-chat-960504a9-b4e0-4b69-bc80-6ac3d4fa4ae0.space-z.ai/api/cli/init","https://preview-chat-960504a9-b4e0-4b69-bc80-6ac3d4fa4ae0.space-z.ai/api/cli/unlock","https://preview-chat-960504a9-b4e0-4b69-bc80-6ac3d4fa4ae0.space-z.ai/api/cli/payload"]},"malicious-packages-origins":[{"import_time":"2026-11-25T06:44:07.002092019Z","modified_time":"2026-11-25T06:25:13Z","sha256":"e77574a4cd7a168169910ded2ac90ae760ed4d01642534551635776bab32d5cd","source":"amazon-inspector","versions":["2.2.1"],"id":"IN-MAL-2026-023106"},{"import_time":"2026-11-25T06:44:06.962731286Z","modified_time":"2026-11-25T06:25:06Z","sha256":"7833744489ea9bb64dd119507e3e779b6be9d029c868abf82400b7588895ca52","source":"amazon-inspector","versions":["2.3"],"id":"IN-MAL-2026-023105"},{"import_time":"2026-11-25T06:44:07.045478324Z","modified_time":"2026-11-25T06:25:20Z","sha256":"a9a74f3074cecc3664413a77f71721857d30a0012b630af60731e6480c11dac3","source":"amazon-inspector","versions":["2.3.1"],"id":"IN-MAL-2026-023107"}]},"references":[{"type":"PACKAGE","url":"https://pypi.org/project/py2ops/2.2.1/"},{"type":"PACKAGE","url":"https://pypi.org/project/py2ops/2.3/"},{"type":"PACKAGE","url":"https://pypi.org/project/py2ops/2.3.1/"}],"affected":[{"package":{"name":"py2ops","ecosystem":"PyPI","purl":"pkg:pypi/py2ops"},"versions":["2.2","2.2.1","2.3","2.3.1"],"database_specific":{"indicators":{"evidence_files":[{"sha256":"e28cc631957bd4118bced3246df7345244f495e1da029145f593738e173fa444","tlsh":"939293239d565833c783c56e4d9bd181f32abc8325052438beedd2c42fa9a3281bd7d9","path":"pyops/cli.py"}],"package_integrity":[{"hashes":{"md5":"ceab2d0273e9933812e0f91dccd49aac","sha256":"fcaf5924e3c051ca2f14f2b7c06768b2346349006948fd7ce8852b7f76ba7208","blake2b_256":"3b0f2337871d7e2d438d8faace90ff02eeead5940980ceaabe0b55aa0e16dc9c"},"filename":"py2ops-2.2.1-py3-none-any.whl"}]},"source":"https://github.com/ossf/malicious-packages/blob/main/osv/malicious/pypi/py2ops/MAL-2026-17807.json","cwes":[{"cweId":"CWE-506","description":"The product contains code that appears to be malicious in nature.","name":"Embedded Malicious Code"},{"description":"The product contains code that appears to be malicious in nature.","name":"Embedded Malicious Code","cweId":"CWE-506"},{"cweId":"CWE-506","description":"The product contains code that appears to be malicious in nature.","name":"Embedded Malicious Code"}]}}],"schema_version":"1.9.2","credits":[{"name":"Amazon Inspector","contact":["inspector-research@amazon.com"],"type":"FINDER"},{"name":"smiling-hyena","contact":["smilinghyena4@gmail.com"],"type":"FINDER"}]}