{"slug": "i-built-a-python-library-to-stop-ai-agents-from-leaking-secrets-modelfuzz", "title": "I built a Python library to stop AI agents from leaking secrets (ModelFuzz)", "summary": "A developer built ModelFuzz, an open-source Python library that intercepts tool calls at the execution layer to prevent AI agents from leaking secrets via prompt injection. The library includes a CLI scanner that red-teams agents, and tests on a local Qwen2.5 model showed it was breached 4 out of 5 times.", "body_md": "I've been building AI agents lately, and honestly, their security model terrifies me.\n\nWe give LLMs access to powerful tools like `shell.run`\n\n, `http.post`\n\n, and `fs.read`\n\n. But if an agent reads a malicious email or a poisoned webpage, it can be tricked by prompt injection into using those tools to exfiltrate data.\n\nHoping the LLM refuses the attack isn't a real security strategy.\n\nSo, I built ModelFuzz. It's an open-source Python library that intercepts the tool call at the execution layer.\n\n`@shield_tool`\n\nInstead of trying to filter prompts, ModelFuzz checks the arguments before the tool runs. If it detects a policy violation, like a stolen API key or an unsafe URL, the tool simply doesn't execute.\n\n``` python\nfrom modelfuzz import shield_tool\n\n@shield_tool\ndef send_email(to_address: str, subject: str, body: str) -> None:\n    smtp.send(to_address, subject, body)\n```\n\nEven if the LLM is completely tricked by a prompt injection, the tool never fires.\n\n`modelfuzz scan`\n\nI also built a CLI scanner that red-teams your agent. It fires deceptive prompt injection attacks at your local model to see if it can be tricked into calling a tool.\n\n```\nmodelfuzz scan --endpoint http://localhost:11434/v1 --model qwen2.5:1.5b\n```\n\nI tested it against a local `qwen2.5:1.5b`\n\nmodel, and it got breached 4 out of 5 times.\n\nIt's 100% open source and live on PyPI.\n\n```\npip install \"modelfuzz[scan]\"\n```\n\nI'd love to know what security policies you think are missing, or what agent frameworks you want supported next!", "url": "https://wpnews.pro/news/i-built-a-python-library-to-stop-ai-agents-from-leaking-secrets-modelfuzz", "canonical_source": "https://dev.to/higagan/i-built-a-python-library-to-stop-ai-agents-from-leaking-secrets-modelfuzz-6o2", "published_at": "2026-07-23 17:58:20+00:00", "updated_at": "2026-07-23 18:04:21.455270+00:00", "lang": "en", "topics": ["ai-safety", "developer-tools", "artificial-intelligence", "large-language-models"], "entities": ["ModelFuzz", "PyPI", "Qwen2.5"], "alternates": {"html": "https://wpnews.pro/news/i-built-a-python-library-to-stop-ai-agents-from-leaking-secrets-modelfuzz", "markdown": "https://wpnews.pro/news/i-built-a-python-library-to-stop-ai-agents-from-leaking-secrets-modelfuzz.md", "text": "https://wpnews.pro/news/i-built-a-python-library-to-stop-ai-agents-from-leaking-secrets-modelfuzz.txt", "jsonld": "https://wpnews.pro/news/i-built-a-python-library-to-stop-ai-agents-from-leaking-secrets-modelfuzz.jsonld"}}