Lyrie
Supply-Chain
0 sources verified·4 min read
By Lyrie Threat Intelligence·5/12/2026

The Mistral AI PyPI Trojan: When Your AI Library Becomes a Weapon

TL;DR

Microsoft threat intelligence disclosed that mistralai v2.4.6 on PyPI was backdoored to steal credentials and execute a geofenced destructive payload. The malware runs automatically on import, targeting Linux machines and downloading a second-stage credential stealer. Developers and ML engineers who used this version should treat their systems as fully compromised.

What Happened

On May 12, 2026, Microsoft Threat Intelligence flagged a critical supply-chain compromise of the official Mistral AI Python client library (version 2.4.6) hosted on PyPI. The attack is part of the broader Mini Shai-Hulud worm campaign that has weaponized AI and developer tool ecosystems.

The malicious version was injected with code that executes automatically whenever the mistralai library is imported—meaning developers simply using Mistral AI in their projects unwittingly triggered the infection.

Technical Details

The Attack Chain

The attackers modified mistralai/client/__init__.py to execute a malicious initialization function that:

1. Checks the OS — Runs only on Linux systems

2. Sets an environment flagMISTRAL_INIT=1 for tracking

3. Fetches a second-stage payload — Downloads transformers.pyz from hxxps://83[.]142[.]209[.]194/transformers.pyz

4. Saves to a deceiving location — Saves as /tmp/transformers.pyz (mimicking Hugging Face's Transformers library to blend into ML workstations)

5. Executes the payload — Launches the second stage, which acts as a credential stealer

The Credential Stealer

The second-stage payload harvests:

  • SSH keys and credentials
  • API tokens and authentication secrets
  • Cloud provider credentials (AWS, GCP, Azure keys)
  • CI/CD pipeline tokens and secrets
  • Database passwords
  • Any environment variables containing secrets

The Geofenced Destructive Logic

This is where it gets alarming. The malware includes explicit geofencing logic:

  • Russian-language systems: Malware skips execution entirely (attribution obfuscation)
  • Israel or Iran: Activates a destructive branch with a 1-in-6 probability of executing rm -rf / to wipe the entire filesystem

This signals the attackers are willing to cause maximum damage in specific geopolitical contexts, not just steal data.

Persistence

The malware attempts to establish persistence by creating:

  • pgmonitor[.]py file
  • pgsql-monitor.service systemd unit (to auto-start on reboot)

Lyrie Assessment

Why This Matters to CISOs:

This attack exemplifies a critical new threat vector: when AI and ML tools themselves become the attack surface. Mistral AI is not a niche library—it's used in AI companies, research labs, DevOps teams, and production ML pipelines.

The asymmetric leverage is extreme:

  • A single compromised library version lands in hundreds of organizations simultaneously
  • Execution on import means no explicit action is required to trigger the infection
  • The target environment (ML and CI/CD infrastructure) often sits at the nexus of cloud credentials, model repositories, and internal deployments
  • A compromised dev workstation or CI runner can grant attackers access to your entire model training pipeline, cloud infrastructure, and deployment secrets

The geofenced destructive behavior also signals:

  • Sophisticated threat actors with state-level resources and geopolitical intent
  • Willingness to cause operational disruption, not just espionage
  • Potential for retaliatory or sabotage operations in specific regions

For Lyrie's autonomous defense mission: This confirms that dependency scanning is table stakes—but it's insufficient. Defense must include:

1. Runtime detection of suspicious import-time behavior (monitoring for outbound connections during package load)

2. Credential isolation in CI/CD (using short-lived tokens, limiting secret scope, rotating aggressively)

3. Behavioral quarantine (sandboxing untrusted package imports in limited-privilege containers)

4. Supply chain attestation (validating package signatures and build provenance, not just hash checks)

Recommended Actions

Immediate (Next 2 Hours)

1. Search your environment for any installation of mistralai==2.4.6 or any mistralai version ≥2.4.0 installed between May 11-12

2. Isolate infected systems — Remove from network immediately if found

3. Block the C2 IP — Add 83.142.209.194 to firewall deny rules (all directions)

4. Hunt for IOCs:

- Search Linux filesystems for /tmp/transformers.pyz

- Check for pgmonitor.py and pgsql-monitor.service files/units

- Grep process logs for connections to 83.142.209.194

Short-term (Next 24 Hours)

1. Rotate ALL credentials accessible from potentially compromised hosts:

- AWS/GCP/Azure keys and service accounts

- SSH keys and bastion access credentials

- Database passwords

- API tokens and CI/CD secrets

- GitHub/GitLab deploy keys

2. Audit CI/CD pipeline logs — Look for unusual deployments, secret exports, or credential theft attempts in the 24 hours before discovery

3. Review model repository access — Check who accessed your ML model registries (HuggingFace, internal repos) from potentially compromised machines

Medium-term (1 Week)

1. Implement dependency pinning — Use exact version locks, not floating ranges (e.g., mistralai==2.4.5 not mistralai^2.4)

2. Enable software attestation verification — Use PyPI's OIDC/PEP 740 signatures where available

3. Sandbox untrusted imports — Run dependency updates and package imports in containers with minimal privileges

4. Deploy anomaly detection on ML and CI/CD infrastructure — Alert on unusual network egress, credential access, or process execution during import-time

Sources

1. Microsoft Threat Intelligence (@MsftSecIntel), May 12 2026 - Mistralai Compromise Report

2. GBHackers - Microsoft Warns: MistralAI PyPI Package Compromised with Malware

3. CyberPress - Microsoft Flags PyPI Compromise


Lyrie.ai Cyber Research Division

Lyrie Verdict

Lyrie's autonomous defense layer flags this class of exposure the moment it surfaces — no signature update required.