The open-source runtime firewall for AI agents.
Stops poisoned tools, rug-pulls, data theft, AI worms and memory poisoning in the live traffic between your agent and its MCP servers.
Get started · Explained simply · Scoreboard · Test any guard · Architecture · Contribute
AI agents do whatever the text they read tells them, including a note an attacker hid in an email, a web page or a GitHub issue. And they hold the keys to your email, files, code and money. Naka sits between the agent (Claude, Cursor, VS Code, any MCP client) and its tools, and checks every message both ways:
AI agent ⇄ naka ⇄ MCP servers
(Claude, checks (GitHub, Slack, files, mail,
Cursor...) every message or a remote https:// server)
- 🔒 Follows your secrets. A key read through one tool can't leave through another, even base64-encoded, reversed or split up.
- 🪱 Stops AI worms. An injected note can't be copied into emails, comments or chats where the next AI will read it. We haven't found another MCP guard that does this.
- 🧠 Protects the AI's memory. Attacker text can't be written into CLAUDE.md, AGENTS.md, Cursor rules, skills or a memory server, where it would come back every session.
- 📌 Pins every tool. A tool that changes after you approved it is quarantined.
- 🙋 Asks you, in the app. Payments, unlocks and messages to addresses the agent just read pop up a question instead of a guess.
It fails closed, has zero dependencies, and sets up with one command.
Naka (नाका) is Hindi for a checkpoint: the post on the road where every vehicle stops and gets checked before it goes on.
Get started
pip install git+https://github.com/lakshyab20/naka # PyPI release coming
naka install --dry-run # see which servers in Claude/Cursor/VS Code/... would be protected
naka install # protect them (backs up each config; `naka uninstall` restores)
Restart the apps. Every MCP server now runs through Naka. To see it work first:
naka demo --unprotected # a hijacked agent, two servers: 7 attacks succeed
naka demo # the same agent through Naka: every one is stopped
In plain words
New to AI agent security? Naka explained simply, in six pictures →
Scoreboard
Same 40 attacks and 22 everyday tasks, through each guard, scored by what actually reached the tools (details and caveats):
| Guard | Classic MCP attacks stopped | AI worms and memory poisoning stopped | Everyday tasks interrupted |
|---|---|---|---|
| No guard | 0 / 13 | 0 / 27 | 0 / 22 |
| Naka | 13 / 13 | 27 / 27 | 4 / 22 |
Pipelock 3.7.1 (claude-code and strict presets) |
10 / 13 | 0 / 27 | 1 / 22 |
The suites are ours and include attack families other guards don't claim to cover, so read the per-kind breakdown. Pipelock does plenty this test doesn't measure (an HTTP egress proxy, signed receipts). Run it yourself, or add your guard:
naka eval --guard naka --guard "yourguard=yourguard proxy -- {cmd}" -v
What it stops
| Attack | What happens | Naka's rule |
|---|---|---|
| Tool poisoning | A tool's description hides instructions for the model, often in invisible Unicode | poisoned-tool: hidden from the agent, calls refused |
| Rug-pull | A tool is harmless when you approve it, then changes later | rug-pull: every definition is pinned by SHA-256; a change is quarantined |
| Indirect prompt injection | Tool output (a page, an issue, an email) tells the model what to do | injected-response: withheld, or labelled as untrusted in warn mode |
| Injected destinations | The output says "email this to attacker@…" or "transfer to account …" and the agent does it | untrusted-destination: an address, URL, account or ID that came from tool output can't decide where data goes without your OK |
| Data theft | A secret read through one server leaves through another | tainted-flow: tracked across every server in the app, even base64-encoded, reversed, reformatted or split up |
| High-impact actions | After reading untrusted content, the agent pays, unlocks, grants access or deletes | after-untrusted: asks you first |
| AI worms | A hijacked agent copies an injected note into an email reply, a forward, an issue comment, a code comment or team chat, where the next AI reads it and spreads it further | spread: Naka remembers the wording of everything untrusted tools return; a copied note that asks to be passed on can't leave, in several languages, even edited or buried in padding |
| Memory poisoning | The note is written into CLAUDE.md, AGENTS.md, Cursor/Cline/Windsurf rules, skills, a memory server, an MCP config, a git hook or a CI workflow, so it comes back every session | memory-poisoning / memory-write: copied text with a link, command or AI-directed request is blocked; other outside text asks first. Text from your own project files is fine |
| Credential leaks | API keys, tokens or private keys in tool-call arguments | secret-in-args |
| Look-alike tools | A new tool named send_emaіl (Cyrillic і) shadows send_email |
shadow-tool |
Detection covers hidden Unicode, base64, look-alike letters, English plus Hindi/Hinglish, Spanish, French, German and Portuguese phrasings, common credentials, and India-aware PII (PAN, Aadhaar, Luhn-checked card numbers).
Measured, not claimed
naka eval runs attack scenarios and everyday tasks through any MCP guard over real stdio, and scores what actually reached the tools (how it works). It includes the first open test set for AI worms and memory poisoning, with everyday look-alikes (quoting, forwarding, saving notes) that a guard must let through.
| Suite | No guard: attacks stopped | Naka: attacks stopped | Naka: everyday tasks interrupted |
|---|---|---|---|
contagion (AI worms, memory poisoning) |
0 / 27 | 27 / 27 | 1 / 15¹ |
mcp-attacks (poisoning, rug-pulls, theft, injected actions) |
0 / 13 | 13 / 13 | 3 / 7² |
injecagent (1,054 public cases) |
0% | 82.3% | 24.3%³ |
¹ Saving text from an email into the AI's long-term memory asks first. ² A reply to an address read from an email and paying a bill from a list ask first; copying .env into another file is blocked. ³ Every one is a high-impact action (payment, unlock, access grant…) right after reading outside content: a confirmation click, not a block. On 924 real emails, documents and code snippets copied into outgoing messages, the spread rule fired on 0 (block) and 0.3% (ask).
Replaying 1,054 InjecAgent attacks end to end (a fully hijacked agent tries to complete each attack):
| Configuration | Direct harm stopped | Data theft stopped | Legitimate runs interrupted |
|---|---|---|---|
| Detection only (regex) | 0% | 1.7% | 0% |
| Data-flow rules, destinations only | 36.7% | 100% | 1.7% |
| Default (+ ask before high-impact actions) | 63.3% | 100% | 24.3% |
| Strict (ask before every change after untrusted content) | 96.7% | 100% | 98.4% |
The lesson behind the design: detection can't be the main defence. Attackers can always reword, and InjecAgent's polite "Please unlock my front door" doesn't look like an attack. What stops attacks is structure: pinning, data flow, and asking a person before risky actions. Detection is a cheap first filter. naka bench reproduces these numbers and scores detection alone on BIPIA and NotInject.
Confirmation prompts
Some calls aren't clearly wrong, only risky: replying to an address the agent just read, a payment after browsing, a tool's first use. If your app supports MCP elicitation, Naka asks you in the app:
Naka: allow 'send_email' on inbox?
- The email amy.watson@gmail.com came from the output of 'inbox/read_page', not from you.
Arguments: {"to": "amy.watson@gmail.com", "body": "..."}
Apps without prompts get confirm_fallback (block by default, with a message explaining how to adjust).
Use it manually
# Local server
claude mcp add github -- naka wrap --name github -- npx -y @modelcontextprotocol/server-github
# Remote server (Streamable HTTP); $VARS in headers are read from the environment
naka wrap --name linear --url https://mcp.linear.app/mcp --header "Authorization: Bearer $LINEAR_TOKEN"
# Untrusted server: hide your home folder from it
naka wrap --name sketchy --sandbox auto --allow-path ~/projects/app --env SKETCHY_TOKEN -- npx -y some-server
naka pins list # what is pinned, what is waiting for review
naka pins approve --name github add # accept a changed definition after reading it
naka log # recent decisions
naka scan suspicious.txt # scan any text; exit code 1 if flagged (CI-friendly)
naka eval -v # run the attack suites through Naka
Defaults are safe; override them with --config naka.toml:
[policy]
on_first_use = "confirm" # ask before each tool's first call, instead of trust-on-first-use
confirm_after_untrusted = true # strict mode
classifier = "builtin" # second-opinion ML classifier (warn mode by default)
trusted_tools = ["get_contact"] # outputs that may decide destinations
deny_tools = ["delete_repo"]
See naka.example.toml for every option.
How it works
Naka relays MCP's JSON-RPC between the app and each server, local (stdio) or remote (Streamable HTTP). A pure decision engine (firewall.py) inspects every message, and a shared data-flow store (flow.py) remembers where secrets, destinations and untrusted wording came from, across all the servers one app runs. It fails closed: a message that can't be fully inspected is stopped, never passed through. More in ARCHITECTURE.md.
Zero runtime dependencies. Python 3.11+. Tested on Linux and macOS against the official MCP Python SDK (stdio and Streamable HTTP, protocol 2025-11-25, elicitation). 200+ tests, including attacks on Naka itself from five rounds of security review.
Honest limitations
- Detection is bypassable. Rewording gets past regex; the built-in classifier is a bag-of-words model. That's why structural rules carry the weight.
- Action-only injections ("unlock the door") with no injected destination are stopped by default only for high-impact actions (63% in the replay). Strict mode stops 97% at the cost of a prompt on almost every change.
- Data leaving in plain prose isn't caught unless it contains tracked secrets or goes to an injected destination. Secrets split into very small pieces (under 6 characters) aren't recognised.
- Worm and memory rules track exact wording (8-word runs). A note fully rewritten by the model, or a payload hidden in base64, can get past them.
- The sandbox is tested on macOS (it hid
~/.ssh,~/.awsand the Keychains and still ran node, npx, Python and a real MCP server). Linux (bubblewrap) and Docker modes are experimental. - Malicious local server code can act without the model. Use
--sandboxfor servers you don't trust.
See SECURITY.md for the threat model, review history and how to report a vulnerability.
Roadmap
- PyPI release and a one-click installer
- Transformer classifier backend (Prompt Guard 2 / PIGuard via ONNX), measured with
naka bench - Run Naka on agent-egress-bench and more public benchmarks
- Per-tool policies and argument schemas (CaMeL-style capabilities)
- Team dashboard, central policies and alerts (Slack, SIEM)
Ideas and votes are welcome in issues.
Contributing
Naka gets better with every attack someone finds. The most useful contributions:
- A new attack scenario (with an everyday twin that must still pass) in
src/naka/evals/suites.py - A bypass. Report it privately first; see SECURITY.md
- Another guard on the scoreboard, or a correction to how one is scored
- Client support: install paths for more MCP apps
Start with CONTRIBUTING.md. Everyone taking part follows the Code of Conduct.
License
Apache-2.0. Copyright 2026 Lakshya Bhardwaj. The built-in classifier's training data is described in MODEL_CARD.md.
Metadata
Release files for naka 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| naka-0.3.0.tar.gz | 1.3 MB | With provenance | Details for naka-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| naka-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for naka-0.3.0-py3-none-any.whl |
Total release size: 2.7 MB
Release files / naka-0.3.0.tar.gz
| Download URL | naka-0.3.0.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1695cfd1886aaa07821385ee91b9e5ba23ec5b9389d9ed13576207cbf1711693
|
|
BLAKE2b-256 checksum How to use checksums |
76326bec33b19b7b435eb639826c79f8c83fbbc21a237a68676847f7123b8db0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / naka-0.3.0-py3-none-any.whl
| Download URL | naka-0.3.0-py3-none-any.whl |
|---|---|
| Size | 1.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1539927d9c2831369bbc129ae64596b784bbc7176ce96d2a1b99075ae534552
|
|
BLAKE2b-256 checksum How to use checksums |
1578597b60c45d7e26a9318ce99c4a3955a35fc6a797d40fe901a6b4b8567159
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for naka 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for naka-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.