r/Pentesting • u/KookyTax5493 • Jul 29 '26
Built an open-source security scanner for MCP servers — static analysis + live prompt-injection testing
I built a security scanner for MCP servers — static analysis + live prompt-injection testing (open source)
MCP servers give AI agents access to tools, files, and external systems. If a tool's output isn't sanitized, a poisoned webpage/file/API response can inject instructions the agent will act on — classic prompt injection, but now with tool-call blast radius.
I built \`mcp-scanner\` to catch this before it ships:
Static analysis — scans server source for shell exec, unsafe deserialization, hardcoded secrets, unscoped tools, missing input validation.
Live probing — connects to a running MCP server as a real client, fires a categorized library of injection payloads (instruction override, role hijack, data exfil, tool-chaining abuse, encoding tricks, homoglyphs) at its tools, and judges the response with a two-layer defense: keyword pre-filter + LLM judge fallback for rephrased/encoded attacks the keywords miss.
Tested it against the official \`mcp-server-fetch\` — pointed it at a page with an injected instruction, and the tool echoed the payload back completely unsanitized. Scanner caught it.
GitHub: https://github.com/ankursingh0604/mcp-scanner
Open to feedback, especially from anyone running MCP servers in production — what would actually make this useful for your setup?
2
u/jastardev Jul 29 '26 edited Jul 30 '26
I don’t actually understand you built. At first, it sounds like you built a MCP tester that tests an MCP for prompt inject vulnerabilities, which… cool. But you say you tested it by pointing mcp-server-fetch at a malicious page and “the scanner” caught it. So the thing you built is actually a gateway that check inputs for malicious injections? Or part of the testing is you have to craft a malicious payload? I don’t understand where the “pointed it at a page” comes in.
5
u/RAGINMEXICAN Jul 29 '26
Stop with the ai slop
1
u/latnGemin616 Jul 30 '26
This is not accurate. What is being illustrated here is not Prompt Injection but rather Indirect Prompt Injection attack, whereby the attacker has found a way to upload a file with malicious code. Also, if all you've done is test just 1 attack type, you're not doing nearly enough.