Browse / MCP and Tool Server Flaws / AML.CS0045
Data Exfiltration via an MCP Server used by Cursor
- Target
- Cursor (Exercise)
How it worked
- AI Attack Adaptation · LLM Prompt Crafting
The researchers crafted a malicious prompt containing an instruction to execute the malicious shell command to exfiltrate the victim's AI agent credentials.
- Resource Development · Stage Capabilities
The researchers created a malicious web site containing the malicious prompt.
- Defense Evasion · LLM Prompt Obfuscation
The malicious prompt was hidden in the title tag of the webpage.
- Resource Development · Stage Capabilities
The researchers launched a web server to receive data exfiltrated from the victim.
- Initial Access · Drive-by Compromise
When a user asked Cursor to use an MCP tool to scrape the malicious website, the contents of the malicious prompt was retrieved and ingested into Cursor's context window.
- Execution · LLM Prompt Injection: Indirect
When the MCP server scraped the malicious web site, it returned the injected prompt to the MCP client and poisoned the context of the Cursor LLM. Cursor executed the malicious prompt embedded in the website scraped by the MCP tool.
- Privilege Escalation · AI Agent Tool Invocation
The prompt injection invoked Cursor's ability to call command line tools via the
run_terminal_cmdtool.Cursor prompted the user before executing a shell command, potentially mitigating this attack.
- Defense Evasion · LLM Prompt Obfuscation
When the MCP server scraped the malicious web site, it returned the injected prompt to the MCP client and poisoned the context of the Cursor LLM. The shell command in the malicious prompt was obscured via base64 encoding, making it less clear to the user that something malicious may be executed.
- Credential Access · Credentials from AI Agent Configuration
The shell command located the
.openapi.apiKeyand.cursor/mcp.jsoncredentials files that were part of the Cursor's configuration. - Exfiltration · Exfiltration via AI Agent Tool Invocation
The credentials files were exfiltrated to the researcher's server via a
curlcommand invoked by Cursor'srun_terminal_cmdtool. - Impact · External Harms: Financial Harm
A bad actor could use the stolen credentials to cause financial damage and could also steal other sensitive information from the victim user.
Summary
The Backslash Security Research Team demonstrated that a Model Context Protocol (MCP) tool can be used as a vector for an indirect prompt injection attack on Cursor, potentially leading to the execution of malicious shell commands.
The Backslash Security Research Team created a proof-of-concept MCP server capable of scraping webpages. When a user asks Cursor to use the tool to scrape a site containing a malicious prompt, the prompt is injected into Cursor's context. The prompt instructs Cursor to execute a shell command to exfiltrate the victim's AI agent configuration files containing credentials. Cursor does prompt the user before executing the malicious command, potentially mitigating the attack.
References
Source: MITRE ATLAS case studies, used under Apache 2.0.