aiocpa 0.1.13 and 0.1.14 on PyPI hid obfuscated code that sent Crypto Pay API tokens to a Telegram bot on 20 November 2024.
aiocpa is a Python client for the Crypto Pay API. The PyPI packages carried the malicious code. The public GitHub repository did not.
What happened
The attacker published two poisoned releases to PyPI.
- The code sits in
cryptopay/utils/sync.py, wrapped in about 50 layers of obfuscation. - On import, it replaces the constructor of the
CryptoPayclass. - It sends the constructor arguments, which include the API token, to a Telegram bot in an HTTP request.
Version 0.1.13 appeared at 18:04 UTC on 20 November 2024 and 0.1.14 at 18:50 UTC. PyPI Security quarantined the package on 21 November at 18:29 UTC.
Affected versions
- aiocpa 0.1.13 (malicious, released 20 November 2024).
- aiocpa 0.1.14 (malicious, released 20 November 2024).
- aiocpa 0.1.0 to 0.1.12 (safe, according to PyPI Security).
- No clean release exists after 0.1.12.
Indicators of compromise
- Package name
aiocpaat version 0.1.13 or 0.1.14. - The file
cryptopay/utils/sync.py, with the malicious code near line 44. - Outbound requests to
api.telegram.orgwith a/bot<id>/sendMessagepath andchat_id=6526761736. - SHA1 of 0.1.13 files listed by ReversingLabs:
a1187d2a4acfe8ddaee3c7be79a9bb838142903aand7007be259829d72e73ff63ad409770ca56cfc418. - SHA1 of 0.1.14 files listed by ReversingLabs:
fc36c157075dd4302f71ed2660e19a61016b085cand01f7db47368bffa279fb15c688518774454650cf.
How to check
Check the version in each Python environment, including virtual environments and containers.
pip show aiocpa pip freeze | grep -i aiocpa
Search lock files and image layers for the package.
grep -rn aiocpa requirements*.txt poetry.lock Pipfile.lock pyproject.toml
What to do now
- Run
pip uninstall aiocpain every environment. - Revoke and replace every Crypto Pay API token that an affected program used.
- Check your Crypto Pay account for payments you did not make.
- Pin dependency versions and use hash checking, for example
pip install --require-hashes.
What Vigilance would show
These examples show an install hold and the corresponding owner report.
Example install message
Vigilance blocked `aiocpa` 0.1.13. This version is too new or changed in a way Vigilance must check first.
Example owner report
Bad update
aiocpa 0.1.13
A payments library gained hidden scrambled code that unpacked itself and sent the owner's payment keys to a chat bot.
No security team? See who reads the alert.
Frequently asked questions
How many downloads did aiocpa have?
ReversingLabs reports more than 10,000 downloads before removal.
How did researchers find it?
ReversingLabs found the package on 21 November 2024 with machine learning threat hunting and reported it to PyPI.
Sources
Send this page to the person who looks after AI at your company.