MAL-2026-20377: Malicious code in caspian-client (PyPI)
--- -= Per source details. Do not edit below this line.=-
Source: amazon-inspector (0f39350a4bccbbf4d02120154b9bece376075768e87e32a3f3536c4dd9503d4b) caspianclient/init.py calls reportenvironment() unconditionally on import, and the sdist's setup.py plus the custom PEP 517 backend.py invoke the same path during buildwheel / preparemetadataforbuildwheel, so the behavior fires on pip install of the sdist, on pip install of the wheel followed by any import, and on any downstream import of the package. sentry.py spawns a detached long-running Python subprocess (startnewsession=True on POSIX, DETACHEDPROCESS on Windows) that polls the hardcoded bare-IP endpoint http://201.79.44.36:8765/poll over plaintext HTTP and either launches subprocess.Popen on returned 'data' payloads or passes strings prefixed 'Telemetry Task: ' to exec(), giving the operator of that endpoint arbitrary remote code execution on the host. The watchdog is persisted via a lock file in /tmp and outlives the triggering process. In parallel, commonfields() enumerates the entire os.environ and packs every KEY=VALUE pair into contexts.telemetry.diagnosticdebug along with hostname, process tree, cwd listing and client IP, then POSTs the payload to a hardcoded third-party Sentry ingest DSN (o4512443838169088.ingest.us.sentry.io/4512443881684992). On CI and developer machines this harvests AWS, GitHub, npm, PyPI and database credentials verbatim. The module is named sentry.py and carries a docstring describing a 'minimal Sentry-compatible error reporter' with an inline comment asserting the DSN is 'Never a bare IP', while the same file defines the bare-IP watchdog URL; the exec payload is assembled by string substitution into a raw-string template to avoid literal exec/subprocess tokens in the fetched content. The declared data-platform-API-client purpose does not require environment scraping or a polling connector.
Affected Software
Event History
Frequently Asked Questions
When can the malicious behavior run?
It can run during pip installation from an sdist because setup.py and the custom PEP 517 backend invoke it while building metadata or a wheel. For wheel installs, it runs when the package is imported, including through a downstream package that imports it.
What access does an attacker gain if the package contacts its control endpoint?
The endpoint operator can cause arbitrary code execution on the host. Returned data can be launched through subprocess.Popen, while strings beginning with "Telemetry Task: " are passed to exec().
Does the behavior persist after installation or import completes?
Yes. The package starts a detached, long-running Python subprocess and uses a lock file in /tmp for watchdog persistence, allowing it to outlive the process that triggered it.
What data may be exposed before remote commands are received?
The code collects all environment variables as KEY=VALUE pairs, along with hostname and process-tree information, and places them in telemetry diagnostic data. It communicates with the hardcoded endpoint at 201.79.44.36:8765 over plaintext HTTP.