rulebound 0.1.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.
- rulebound-0.1.0/.gitignore +22 -0
- rulebound-0.1.0/CHANGELOG.md +29 -0
- rulebound-0.1.0/CITATION.cff +32 -0
- rulebound-0.1.0/LICENSE +202 -0
- rulebound-0.1.0/NOTICE +8 -0
- rulebound-0.1.0/PKG-INFO +313 -0
- rulebound-0.1.0/README.md +281 -0
- rulebound-0.1.0/docs/demo.svg +9 -0
- rulebound-0.1.0/docs/methodology.md +83 -0
- rulebound-0.1.0/docs/policy.md +147 -0
- rulebound-0.1.0/examples/mcp-client-config.json +13 -0
- rulebound-0.1.0/examples/policy-isolated-autonomous.toml +59 -0
- rulebound-0.1.0/examples/policy.toml +81 -0
- rulebound-0.1.0/examples/python_agent.py +40 -0
- rulebound-0.1.0/pyproject.toml +66 -0
- rulebound-0.1.0/src/rulebound/__init__.py +26 -0
- rulebound-0.1.0/src/rulebound/__main__.py +5 -0
- rulebound-0.1.0/src/rulebound/approval.py +192 -0
- rulebound-0.1.0/src/rulebound/audit.py +303 -0
- rulebound-0.1.0/src/rulebound/cli.py +406 -0
- rulebound-0.1.0/src/rulebound/data/example_policy.toml +81 -0
- rulebound-0.1.0/src/rulebound/data/tlds.txt +1433 -0
- rulebound-0.1.0/src/rulebound/engine.py +449 -0
- rulebound-0.1.0/src/rulebound/execwrap.py +72 -0
- rulebound-0.1.0/src/rulebound/health.py +111 -0
- rulebound-0.1.0/src/rulebound/hooks.py +57 -0
- rulebound-0.1.0/src/rulebound/mcp_proxy.py +234 -0
- rulebound-0.1.0/src/rulebound/policy.py +542 -0
- rulebound-0.1.0/src/rulebound/py.typed +0 -0
- rulebound-0.1.0/src/rulebound/report.py +229 -0
- rulebound-0.1.0/src/rulebound/scope.py +264 -0
- rulebound-0.1.0/src/rulebound/targets.py +280 -0
- rulebound-0.1.0/tests/fixtures/fake_mcp_server.py +54 -0
- rulebound-0.1.0/tests/fixtures/stubborn_mcp_server.py +19 -0
- rulebound-0.1.0/tests/interop/mcp_server_interop.py +165 -0
- rulebound-0.1.0/tests/support.py +91 -0
- rulebound-0.1.0/tests/test_audit.py +147 -0
- rulebound-0.1.0/tests/test_engine.py +247 -0
- rulebound-0.1.0/tests/test_exec.py +75 -0
- rulebound-0.1.0/tests/test_health.py +94 -0
- rulebound-0.1.0/tests/test_mcp_proxy.py +172 -0
- rulebound-0.1.0/tests/test_policy.py +106 -0
- rulebound-0.1.0/tests/test_report_cli.py +169 -0
- rulebound-0.1.0/tests/test_scope.py +136 -0
- rulebound-0.1.0/tests/test_targets.py +108 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.eggs/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
.venv/
|
|
9
|
+
venv/
|
|
10
|
+
.pytest_cache/
|
|
11
|
+
.ruff_cache/
|
|
12
|
+
.mypy_cache/
|
|
13
|
+
.coverage
|
|
14
|
+
htmlcov/
|
|
15
|
+
|
|
16
|
+
# rulebound runtime state (audit logs, kill switch, pending approvals)
|
|
17
|
+
.rulebound/
|
|
18
|
+
|
|
19
|
+
# OS / editors
|
|
20
|
+
.DS_Store
|
|
21
|
+
.idea/
|
|
22
|
+
.vscode/
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-11-30
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- End-to-end interop test against a real MCP server (`tests/interop/`, `MCP interop` workflow).
|
|
12
|
+
- `mcp-proxy` stops the server's whole process group on client disconnect or SIGINT/SIGTERM
|
|
13
|
+
(grace period: `RULEBOUND_MCP_SHUTDOWN_GRACE`).
|
|
14
|
+
- `rulebound init` writes an engagement window that starts today and lasts 30 days.
|
|
15
|
+
- Policy files (TOML, JSON, optional YAML) describing an engagement: authorization record,
|
|
16
|
+
time window, environment, scope (CIDRs, IPv6, hosts, `*.` wildcards, URL prefixes,
|
|
17
|
+
exclusions), graduated autonomy (`supervised`, `semi`, `autonomous`), action classes with
|
|
18
|
+
risk levels, approvals, rate limits, kill switch, health checks, hooks and audit settings.
|
|
19
|
+
- `rulebound validate` with path-qualified errors and warnings; `rulebound init` template.
|
|
20
|
+
- Decision engine with a fixed evaluation order (stop → window → prohibited class → scope →
|
|
21
|
+
escalation conditions → rate limits → autonomy) and heuristic target extraction from tool
|
|
22
|
+
arguments and command lines.
|
|
23
|
+
- Enforcement points: Python API (`Guard.check/authorize/run/wrap`), `rulebound exec`
|
|
24
|
+
command wrapper, `rulebound mcp-proxy` stdio proxy for MCP servers, `rulebound check` dry run.
|
|
25
|
+
- Approvals on the controlling terminal or through files (`rulebound pending/approve/reject`).
|
|
26
|
+
- Kill switch (`stop` / `resume`), denial breaker, health monitor (`health`, `watch`) and
|
|
27
|
+
lifecycle hooks (`start` / `end`, `on_stop`).
|
|
28
|
+
- Hash-chained JSONL audit trail with optional HMAC key, redaction, `audit verify` / `audit head`.
|
|
29
|
+
- `rulebound report`: Markdown/JSON engagement evidence report with operational metrics.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use rulebound in your work, please cite the software and the paper that describes its methodology."
|
|
3
|
+
title: "rulebound: rules of engagement for AI security agents"
|
|
4
|
+
type: software
|
|
5
|
+
version: 0.1.0
|
|
6
|
+
date-released: 2026-11-30
|
|
7
|
+
license: Apache-2.0
|
|
8
|
+
repository-code: "https://github.com/rajyavardhan01/rulebound"
|
|
9
|
+
keywords:
|
|
10
|
+
- AI security
|
|
11
|
+
- autonomous penetration testing
|
|
12
|
+
- rules of engagement
|
|
13
|
+
- MCP
|
|
14
|
+
- audit logging
|
|
15
|
+
authors:
|
|
16
|
+
- family-names: Handa
|
|
17
|
+
given-names: Rajyavardhan
|
|
18
|
+
orcid: "https://orcid.org/0000-0002-5247-7880"
|
|
19
|
+
references:
|
|
20
|
+
- type: article
|
|
21
|
+
title: "Automating Cyber Offense Simulations with Machine Learning: Advancements in AI-Augmented Penetration Testing"
|
|
22
|
+
authors:
|
|
23
|
+
- family-names: Handa
|
|
24
|
+
given-names: Rajyavardhan
|
|
25
|
+
orcid: "https://orcid.org/0000-0002-5247-7880"
|
|
26
|
+
journal: "Computer Fraud and Security"
|
|
27
|
+
year: 2025
|
|
28
|
+
volume: "2025"
|
|
29
|
+
issue: "2"
|
|
30
|
+
start: 1944
|
|
31
|
+
end: 1951
|
|
32
|
+
doi: "10.52710/cfs.831"
|
rulebound-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
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
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
rulebound-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
rulebound
|
|
2
|
+
Copyright 2026 Rajyavardhan Handa
|
|
3
|
+
|
|
4
|
+
This product includes software developed by Rajyavardhan Handa
|
|
5
|
+
(https://github.com/rajyavardhan01).
|
|
6
|
+
|
|
7
|
+
src/rulebound/data/tlds.txt is derived from the list of top-level domains
|
|
8
|
+
published by IANA (https://data.iana.org/TLD/tlds-alpha-by-domain.txt).
|
rulebound-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: rulebound
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Rules of engagement for AI security agents: scope, autonomy levels, approvals, kill switch and a tamper-evident audit trail, enforced at the tool-call boundary.
|
|
5
|
+
Project-URL: Homepage, https://github.com/rajyavardhan01/rulebound
|
|
6
|
+
Project-URL: Repository, https://github.com/rajyavardhan01/rulebound
|
|
7
|
+
Project-URL: Issues, https://github.com/rajyavardhan01/rulebound/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/rajyavardhan01/rulebound/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Rajyavardhan Handa
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: NOTICE
|
|
13
|
+
Keywords: ai-agents,ai-safety,audit-log,guardrails,llm-security,mcp,penetration-testing,red-team,rules-of-engagement,security
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Environment :: Console
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Intended Audience :: Information Technology
|
|
18
|
+
Classifier: Operating System :: MacOS
|
|
19
|
+
Classifier: Operating System :: POSIX
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
26
|
+
Classifier: Topic :: Security
|
|
27
|
+
Classifier: Typing :: Typed
|
|
28
|
+
Requires-Python: >=3.11
|
|
29
|
+
Provides-Extra: yaml
|
|
30
|
+
Requires-Dist: pyyaml>=6; extra == 'yaml'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# rulebound — rules of engagement for AI security agents
|
|
34
|
+
|
|
35
|
+
[](https://github.com/rajyavardhan01/rulebound/actions/workflows/ci.yml)
|
|
36
|
+
[](https://github.com/rajyavardhan01/rulebound/actions/workflows/interop.yml)
|
|
37
|
+
[](LICENSE)
|
|
38
|
+

|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
<p align="center"><img src="docs/demo.svg" alt="rulebound allowing an in-scope request, denying an out-of-scope one, escalating an exploit tool and verifying the audit chain" width="860"></p>
|
|
42
|
+
|
|
43
|
+
**Scope, autonomy levels, approvals, kill switch and a tamper-evident audit trail —
|
|
44
|
+
enforced at the tool-call boundary (MCP proxy, CLI wrapper, Python API). Zero dependencies.**
|
|
45
|
+
|
|
46
|
+
Status: alpha (v0.1.0).
|
|
47
|
+
|
|
48
|
+
## Why
|
|
49
|
+
|
|
50
|
+
AI agents are increasingly given security tools: scanners, HTTP clients, exploitation
|
|
51
|
+
frameworks, shells. Whatever plans the agent makes, the *rules of engagement* must hold:
|
|
52
|
+
only authorized targets, only inside the authorized window, risky actions approved by a
|
|
53
|
+
named human, and a reliable way to stop everything — with evidence afterwards that all of
|
|
54
|
+
this was true.
|
|
55
|
+
|
|
56
|
+
rulebound puts those rules in one policy file and enforces them on every action before it
|
|
57
|
+
runs:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
agent ──► tool call ──► rulebound ──► allow ──► tool / MCP server / command
|
|
61
|
+
│
|
|
62
|
+
├──► deny (out of scope, outside window, prohibited, stopped…)
|
|
63
|
+
├──► escalate (needs a human: tty or file-based approval)
|
|
64
|
+
└──► audit (hash-chained JSONL + evidence report)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Quickstart
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install git+https://github.com/rajyavardhan01/rulebound
|
|
71
|
+
# or, from a clone (no dependencies needed):
|
|
72
|
+
PYTHONPATH=src python3 -m rulebound --help
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
A 30-second offline demo (real output):
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
$ rulebound init
|
|
79
|
+
wrote rulebound.toml — edit the engagement, scope and action classes, then run `rulebound validate rulebound.toml`
|
|
80
|
+
$ rulebound validate
|
|
81
|
+
rulebound.toml: OK
|
|
82
|
+
|
|
83
|
+
$ rulebound check --tool http_get --args '{"url": "https://app.staging.example.com/login"}'
|
|
84
|
+
ALLOW http_get [class=recon risk=low autonomy=semi]
|
|
85
|
+
targets: https://app.staging.example.com/login
|
|
86
|
+
- pre-approved action class 'recon', target(s) in scope
|
|
87
|
+
|
|
88
|
+
$ rulebound check --tool curl -- -s https://unrelated.example.net/
|
|
89
|
+
DENY curl [class=recon risk=low autonomy=semi]
|
|
90
|
+
targets: https://unrelated.example.net/
|
|
91
|
+
- target https://unrelated.example.net/ is not in scope
|
|
92
|
+
|
|
93
|
+
$ rulebound check --tool sqlmap -- -u "https://app.example.com/api/items?id=1"
|
|
94
|
+
ESCALATE sqlmap [class=exploit risk=high autonomy=semi]
|
|
95
|
+
targets: https://app.example.com/api/items?id=1
|
|
96
|
+
- action class 'exploit' is not pre-approved
|
|
97
|
+
|
|
98
|
+
$ rulebound exec --tool http_get -- echo https://app.staging.example.com/health
|
|
99
|
+
https://app.staging.example.com/health
|
|
100
|
+
$ rulebound exec --tool nmap -- echo -sV 10.20.5.0/24
|
|
101
|
+
rulebound: blocked nmap: target 10.20.5.0/24 is excluded by scope rule '10.20.5.10' # exit 126
|
|
102
|
+
|
|
103
|
+
$ rulebound stop --reason "target latency spike"
|
|
104
|
+
kill switch engaged: target latency spike
|
|
105
|
+
$ rulebound check --tool http_get --args '{"url": "https://app.staging.example.com/login"}'
|
|
106
|
+
DENY http_get [class=recon risk=low autonomy=semi]
|
|
107
|
+
targets: https://app.staging.example.com/login
|
|
108
|
+
- engagement is stopped: target latency spike
|
|
109
|
+
$ rulebound resume --by jane
|
|
110
|
+
kill switch cleared
|
|
111
|
+
|
|
112
|
+
$ rulebound audit verify
|
|
113
|
+
OK: 9 entries, chain intact (head seq=9 hash=b29a38064d2bfc2ded7232bb7de4b87f86cbbecf2c07a4ed7a46d3c76d7df5b1)
|
|
114
|
+
$ rulebound report # Markdown evidence report (or --format json)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Features
|
|
118
|
+
|
|
119
|
+
- **One policy file** (TOML, JSON or YAML) for the engagement: who authorized it, the
|
|
120
|
+
window, the environment, the scope, action classes and risk, approvals, limits, stop
|
|
121
|
+
conditions, hooks and audit settings. `rulebound validate` reports errors with paths.
|
|
122
|
+
- **Scope** — CIDRs (IPv4/IPv6), IPs, hosts with optional port, `*.` wildcards (subdomains
|
|
123
|
+
only), URL prefixes; exclusions always win, on any overlap (scanning a /24 that contains
|
|
124
|
+
an excluded host is denied). Hostnames are never resolved.
|
|
125
|
+
- **Graduated autonomy** — `supervised` (every action approved), `semi` (pre-approved
|
|
126
|
+
classes run, others escalate, critical always escalates), `autonomous` (only honored in
|
|
127
|
+
an `isolated` environment). Unknown actions never run unattended.
|
|
128
|
+
- **Approvals** — on the controlling terminal (works under MCP stdio) or through files
|
|
129
|
+
(`rulebound pending`, `approve <id>`, `reject <id>`), with named approvers and timeouts.
|
|
130
|
+
- **Enforcement points**
|
|
131
|
+
- `rulebound mcp-proxy -- <server command>`: wraps any MCP stdio server; blocked
|
|
132
|
+
`tools/call` requests are answered with an error result and never reach the server.
|
|
133
|
+
- `rulebound exec -- <command>`: authorizes a command line, runs it without a shell, and
|
|
134
|
+
terminates it if the engagement stops.
|
|
135
|
+
- Python API: `Guard.authorize()`, `Guard.run()`, `@guard.wrap("tool")`.
|
|
136
|
+
- `rulebound check`: dry run for CI, tests and policy development.
|
|
137
|
+
- **Stop conditions** — kill switch file shared by every process, `stop` / `resume`,
|
|
138
|
+
health checks (status and latency) that suspend the engagement, a breaker that trips after
|
|
139
|
+
repeated denials, and `on_stop` hooks for restore/notify.
|
|
140
|
+
- **Rate limits** — global and per action class, persisted through the audit log so they
|
|
141
|
+
hold across separate processes.
|
|
142
|
+
- **Tamper-evident audit trail** — append-only JSON Lines, SHA-256 hash chain (or
|
|
143
|
+
HMAC-SHA-256 with a key), redaction of secrets, `audit verify` and `audit head`.
|
|
144
|
+
- **Evidence report** — engagement metadata, policy hash, chain status, decisions by
|
|
145
|
+
verdict/class/risk, targets touched, blocked out-of-scope attempts, escalations with
|
|
146
|
+
approver and latency, stop events, operational metrics.
|
|
147
|
+
|
|
148
|
+
## Usage
|
|
149
|
+
|
|
150
|
+
### Wrap an MCP server
|
|
151
|
+
|
|
152
|
+
Point your MCP client at rulebound instead of the server, and put the real server command
|
|
153
|
+
after `--` (see [`examples/mcp-client-config.json`](examples/mcp-client-config.json)):
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"mcpServers": {
|
|
158
|
+
"security-tools": {
|
|
159
|
+
"command": "rulebound",
|
|
160
|
+
"args": ["mcp-proxy", "--policy", "/absolute/path/to/policy.toml", "--",
|
|
161
|
+
"python3", "-m", "my_security_tools_server"]
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Each `tools/call` is classified by tool name, its arguments are scanned for targets, and the
|
|
168
|
+
call is allowed, denied or escalated. The proxy also records `initialize`, the tool list
|
|
169
|
+
(flagging tools that match no action class) and session start/stop.
|
|
170
|
+
|
|
171
|
+
The server runs in its own process group. When the client disconnects, or the proxy receives
|
|
172
|
+
SIGINT or SIGTERM, the whole group is stopped (SIGTERM, then SIGKILL), so wrappers such as
|
|
173
|
+
`npx` can't leave the real server running. Set `RULEBOUND_MCP_SHUTDOWN_GRACE` (default `5`
|
|
174
|
+
seconds) to control how long each step waits.
|
|
175
|
+
|
|
176
|
+
### Guard a command
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
rulebound exec --policy policy.toml -- nmap -sV 10.20.1.0/24
|
|
180
|
+
rulebound exec --policy policy.toml --tool web_scan -- nuclei -u https://web.staging.example.com
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
The action name is the command's basename unless `--tool` is given. Exit status is the
|
|
184
|
+
command's own, `126` when blocked, `127` when not found.
|
|
185
|
+
|
|
186
|
+
### Guard Python tools
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from rulebound import ActionBlocked, Guard
|
|
190
|
+
|
|
191
|
+
guard = Guard.from_file("policy.toml")
|
|
192
|
+
|
|
193
|
+
@guard.wrap("http_get")
|
|
194
|
+
def http_get(url: str) -> str:
|
|
195
|
+
...
|
|
196
|
+
|
|
197
|
+
try:
|
|
198
|
+
http_get(url="https://unrelated.example.net/")
|
|
199
|
+
except ActionBlocked as exc:
|
|
200
|
+
print(exc.decision.reasons) # ['target https://unrelated.example.net/ is not in scope']
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
See [`examples/python_agent.py`](examples/python_agent.py).
|
|
204
|
+
|
|
205
|
+
### Approvals in file mode
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
rulebound pending --policy policy.toml
|
|
209
|
+
rulebound approve 3f9c2a1b7e44 --policy policy.toml --by jane --note "change window confirmed"
|
|
210
|
+
rulebound reject 3f9c2a1b7e44 --policy policy.toml --by jane
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### CLI reference
|
|
214
|
+
|
|
215
|
+
| Command | Purpose |
|
|
216
|
+
|---|---|
|
|
217
|
+
| `init [PATH]` | write an example policy |
|
|
218
|
+
| `validate [POLICY]` | validate a policy (exit 2 on errors) |
|
|
219
|
+
| `check --tool T [--args JSON \| -- ARGV…]` | dry-run decision (exit 0 allow, 1 deny, 3 escalate) |
|
|
220
|
+
| `exec [--tool T] -- CMD…` | authorize and run a command |
|
|
221
|
+
| `mcp-proxy -- SERVER_CMD…` | enforce the policy on an MCP stdio server |
|
|
222
|
+
| `pending`, `approve ID`, `reject ID` | file-mode approvals |
|
|
223
|
+
| `stop [--reason]`, `resume --by NAME` | kill switch |
|
|
224
|
+
| `start`, `end` | record the engagement lifecycle and run hooks |
|
|
225
|
+
| `health`, `watch` | probe health checks once / continuously (trips the kill switch) |
|
|
226
|
+
| `audit verify [PATH]`, `audit head [PATH]` | verify the hash chain / print the head for anchoring |
|
|
227
|
+
| `report [PATH] [--format md\|json] [-o FILE]` | engagement evidence report |
|
|
228
|
+
|
|
229
|
+
All commands take `--policy/-p` (default `rulebound.toml`). The full policy schema and the
|
|
230
|
+
decision order are documented in [`docs/policy.md`](docs/policy.md).
|
|
231
|
+
|
|
232
|
+
## Interoperability
|
|
233
|
+
|
|
234
|
+
The MCP proxy is tested end to end against a real, independently developed MCP server,
|
|
235
|
+
[chrome-devtools-mcp](https://github.com/ChromeDevTools/chrome-devtools-mcp) 0.20.2 (29
|
|
236
|
+
tools), in the [MCP interop workflow](.github/workflows/interop.yml). The test checks that:
|
|
237
|
+
|
|
238
|
+
- the handshake and tool list pass through unchanged;
|
|
239
|
+
- an in-scope `new_page` call reaches the server;
|
|
240
|
+
- an out-of-scope call is blocked and never reaches the server;
|
|
241
|
+
- a tool outside the pre-approved classes is escalated and rejected;
|
|
242
|
+
- the audit chain verifies afterwards.
|
|
243
|
+
|
|
244
|
+
It has also been checked by hand with a production AI-agent CLI as the MCP client, wrapping
|
|
245
|
+
the same server through `rulebound mcp-proxy`. The agent's in-scope `new_page` call
|
|
246
|
+
succeeded, its out-of-scope call came back as `Blocked by rulebound: target
|
|
247
|
+
https://example.org/ is not in scope`, and the audit log recorded the client's `initialize`
|
|
248
|
+
handshake and both decisions with the chain intact.
|
|
249
|
+
|
|
250
|
+
To run the automated check yourself (needs Node.js and Chrome):
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
python tests/interop/mcp_server_interop.py -- \
|
|
254
|
+
npx -y chrome-devtools-mcp@0.20.2 --headless --isolated --no-usage-statistics
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Output formats
|
|
258
|
+
|
|
259
|
+
- **Audit log** — one JSON object per line: `seq`, `ts` (UTC), `engagement_id`, `event`,
|
|
260
|
+
`policy_sha256`, event fields (`tool`, `action_class`, `risk`, `targets`, `verdict`,
|
|
261
|
+
`reasons`, `codes`, redacted `args`, `args_sha256`, `approver`, …), `prev_hash`, `alg`,
|
|
262
|
+
`hash`.
|
|
263
|
+
- **Report** — Markdown (default) or JSON.
|
|
264
|
+
- **`check --format json`** — the decision object.
|
|
265
|
+
|
|
266
|
+
## CI integration
|
|
267
|
+
|
|
268
|
+
`rulebound check` is useful in CI to test a policy against the actions an agent is expected
|
|
269
|
+
to take:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
rulebound validate policy.toml
|
|
273
|
+
rulebound check -p policy.toml --no-audit --tool http_get --args '{"url": "https://app.staging.example.com/"}'
|
|
274
|
+
! rulebound check -p policy.toml --no-audit --tool http_get --args '{"url": "https://unrelated.example.net/"}'
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## Methodology
|
|
278
|
+
|
|
279
|
+
rulebound implements the safety-constrained autonomy, measurement and governance layer
|
|
280
|
+
(§4–§5, Tables 3–4) of:
|
|
281
|
+
|
|
282
|
+
> R. Handa, "Automating Cyber Offense Simulations with Machine Learning: Advancements in
|
|
283
|
+
> AI-Augmented Penetration Testing," *Computer Fraud and Security*, 2025(2), 1944–1951.
|
|
284
|
+
> doi:[10.52710/cfs.831](https://doi.org/10.52710/cfs.831)
|
|
285
|
+
|
|
286
|
+
[`docs/methodology.md`](docs/methodology.md) maps each feature to the corresponding section
|
|
287
|
+
and lists the limits of the approach. rulebound contains no offensive capability; it only
|
|
288
|
+
governs and audits actions taken by other tools.
|
|
289
|
+
|
|
290
|
+
**Limits, in short:** target extraction is heuristic (false positives fail safe;
|
|
291
|
+
`require_target` escalates actions with no recognizable target); rulebound is a guardrail,
|
|
292
|
+
not a sandbox — run agents with least privilege; hostnames are not resolved.
|
|
293
|
+
|
|
294
|
+
## Roadmap
|
|
295
|
+
|
|
296
|
+
- Policy test files (expected verdicts for a list of actions) run by `rulebound test`
|
|
297
|
+
- Webhook / chat-ops approver
|
|
298
|
+
- Signed policy files and external anchoring of the audit head
|
|
299
|
+
- HTTP(S) forward-proxy enforcement point
|
|
300
|
+
|
|
301
|
+
## Contributing
|
|
302
|
+
|
|
303
|
+
Issues and pull requests are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md). Please
|
|
304
|
+
report security issues privately as described in [SECURITY.md](SECURITY.md).
|
|
305
|
+
|
|
306
|
+
## License
|
|
307
|
+
|
|
308
|
+
Apache-2.0 — see [LICENSE](LICENSE) and [NOTICE](NOTICE).
|
|
309
|
+
|
|
310
|
+
## Citation
|
|
311
|
+
|
|
312
|
+
If you use rulebound, please cite it (see [CITATION.cff](CITATION.cff)) and the paper
|
|
313
|
+
above.
|