naka 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- naka-0.3.0/LICENSE +179 -0
- naka-0.3.0/PKG-INFO +242 -0
- naka-0.3.0/README.md +213 -0
- naka-0.3.0/pyproject.toml +49 -0
- naka-0.3.0/setup.cfg +4 -0
- naka-0.3.0/src/naka/__init__.py +3 -0
- naka-0.3.0/src/naka/__main__.py +5 -0
- naka-0.3.0/src/naka/bench.py +386 -0
- naka-0.3.0/src/naka/classifier.py +134 -0
- naka-0.3.0/src/naka/cli.py +249 -0
- naka-0.3.0/src/naka/data/__init__.py +1 -0
- naka-0.3.0/src/naka/data/redteam_corpus.json +67 -0
- naka-0.3.0/src/naka/demo/__init__.py +0 -0
- naka-0.3.0/src/naka/demo/evil_server.py +146 -0
- naka-0.3.0/src/naka/demo/run_demo.py +234 -0
- naka-0.3.0/src/naka/demo/workspace_server.py +78 -0
- naka-0.3.0/src/naka/detectors.py +393 -0
- naka-0.3.0/src/naka/evals/__init__.py +0 -0
- naka-0.3.0/src/naka/evals/cli.py +95 -0
- naka-0.3.0/src/naka/evals/core.py +408 -0
- naka-0.3.0/src/naka/evals/server.py +94 -0
- naka-0.3.0/src/naka/evals/suites.py +522 -0
- naka-0.3.0/src/naka/firewall.py +1076 -0
- naka-0.3.0/src/naka/flow.py +382 -0
- naka-0.3.0/src/naka/install.py +226 -0
- naka-0.3.0/src/naka/models/MODEL_CARD.md +34 -0
- naka-0.3.0/src/naka/models/__init__.py +1 -0
- naka-0.3.0/src/naka/models/injection-v1.bin.gz +0 -0
- naka-0.3.0/src/naka/policy.py +105 -0
- naka-0.3.0/src/naka/proxy.py +153 -0
- naka-0.3.0/src/naka/sandbox.py +183 -0
- naka-0.3.0/src/naka/store.py +126 -0
- naka-0.3.0/src/naka/upstream.py +240 -0
- naka-0.3.0/src/naka.egg-info/PKG-INFO +242 -0
- naka-0.3.0/src/naka.egg-info/SOURCES.txt +46 -0
- naka-0.3.0/src/naka.egg-info/dependency_links.txt +1 -0
- naka-0.3.0/src/naka.egg-info/entry_points.txt +2 -0
- naka-0.3.0/src/naka.egg-info/requires.txt +3 -0
- naka-0.3.0/src/naka.egg-info/top_level.txt +1 -0
- naka-0.3.0/tests/test_contagion.py +139 -0
- naka-0.3.0/tests/test_detectors.py +80 -0
- naka-0.3.0/tests/test_e2e.py +79 -0
- naka-0.3.0/tests/test_firewall.py +154 -0
- naka-0.3.0/tests/test_flow.py +229 -0
- naka-0.3.0/tests/test_http.py +113 -0
- naka-0.3.0/tests/test_install.py +97 -0
- naka-0.3.0/tests/test_sandbox.py +95 -0
- naka-0.3.0/tests/test_security.py +582 -0
naka-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 Lakshya Bhardwaj
|
naka-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: naka
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Open-source runtime firewall for AI agents. Stops poisoned tools, rug-pulls, data leaks, AI worms and memory poisoning in MCP traffic.
|
|
5
|
+
Author: Lakshya Bhardwaj
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/lakshyab20/naka
|
|
8
|
+
Project-URL: Documentation, https://github.com/lakshyab20/naka/tree/main/docs
|
|
9
|
+
Project-URL: Issues, https://github.com/lakshyab20/naka/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/lakshyab20/naka/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: mcp,model-context-protocol,ai-security,prompt-injection,llm,agents,firewall,ai-worm,memory-poisoning
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Information Technology
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Security
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<picture>
|
|
32
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/img/brand/wordmark-dark.svg">
|
|
33
|
+
<img alt="Naka" src="docs/img/brand/wordmark-light.svg" height="64">
|
|
34
|
+
</picture>
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
<p align="center"><b>The open-source runtime firewall for AI agents.</b><br>
|
|
38
|
+
Stops poisoned tools, rug-pulls, data theft, AI worms and memory poisoning in the live traffic between your agent and its MCP servers.</p>
|
|
39
|
+
|
|
40
|
+
<p align="center">
|
|
41
|
+
<a href="https://github.com/lakshyab20/naka/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/lakshyab20/naka/actions/workflows/ci.yml/badge.svg"></a>
|
|
42
|
+
<a href="LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/badge/license-Apache--2.0-blue"></a>
|
|
43
|
+
<img alt="Python 3.11+" src="https://img.shields.io/badge/python-3.11%2B-blue">
|
|
44
|
+
<img alt="Zero dependencies" src="https://img.shields.io/badge/dependencies-0-brightgreen">
|
|
45
|
+
<a href="docs/SCOREBOARD.md"><img alt="Scoreboard" src="https://img.shields.io/badge/attacks%20stopped-40%2F40-FF6B35"></a>
|
|
46
|
+
</p>
|
|
47
|
+
|
|
48
|
+
<p align="center">
|
|
49
|
+
<a href="#get-started">Get started</a> ·
|
|
50
|
+
<a href="docs/EXPLAINED.md">Explained simply</a> ·
|
|
51
|
+
<a href="docs/SCOREBOARD.md">Scoreboard</a> ·
|
|
52
|
+
<a href="docs/EVALS.md">Test any guard</a> ·
|
|
53
|
+
<a href="docs/ARCHITECTURE.md">Architecture</a> ·
|
|
54
|
+
<a href="CONTRIBUTING.md">Contribute</a>
|
|
55
|
+
</p>
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
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:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
AI agent ⇄ naka ⇄ MCP servers
|
|
63
|
+
(Claude, checks (GitHub, Slack, files, mail,
|
|
64
|
+
Cursor...) every message or a remote https:// server)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- 🔒 **Follows your secrets.** A key read through one tool can't leave through another, even base64-encoded, reversed or split up.
|
|
68
|
+
- 🪱 **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.*
|
|
69
|
+
- 🧠 **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.
|
|
70
|
+
- 📌 **Pins every tool.** A tool that changes after you approved it is quarantined.
|
|
71
|
+
- 🙋 **Asks you, in the app.** Payments, unlocks and messages to addresses the agent just read pop up a question instead of a guess.
|
|
72
|
+
|
|
73
|
+
It fails closed, has zero dependencies, and sets up with one command.
|
|
74
|
+
|
|
75
|
+
*Naka* (नाका) is Hindi for a checkpoint: the post on the road where every vehicle stops and gets checked before it goes on.
|
|
76
|
+
|
|
77
|
+
<p align="center"><img src="docs/demo.gif" alt="A hijacked agent with two MCP servers: 7 attacks succeed without Naka, all are stopped with it" width="760"></p>
|
|
78
|
+
|
|
79
|
+
## Get started
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pip install git+https://github.com/lakshyab20/naka # PyPI release coming
|
|
83
|
+
naka install --dry-run # see which servers in Claude/Cursor/VS Code/... would be protected
|
|
84
|
+
naka install # protect them (backs up each config; `naka uninstall` restores)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Restart the apps. Every MCP server now runs through Naka. To see it work first:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
naka demo --unprotected # a hijacked agent, two servers: 7 attacks succeed
|
|
91
|
+
naka demo # the same agent through Naka: every one is stopped
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## In plain words
|
|
95
|
+
|
|
96
|
+

|
|
97
|
+
|
|
98
|
+
New to AI agent security? **[Naka explained simply, in six pictures →](docs/EXPLAINED.md)**
|
|
99
|
+
|
|
100
|
+
## Scoreboard
|
|
101
|
+
|
|
102
|
+
Same 40 attacks and 22 everyday tasks, through each guard, scored by what actually reached the tools ([details and caveats](docs/SCOREBOARD.md)):
|
|
103
|
+
|
|
104
|
+
| Guard | Classic MCP attacks stopped | AI worms and memory poisoning stopped | Everyday tasks interrupted |
|
|
105
|
+
|---|---:|---:|---:|
|
|
106
|
+
| No guard | 0 / 13 | 0 / 27 | 0 / 22 |
|
|
107
|
+
| **Naka** | **13 / 13** | **27 / 27** | 4 / 22 |
|
|
108
|
+
| Pipelock 3.7.1 (`claude-code` and `strict` presets) | 10 / 13 | 0 / 27 | 1 / 22 |
|
|
109
|
+
|
|
110
|
+
The suites are ours and include attack families other guards don't claim to cover, so read the [per-kind breakdown](docs/SCOREBOARD.md). Pipelock does plenty this test doesn't measure (an HTTP egress proxy, signed receipts). Run it yourself, or add your guard:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
naka eval --guard naka --guard "yourguard=yourguard proxy -- {cmd}" -v
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## What it stops
|
|
117
|
+
|
|
118
|
+
| Attack | What happens | Naka's rule |
|
|
119
|
+
|---|---|---|
|
|
120
|
+
| **Tool poisoning** | A tool's description hides instructions for the model, often in invisible Unicode | `poisoned-tool`: hidden from the agent, calls refused |
|
|
121
|
+
| **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 |
|
|
122
|
+
| **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 |
|
|
123
|
+
| **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 |
|
|
124
|
+
| **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 |
|
|
125
|
+
| **High-impact actions** | After reading untrusted content, the agent pays, unlocks, grants access or deletes | `after-untrusted`: asks you first |
|
|
126
|
+
| **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 |
|
|
127
|
+
| **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 |
|
|
128
|
+
| **Credential leaks** | API keys, tokens or private keys in tool-call arguments | `secret-in-args` |
|
|
129
|
+
| **Look-alike tools** | A new tool named `send_emaіl` (Cyrillic і) shadows `send_email` | `shadow-tool` |
|
|
130
|
+
|
|
131
|
+
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).
|
|
132
|
+
|
|
133
|
+
## Measured, not claimed
|
|
134
|
+
|
|
135
|
+
**`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](docs/EVALS.md)). 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.
|
|
136
|
+
|
|
137
|
+
| Suite | No guard: attacks stopped | Naka: attacks stopped | Naka: everyday tasks interrupted |
|
|
138
|
+
|---|---:|---:|---:|
|
|
139
|
+
| `contagion` (AI worms, memory poisoning) | 0 / 27 | **27 / 27** | 1 / 15¹ |
|
|
140
|
+
| `mcp-attacks` (poisoning, rug-pulls, theft, injected actions) | 0 / 13 | **13 / 13** | 3 / 7² |
|
|
141
|
+
| `injecagent` (1,054 public cases) | 0% | **82.3%** | 24.3%³ |
|
|
142
|
+
|
|
143
|
+
¹ 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).
|
|
144
|
+
|
|
145
|
+
**Replaying 1,054 InjecAgent attacks end to end** (a fully hijacked agent tries to complete each attack):
|
|
146
|
+
|
|
147
|
+
| Configuration | Direct harm stopped | Data theft stopped | Legitimate runs interrupted |
|
|
148
|
+
|---|---:|---:|---:|
|
|
149
|
+
| Detection only (regex) | 0% | 1.7% | 0% |
|
|
150
|
+
| Data-flow rules, destinations only | 36.7% | **100%** | 1.7% |
|
|
151
|
+
| **Default** (+ ask before high-impact actions) | **63.3%** | **100%** | 24.3% |
|
|
152
|
+
| Strict (ask before every change after untrusted content) | 96.7% | 100% | 98.4% |
|
|
153
|
+
|
|
154
|
+
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.
|
|
155
|
+
|
|
156
|
+
## Confirmation prompts
|
|
157
|
+
|
|
158
|
+
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:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
Naka: allow 'send_email' on inbox?
|
|
162
|
+
- The email amy.watson@gmail.com came from the output of 'inbox/read_page', not from you.
|
|
163
|
+
Arguments: {"to": "amy.watson@gmail.com", "body": "..."}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Apps without prompts get `confirm_fallback` (block by default, with a message explaining how to adjust).
|
|
167
|
+
|
|
168
|
+
## Use it manually
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Local server
|
|
172
|
+
claude mcp add github -- naka wrap --name github -- npx -y @modelcontextprotocol/server-github
|
|
173
|
+
|
|
174
|
+
# Remote server (Streamable HTTP); $VARS in headers are read from the environment
|
|
175
|
+
naka wrap --name linear --url https://mcp.linear.app/mcp --header "Authorization: Bearer $LINEAR_TOKEN"
|
|
176
|
+
|
|
177
|
+
# Untrusted server: hide your home folder from it
|
|
178
|
+
naka wrap --name sketchy --sandbox auto --allow-path ~/projects/app --env SKETCHY_TOKEN -- npx -y some-server
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
naka pins list # what is pinned, what is waiting for review
|
|
183
|
+
naka pins approve --name github add # accept a changed definition after reading it
|
|
184
|
+
naka log # recent decisions
|
|
185
|
+
naka scan suspicious.txt # scan any text; exit code 1 if flagged (CI-friendly)
|
|
186
|
+
naka eval -v # run the attack suites through Naka
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Defaults are safe; override them with `--config naka.toml`:
|
|
190
|
+
|
|
191
|
+
```toml
|
|
192
|
+
[policy]
|
|
193
|
+
on_first_use = "confirm" # ask before each tool's first call, instead of trust-on-first-use
|
|
194
|
+
confirm_after_untrusted = true # strict mode
|
|
195
|
+
classifier = "builtin" # second-opinion ML classifier (warn mode by default)
|
|
196
|
+
trusted_tools = ["get_contact"] # outputs that may decide destinations
|
|
197
|
+
deny_tools = ["delete_repo"]
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
See [`naka.example.toml`](naka.example.toml) for every option.
|
|
201
|
+
|
|
202
|
+
## How it works
|
|
203
|
+
|
|
204
|
+
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](docs/ARCHITECTURE.md).
|
|
205
|
+
|
|
206
|
+
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.
|
|
207
|
+
|
|
208
|
+
## Honest limitations
|
|
209
|
+
|
|
210
|
+
- **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.
|
|
211
|
+
- **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.
|
|
212
|
+
- **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.
|
|
213
|
+
- **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.
|
|
214
|
+
- **The sandbox is tested on macOS** (it hid `~/.ssh`, `~/.aws` and the Keychains and still ran node, npx, Python and a real MCP server). Linux (bubblewrap) and Docker modes are experimental.
|
|
215
|
+
- **Malicious local server code** can act without the model. Use `--sandbox` for servers you don't trust.
|
|
216
|
+
|
|
217
|
+
See [SECURITY.md](SECURITY.md) for the threat model, review history and how to report a vulnerability.
|
|
218
|
+
|
|
219
|
+
## Roadmap
|
|
220
|
+
|
|
221
|
+
- PyPI release and a one-click installer
|
|
222
|
+
- Transformer classifier backend (Prompt Guard 2 / PIGuard via ONNX), measured with `naka bench`
|
|
223
|
+
- Run Naka on [agent-egress-bench](https://github.com/luckyPipewrench/agent-egress-bench) and more public benchmarks
|
|
224
|
+
- Per-tool policies and argument schemas (CaMeL-style capabilities)
|
|
225
|
+
- Team dashboard, central policies and alerts (Slack, SIEM)
|
|
226
|
+
|
|
227
|
+
Ideas and votes are welcome in [issues](https://github.com/lakshyab20/naka/issues).
|
|
228
|
+
|
|
229
|
+
## Contributing
|
|
230
|
+
|
|
231
|
+
Naka gets better with every attack someone finds. The most useful contributions:
|
|
232
|
+
|
|
233
|
+
- **A new attack scenario** (with an everyday twin that must still pass) in [`src/naka/evals/suites.py`](src/naka/evals/suites.py)
|
|
234
|
+
- **A bypass.** Report it privately first; see [SECURITY.md](SECURITY.md)
|
|
235
|
+
- **Another guard on the scoreboard**, or a correction to how one is scored
|
|
236
|
+
- **Client support**: install paths for more MCP apps
|
|
237
|
+
|
|
238
|
+
Start with [CONTRIBUTING.md](CONTRIBUTING.md). Everyone taking part follows the [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
239
|
+
|
|
240
|
+
## License
|
|
241
|
+
|
|
242
|
+
[Apache-2.0](LICENSE). Copyright 2026 Lakshya Bhardwaj. The built-in classifier's training data is described in [`MODEL_CARD.md`](src/naka/models/MODEL_CARD.md).
|
naka-0.3.0/README.md
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/img/brand/wordmark-dark.svg">
|
|
4
|
+
<img alt="Naka" src="docs/img/brand/wordmark-light.svg" height="64">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center"><b>The open-source runtime firewall for AI agents.</b><br>
|
|
9
|
+
Stops poisoned tools, rug-pulls, data theft, AI worms and memory poisoning in the live traffic between your agent and its MCP servers.</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://github.com/lakshyab20/naka/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/lakshyab20/naka/actions/workflows/ci.yml/badge.svg"></a>
|
|
13
|
+
<a href="LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/badge/license-Apache--2.0-blue"></a>
|
|
14
|
+
<img alt="Python 3.11+" src="https://img.shields.io/badge/python-3.11%2B-blue">
|
|
15
|
+
<img alt="Zero dependencies" src="https://img.shields.io/badge/dependencies-0-brightgreen">
|
|
16
|
+
<a href="docs/SCOREBOARD.md"><img alt="Scoreboard" src="https://img.shields.io/badge/attacks%20stopped-40%2F40-FF6B35"></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<a href="#get-started">Get started</a> ·
|
|
21
|
+
<a href="docs/EXPLAINED.md">Explained simply</a> ·
|
|
22
|
+
<a href="docs/SCOREBOARD.md">Scoreboard</a> ·
|
|
23
|
+
<a href="docs/EVALS.md">Test any guard</a> ·
|
|
24
|
+
<a href="docs/ARCHITECTURE.md">Architecture</a> ·
|
|
25
|
+
<a href="CONTRIBUTING.md">Contribute</a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
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:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
AI agent ⇄ naka ⇄ MCP servers
|
|
34
|
+
(Claude, checks (GitHub, Slack, files, mail,
|
|
35
|
+
Cursor...) every message or a remote https:// server)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- 🔒 **Follows your secrets.** A key read through one tool can't leave through another, even base64-encoded, reversed or split up.
|
|
39
|
+
- 🪱 **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.*
|
|
40
|
+
- 🧠 **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.
|
|
41
|
+
- 📌 **Pins every tool.** A tool that changes after you approved it is quarantined.
|
|
42
|
+
- 🙋 **Asks you, in the app.** Payments, unlocks and messages to addresses the agent just read pop up a question instead of a guess.
|
|
43
|
+
|
|
44
|
+
It fails closed, has zero dependencies, and sets up with one command.
|
|
45
|
+
|
|
46
|
+
*Naka* (नाका) is Hindi for a checkpoint: the post on the road where every vehicle stops and gets checked before it goes on.
|
|
47
|
+
|
|
48
|
+
<p align="center"><img src="docs/demo.gif" alt="A hijacked agent with two MCP servers: 7 attacks succeed without Naka, all are stopped with it" width="760"></p>
|
|
49
|
+
|
|
50
|
+
## Get started
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install git+https://github.com/lakshyab20/naka # PyPI release coming
|
|
54
|
+
naka install --dry-run # see which servers in Claude/Cursor/VS Code/... would be protected
|
|
55
|
+
naka install # protect them (backs up each config; `naka uninstall` restores)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Restart the apps. Every MCP server now runs through Naka. To see it work first:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
naka demo --unprotected # a hijacked agent, two servers: 7 attacks succeed
|
|
62
|
+
naka demo # the same agent through Naka: every one is stopped
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## In plain words
|
|
66
|
+
|
|
67
|
+

|
|
68
|
+
|
|
69
|
+
New to AI agent security? **[Naka explained simply, in six pictures →](docs/EXPLAINED.md)**
|
|
70
|
+
|
|
71
|
+
## Scoreboard
|
|
72
|
+
|
|
73
|
+
Same 40 attacks and 22 everyday tasks, through each guard, scored by what actually reached the tools ([details and caveats](docs/SCOREBOARD.md)):
|
|
74
|
+
|
|
75
|
+
| Guard | Classic MCP attacks stopped | AI worms and memory poisoning stopped | Everyday tasks interrupted |
|
|
76
|
+
|---|---:|---:|---:|
|
|
77
|
+
| No guard | 0 / 13 | 0 / 27 | 0 / 22 |
|
|
78
|
+
| **Naka** | **13 / 13** | **27 / 27** | 4 / 22 |
|
|
79
|
+
| Pipelock 3.7.1 (`claude-code` and `strict` presets) | 10 / 13 | 0 / 27 | 1 / 22 |
|
|
80
|
+
|
|
81
|
+
The suites are ours and include attack families other guards don't claim to cover, so read the [per-kind breakdown](docs/SCOREBOARD.md). Pipelock does plenty this test doesn't measure (an HTTP egress proxy, signed receipts). Run it yourself, or add your guard:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
naka eval --guard naka --guard "yourguard=yourguard proxy -- {cmd}" -v
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## What it stops
|
|
88
|
+
|
|
89
|
+
| Attack | What happens | Naka's rule |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| **Tool poisoning** | A tool's description hides instructions for the model, often in invisible Unicode | `poisoned-tool`: hidden from the agent, calls refused |
|
|
92
|
+
| **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 |
|
|
93
|
+
| **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 |
|
|
94
|
+
| **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 |
|
|
95
|
+
| **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 |
|
|
96
|
+
| **High-impact actions** | After reading untrusted content, the agent pays, unlocks, grants access or deletes | `after-untrusted`: asks you first |
|
|
97
|
+
| **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 |
|
|
98
|
+
| **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 |
|
|
99
|
+
| **Credential leaks** | API keys, tokens or private keys in tool-call arguments | `secret-in-args` |
|
|
100
|
+
| **Look-alike tools** | A new tool named `send_emaіl` (Cyrillic і) shadows `send_email` | `shadow-tool` |
|
|
101
|
+
|
|
102
|
+
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).
|
|
103
|
+
|
|
104
|
+
## Measured, not claimed
|
|
105
|
+
|
|
106
|
+
**`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](docs/EVALS.md)). 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.
|
|
107
|
+
|
|
108
|
+
| Suite | No guard: attacks stopped | Naka: attacks stopped | Naka: everyday tasks interrupted |
|
|
109
|
+
|---|---:|---:|---:|
|
|
110
|
+
| `contagion` (AI worms, memory poisoning) | 0 / 27 | **27 / 27** | 1 / 15¹ |
|
|
111
|
+
| `mcp-attacks` (poisoning, rug-pulls, theft, injected actions) | 0 / 13 | **13 / 13** | 3 / 7² |
|
|
112
|
+
| `injecagent` (1,054 public cases) | 0% | **82.3%** | 24.3%³ |
|
|
113
|
+
|
|
114
|
+
¹ 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).
|
|
115
|
+
|
|
116
|
+
**Replaying 1,054 InjecAgent attacks end to end** (a fully hijacked agent tries to complete each attack):
|
|
117
|
+
|
|
118
|
+
| Configuration | Direct harm stopped | Data theft stopped | Legitimate runs interrupted |
|
|
119
|
+
|---|---:|---:|---:|
|
|
120
|
+
| Detection only (regex) | 0% | 1.7% | 0% |
|
|
121
|
+
| Data-flow rules, destinations only | 36.7% | **100%** | 1.7% |
|
|
122
|
+
| **Default** (+ ask before high-impact actions) | **63.3%** | **100%** | 24.3% |
|
|
123
|
+
| Strict (ask before every change after untrusted content) | 96.7% | 100% | 98.4% |
|
|
124
|
+
|
|
125
|
+
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.
|
|
126
|
+
|
|
127
|
+
## Confirmation prompts
|
|
128
|
+
|
|
129
|
+
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:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
Naka: allow 'send_email' on inbox?
|
|
133
|
+
- The email amy.watson@gmail.com came from the output of 'inbox/read_page', not from you.
|
|
134
|
+
Arguments: {"to": "amy.watson@gmail.com", "body": "..."}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Apps without prompts get `confirm_fallback` (block by default, with a message explaining how to adjust).
|
|
138
|
+
|
|
139
|
+
## Use it manually
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Local server
|
|
143
|
+
claude mcp add github -- naka wrap --name github -- npx -y @modelcontextprotocol/server-github
|
|
144
|
+
|
|
145
|
+
# Remote server (Streamable HTTP); $VARS in headers are read from the environment
|
|
146
|
+
naka wrap --name linear --url https://mcp.linear.app/mcp --header "Authorization: Bearer $LINEAR_TOKEN"
|
|
147
|
+
|
|
148
|
+
# Untrusted server: hide your home folder from it
|
|
149
|
+
naka wrap --name sketchy --sandbox auto --allow-path ~/projects/app --env SKETCHY_TOKEN -- npx -y some-server
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
naka pins list # what is pinned, what is waiting for review
|
|
154
|
+
naka pins approve --name github add # accept a changed definition after reading it
|
|
155
|
+
naka log # recent decisions
|
|
156
|
+
naka scan suspicious.txt # scan any text; exit code 1 if flagged (CI-friendly)
|
|
157
|
+
naka eval -v # run the attack suites through Naka
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Defaults are safe; override them with `--config naka.toml`:
|
|
161
|
+
|
|
162
|
+
```toml
|
|
163
|
+
[policy]
|
|
164
|
+
on_first_use = "confirm" # ask before each tool's first call, instead of trust-on-first-use
|
|
165
|
+
confirm_after_untrusted = true # strict mode
|
|
166
|
+
classifier = "builtin" # second-opinion ML classifier (warn mode by default)
|
|
167
|
+
trusted_tools = ["get_contact"] # outputs that may decide destinations
|
|
168
|
+
deny_tools = ["delete_repo"]
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
See [`naka.example.toml`](naka.example.toml) for every option.
|
|
172
|
+
|
|
173
|
+
## How it works
|
|
174
|
+
|
|
175
|
+
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](docs/ARCHITECTURE.md).
|
|
176
|
+
|
|
177
|
+
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.
|
|
178
|
+
|
|
179
|
+
## Honest limitations
|
|
180
|
+
|
|
181
|
+
- **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.
|
|
182
|
+
- **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.
|
|
183
|
+
- **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.
|
|
184
|
+
- **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.
|
|
185
|
+
- **The sandbox is tested on macOS** (it hid `~/.ssh`, `~/.aws` and the Keychains and still ran node, npx, Python and a real MCP server). Linux (bubblewrap) and Docker modes are experimental.
|
|
186
|
+
- **Malicious local server code** can act without the model. Use `--sandbox` for servers you don't trust.
|
|
187
|
+
|
|
188
|
+
See [SECURITY.md](SECURITY.md) for the threat model, review history and how to report a vulnerability.
|
|
189
|
+
|
|
190
|
+
## Roadmap
|
|
191
|
+
|
|
192
|
+
- PyPI release and a one-click installer
|
|
193
|
+
- Transformer classifier backend (Prompt Guard 2 / PIGuard via ONNX), measured with `naka bench`
|
|
194
|
+
- Run Naka on [agent-egress-bench](https://github.com/luckyPipewrench/agent-egress-bench) and more public benchmarks
|
|
195
|
+
- Per-tool policies and argument schemas (CaMeL-style capabilities)
|
|
196
|
+
- Team dashboard, central policies and alerts (Slack, SIEM)
|
|
197
|
+
|
|
198
|
+
Ideas and votes are welcome in [issues](https://github.com/lakshyab20/naka/issues).
|
|
199
|
+
|
|
200
|
+
## Contributing
|
|
201
|
+
|
|
202
|
+
Naka gets better with every attack someone finds. The most useful contributions:
|
|
203
|
+
|
|
204
|
+
- **A new attack scenario** (with an everyday twin that must still pass) in [`src/naka/evals/suites.py`](src/naka/evals/suites.py)
|
|
205
|
+
- **A bypass.** Report it privately first; see [SECURITY.md](SECURITY.md)
|
|
206
|
+
- **Another guard on the scoreboard**, or a correction to how one is scored
|
|
207
|
+
- **Client support**: install paths for more MCP apps
|
|
208
|
+
|
|
209
|
+
Start with [CONTRIBUTING.md](CONTRIBUTING.md). Everyone taking part follows the [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
210
|
+
|
|
211
|
+
## License
|
|
212
|
+
|
|
213
|
+
[Apache-2.0](LICENSE). Copyright 2026 Lakshya Bhardwaj. The built-in classifier's training data is described in [`MODEL_CARD.md`](src/naka/models/MODEL_CARD.md).
|