Supply Chain Weaknesses in AI Coding Assistants Expose Sensitive Credentials
A new study reveals that Model Context Protocol (MCP) servers, integral to AI coding assistants, are vulnerable to supply chain attacks that can lead to the theft of API keys and administrator credentials.

Security teams deploying AI coding assistants may be inadvertently exposing their most sensitive credentials due to inherent weaknesses in Model Context Protocol (MCP) servers. A recent study by Corelight highlights how these servers, which facilitate communication between AI assistants and other tools like firewalls and cloud consoles, can be manipulated through supply chain attacks. By poisoning dependencies fetched from public registries such as PyPI, attackers can inject malicious code that steals API keys and administrator logins, compromising the integrity of the AI tools and the data they access.
The vulnerability arises from the installation methods employed by many MCP servers. Researchers observed that some servers, despite having pinned dependencies or hash-locked files, would still fetch the latest package versions upon rebuilds. This practice bypasses pinned dependencies, creating a critical window for malicious code injection. In one observed case, a server rebuilt 19 times over five weeks saw 23 of its 69 packages change versions, including essential libraries like cryptography and the MCP software kit itself. This drift occurs because the launcher ignores the pinned file and pulls fresh packages from public registries, effectively undermining security configurations.
Each package within the server's process has the potential to access sensitive information, including API tokens, user files, and network paths. Malicious packages can execute code the moment Python starts, making the compromise swift and stealthy. The risk is not confined to Python; similar practices are seen with other languages and package managers where 'latest' tags are used, fetching the newest version at every start-up. This dynamic update mechanism, while sometimes intended for convenience, mirrors the critical flaw where a hijacked release could spread just as rapidly as a legitimate update.
Corelight emphasizes that this is not a flaw within MCP itself but rather a consequence of installation choices. A significant portion of reviewed MCP servers utilized installation methods that would pull dependencies directly from public registries. Attackers exploit this by targeting the easiest dependency to compromise, whether through weak account security, phishing, or insecure release pipelines. The malicious version then masquerades as a routine update, making detection difficult.
Past incidents, such as the xz Utils and Shai-Hulud campaigns, demonstrate the effectiveness of such supply chain attacks. The Shai-Hulud npm worm, for instance, used stolen tokens to publish infected versions of packages, with a variant specifically targeting cloud credentials and AI coding tool API keys. Servers that rebuild automatically at start-up are particularly susceptible, increasing their chances of falling victim to these brief windows of compromise.
Detecting this type of threat involves monitoring DNS and TLS logs for connections to package registries like GitHub and PyPI. Endpoint data can then identify which workstations are installing packages and when. The primary mitigation strategy recommended by Corelight is to freeze the environment by pinning dependencies to specific commits, using hash-pinned lock files, launching servers directly, and disabling auto-update checks at start-up. Implementing these measures ensures that package lists remain static and secure.
Furthermore, each server should operate with an account that has the minimum necessary privileges, and a designated owner should regularly review any updates. By adopting these stringent security practices, organizations can significantly reduce the risk of supply chain attacks targeting their AI coding assistants and protect their sensitive credentials from falling into the wrong hands.
The study identified several indicators of compromise, including connections to domains like github.com, pypi.org, and npmjs.org for code downloads and package registry interactions. While IP addresses and domains were obfuscated in the report, these patterns can serve as valuable alerts for security operations centers.