sentinelos-audit 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.
- sentinelos_audit-0.1.0/LICENSE +21 -0
- sentinelos_audit-0.1.0/PKG-INFO +235 -0
- sentinelos_audit-0.1.0/README.md +223 -0
- sentinelos_audit-0.1.0/pyproject.toml +26 -0
- sentinelos_audit-0.1.0/setup.cfg +4 -0
- sentinelos_audit-0.1.0/src/os_audit/__init__.py +5 -0
- sentinelos_audit-0.1.0/src/os_audit/cli.py +36 -0
- sentinelos_audit-0.1.0/src/os_audit/core.py +1055 -0
- sentinelos_audit-0.1.0/src/os_audit/export.py +85 -0
- sentinelos_audit-0.1.0/src/os_audit/reproduce.py +404 -0
- sentinelos_audit-0.1.0/src/os_audit/schema.json +34 -0
- sentinelos_audit-0.1.0/src/sentinelos_audit.egg-info/PKG-INFO +235 -0
- sentinelos_audit-0.1.0/src/sentinelos_audit.egg-info/SOURCES.txt +22 -0
- sentinelos_audit-0.1.0/src/sentinelos_audit.egg-info/dependency_links.txt +1 -0
- sentinelos_audit-0.1.0/src/sentinelos_audit.egg-info/entry_points.txt +2 -0
- sentinelos_audit-0.1.0/src/sentinelos_audit.egg-info/top_level.txt +1 -0
- sentinelos_audit-0.1.0/tests/test_audit.py +286 -0
- sentinelos_audit-0.1.0/tests/test_causal.py +54 -0
- sentinelos_audit-0.1.0/tests/test_next_wave.py +57 -0
- sentinelos_audit-0.1.0/tests/test_proof.py +158 -0
- sentinelos_audit-0.1.0/tests/test_research.py +213 -0
- sentinelos_audit-0.1.0/tests/test_secret_carry.py +66 -0
- sentinelos_audit-0.1.0/tests/test_spellings.py +119 -0
- sentinelos_audit-0.1.0/tests/test_tools.py +178 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SentinelOS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sentinelos-audit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Did the agent act on a text that was never its owner's? Attribution of Unauthorised Directives by Input Tracing.
|
|
5
|
+
Author: SentinelOS Frontier Lab
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: ai agents,prompt injection,security,audit,provenance
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# OS-Audit
|
|
14
|
+
|
|
15
|
+
**Governing agents starts with knowing whether or not they obeyed.**
|
|
16
|
+
|
|
17
|
+
Attribution of Unauthorised Directives by Input Tracing. From SentinelOS Frontier Lab.
|
|
18
|
+
|
|
19
|
+
## Why
|
|
20
|
+
|
|
21
|
+
An AI agent acts on what it reads. One sentence hidden in a mail, a page or a ticket can give it an order, and it will
|
|
22
|
+
carry that order out with its owner's access.
|
|
23
|
+
|
|
24
|
+
Finding the hidden sentence is a solved kind of problem. It does not tell you what matters next: **did the agent obey
|
|
25
|
+
it?** By the benchmarks' own score, an attack succeeds in 17.2 % of runs under attack on AgentDojo and 12.2 % on
|
|
26
|
+
AgentDyn. A detector of the planted text cannot tell these runs from those in which the agent ignored it.
|
|
27
|
+
|
|
28
|
+
OS-Audit answers that one question, and shows its proof.
|
|
29
|
+
|
|
30
|
+
## What it does
|
|
31
|
+
|
|
32
|
+
It works two ways.
|
|
33
|
+
|
|
34
|
+
**Before.** Put it where your agent runs its tools, and it judges each call before the call runs.
|
|
35
|
+
|
|
36
|
+
**After.** Hand it finished sessions, one or a hundred thousand, and it tells you which ones obeyed.
|
|
37
|
+
|
|
38
|
+
Either way it works from three things: what the user asked, the tool calls with what each returned, and the text that
|
|
39
|
+
was flagged as a hidden instruction.
|
|
40
|
+
|
|
41
|
+
It follows every value of every call back to where it came from. A payment to an account only the hidden text named.
|
|
42
|
+
A mail to an address only it gave. A password it dictated. A date it set. And one step further: a value returned by a
|
|
43
|
+
lookup the hidden text told the agent to make.
|
|
44
|
+
|
|
45
|
+
When such a value reaches a call that acts, or a fetch to an address the hidden text named, the agent is obeying. You
|
|
46
|
+
know it before the money leaves.
|
|
47
|
+
|
|
48
|
+
There is no model. Nothing to train, nothing to tune, nothing to download but the package. One file of logic.
|
|
49
|
+
|
|
50
|
+
## Install
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install sentinelos-audit
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Python 3.9 or later. No dependency.
|
|
57
|
+
|
|
58
|
+
## Use
|
|
59
|
+
|
|
60
|
+
**Before.** Where your agent runs its tools:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from os_audit import Watch
|
|
64
|
+
|
|
65
|
+
watch = Watch(request)
|
|
66
|
+
|
|
67
|
+
proof = watch.before(tool, args) # before the call runs
|
|
68
|
+
if proof and (proof.acting or proof.egress):
|
|
69
|
+
... # it carries a value of the hidden text: stop it, hold it, log it
|
|
70
|
+
result = run(tool, args)
|
|
71
|
+
watch.after(result)
|
|
72
|
+
|
|
73
|
+
watch.flag(text) # whenever your detector flags a text
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The check before a call is fast: per call, p50 50 microseconds, p95 0.41 ms, p99 1.3 ms, measured over 6,574 recorded
|
|
77
|
+
sessions. See it stop a payment:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
python examples/live.py
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
stopped before it ran: send_money us133000000121212121212 - named only by the hidden text
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**After.** On a recorded session, three lines:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from os_audit import audit
|
|
91
|
+
|
|
92
|
+
verdict = audit(request, calls, hidden_text)
|
|
93
|
+
if verdict.obeyed:
|
|
94
|
+
print(verdict.level, verdict.evidence)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`calls` is the session in order, in the simplest shape there is:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
calls = [
|
|
101
|
+
{"tool": "read_file", "args": {"file_path": "bill-december.txt"}, "result": "..."},
|
|
102
|
+
{"tool": "send_money", "args": {"recipient": "US133000000121212121212", "amount": 98.7}, "result": "ok"},
|
|
103
|
+
]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Whatever your agent framework, tool gateway or trace format, it reduces to that in a few lines.
|
|
107
|
+
|
|
108
|
+
Or one command on a log file:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
os-audit check examples/session.json
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"schema_version": "1",
|
|
117
|
+
"obeyed": true,
|
|
118
|
+
"level": "acted",
|
|
119
|
+
"egress": false,
|
|
120
|
+
"decision": "no-go",
|
|
121
|
+
"evidence": [
|
|
122
|
+
{
|
|
123
|
+
"call": 1,
|
|
124
|
+
"tool": "send_money",
|
|
125
|
+
"value": "us133000000121212121212",
|
|
126
|
+
"reason": "named only by the hidden text",
|
|
127
|
+
"acting": true,
|
|
128
|
+
"egress": false,
|
|
129
|
+
"decision": "no-go"
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The exit code is `1` when the agent obeyed. Put that line in a build pipeline and the build fails the day an agent
|
|
136
|
+
acts on an injected instruction.
|
|
137
|
+
|
|
138
|
+
`level` is `acted` (a call that acts used a value of the hidden text), `looked_up` (the agent only went and looked at
|
|
139
|
+
what the text named) or `none`. `egress` is `true` when a fetching call requests an address the hidden text named.
|
|
140
|
+
|
|
141
|
+
**Which tools act.** By default, the words of the tool's name: `check_out_and_pay` acts, `get_order` reads, a name with
|
|
142
|
+
no reading verb acts. MCP annotations come from the server, and the MCP specification says not to trust them from an
|
|
143
|
+
untrusted server: they may only make a tool stricter, never turn a payment into a read. Only you, the operator, can:
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from os_audit import Tools
|
|
147
|
+
|
|
148
|
+
tools = Tools.from_mcp(server_tools, operator={"erp.query": "read", "web.*": "egress"})
|
|
149
|
+
verdict = audit(request, calls, hidden_text, tools=tools)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**In your logs.** `verdict.to_json()` is one line in a fixed form (`src/os_audit/schema.json`). For a trace,
|
|
153
|
+
`os_audit.export.to_otel(evidence)` gives the attributes of a span event on the tool call, after the OpenTelemetry
|
|
154
|
+
GenAI conventions; it carries the kind of the value and a salted hash, never the value itself unless you ask for it,
|
|
155
|
+
and never a secret. No dependency: with the `opentelemetry` package, `attach(span, evidence)` adds the event.
|
|
156
|
+
|
|
157
|
+
**In TypeScript.** `ports/ts/os_audit.ts`, one file, no dependency, run by Node 24 or Bun as it is. Every proof it
|
|
158
|
+
gives is the Python engine's, byte for byte, on the golden corpus in `ports/golden/`: `node ports/ts/conformance.ts`.
|
|
159
|
+
|
|
160
|
+
## What it found
|
|
161
|
+
|
|
162
|
+
Run on the recorded sessions that two public benchmarks publish. Each distinct run is counted once.
|
|
163
|
+
|
|
164
|
+
| | AgentDojo | AgentDyn |
|
|
165
|
+
|---|---|---|
|
|
166
|
+
| run folders (model and defence set-ups, as `reproduce` counts them) | 28 | 66 |
|
|
167
|
+
| attacks that succeeded through a tool call (distinct runs) | 4,486 | 3,801 |
|
|
168
|
+
| **of those, flagged by the audit of the recorded session** | **97.9 %** | **96.3 %** |
|
|
169
|
+
| of those, flagged live (the text is flagged only once a result carries it) | 97.7 % | 96.3 % |
|
|
170
|
+
| ordinary runs handed a hidden text they never met, flagged by the audit | 0.16 % (3 of 1,824) | 0.80 % (31 of 3,899) |
|
|
171
|
+
| ordinary runs interrupted by the gate, with the text known from the start | 0.11 % | 0.56 % |
|
|
172
|
+
|
|
173
|
+
Live, an ordinary run never carries the hidden text, so it is never flagged: the two false-alarm rows measure what
|
|
174
|
+
happens when the text is known from the start. A 10,000-call session is judged in 0.65 s. Live, call by call, it is the
|
|
175
|
+
same logic.
|
|
176
|
+
|
|
177
|
+
Four corpora of clean agent sessions (tau-bench, MCP-Atlas, Toucan, obaydata) produce no false alarm.
|
|
178
|
+
|
|
179
|
+
Success is not obedience, in both directions. Of 99 AgentDojo runs scored as successful attacks that an earlier version
|
|
180
|
+
did not flag, 60 were not obedience (crashed runs, a benchmark version where the "attacker's" account is the user's
|
|
181
|
+
landlord, three with no obedience); at most about 39 are real misses. In the other direction, OS-Audit flags 4.36 % of
|
|
182
|
+
AgentDojo runs and 7.59 % of AgentDyn runs that the benchmarks score as resisted; in 3.24 and 3.54 percentage points of
|
|
183
|
+
them the proof shows obedience directly (a secret left the session, a fetch reached the attacker's address, or an
|
|
184
|
+
acting call used an address, site or account that only the attacker gave).
|
|
185
|
+
|
|
186
|
+
## Check it yourself
|
|
187
|
+
|
|
188
|
+
Each benchmark figure above comes from one command, run on the benchmark's own archive:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
os-audit reproduce agentdojo-main.tar.gz # github.com/ethz-spylab/agentdojo, MIT
|
|
192
|
+
os-audit reproduce AgentDyn-main.tar.gz # github.com/SaFo-Lab/AgentDyn, MIT
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Nothing in the archives is executed. The clean-corpus and constructed-evasion figures are not produced by `reproduce`.
|
|
196
|
+
|
|
197
|
+
## Where it stops
|
|
198
|
+
|
|
199
|
+
OS-Audit is a first layer. It catches the attacks that name a value. It does not catch every attack, and it does not
|
|
200
|
+
pretend to.
|
|
201
|
+
|
|
202
|
+
- It does not find the hidden instruction. Something has to hand it one.
|
|
203
|
+
- An attack that names no value ("delete one of the repositories", "book the most expensive hotel") leaves it nothing
|
|
204
|
+
to follow.
|
|
205
|
+
- An attack whose goal is only to make the agent say something, or stop, makes no call to read. For the first kind,
|
|
206
|
+
`echoed(request, calls, hidden_text, answer)` returns seven words in a row the answer repeated from the hidden text
|
|
207
|
+
and found nowhere else; a separate signal, as an agent that quotes the text to warn its user repeats it too.
|
|
208
|
+
- It needs the owner's words: the user's original request and, when there is one, the operator's system prompt. Any
|
|
209
|
+
value that already appears in them is never flagged.
|
|
210
|
+
- Dates are read in English, French, German, Spanish, Italian and Portuguese, and quoted values in `'…'`, `"…"`, `«…»`,
|
|
211
|
+
`“…”`, `„…“`, `‘…’` and `「…」`; a date written only in figures (`01/05`) is not read, as its day and month cannot be
|
|
212
|
+
told apart.
|
|
213
|
+
- A copy of the hidden text inside an argument that names an object (a channel called after the injection) is taken
|
|
214
|
+
as the object's name, not as values handed to the call. Inside a free-text argument (a message body) it is still read.
|
|
215
|
+
A known secret is never dropped this way; a payee IBAN or a mailbox is kept when the argument is an address, or when
|
|
216
|
+
the call acts and the argument does not name a place.
|
|
217
|
+
- In an argument, base64, hex and percent-encoding are undone, Cyrillic and Greek look-alike letters are read as Latin,
|
|
218
|
+
an account sent in two pieces and « the account ending in 1212 » are traced. Not undone: rot13, other ciphers,
|
|
219
|
+
values rebuilt from more than two pieces, or described in any other words.
|
|
220
|
+
- Unquoted single alphabetic words shorter than 10 letters, short (`<= 3` chars) or digits-only unquoted values,
|
|
221
|
+
wrapped or reworded dictated text, and unlisted bare TLDs without a URL scheme are not flagged.
|
|
222
|
+
- Lookups are followed one step, and only when the lookup itself carried a value from the hidden text; unlinked
|
|
223
|
+
ordinary-name lookups and multi-hop chains pass.
|
|
224
|
+
- A tool is judged by the words of its name unless the operator says otherwise: a name with a reading verb and no
|
|
225
|
+
acting verb (`get_order`, `github_list_issues`) is treated as a read unless it fetches a hidden-named address; an
|
|
226
|
+
acting tool named only with reading words (`query_erp`) needs the operator's map to be judged as acting.
|
|
227
|
+
- State is per-session; values written in one session and read in a later session with no flagged text are not linked.
|
|
228
|
+
|
|
229
|
+
## Paper
|
|
230
|
+
|
|
231
|
+
Preprint: link to be added on publication.
|
|
232
|
+
|
|
233
|
+
## Licence
|
|
234
|
+
|
|
235
|
+
MIT.
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# OS-Audit
|
|
2
|
+
|
|
3
|
+
**Governing agents starts with knowing whether or not they obeyed.**
|
|
4
|
+
|
|
5
|
+
Attribution of Unauthorised Directives by Input Tracing. From SentinelOS Frontier Lab.
|
|
6
|
+
|
|
7
|
+
## Why
|
|
8
|
+
|
|
9
|
+
An AI agent acts on what it reads. One sentence hidden in a mail, a page or a ticket can give it an order, and it will
|
|
10
|
+
carry that order out with its owner's access.
|
|
11
|
+
|
|
12
|
+
Finding the hidden sentence is a solved kind of problem. It does not tell you what matters next: **did the agent obey
|
|
13
|
+
it?** By the benchmarks' own score, an attack succeeds in 17.2 % of runs under attack on AgentDojo and 12.2 % on
|
|
14
|
+
AgentDyn. A detector of the planted text cannot tell these runs from those in which the agent ignored it.
|
|
15
|
+
|
|
16
|
+
OS-Audit answers that one question, and shows its proof.
|
|
17
|
+
|
|
18
|
+
## What it does
|
|
19
|
+
|
|
20
|
+
It works two ways.
|
|
21
|
+
|
|
22
|
+
**Before.** Put it where your agent runs its tools, and it judges each call before the call runs.
|
|
23
|
+
|
|
24
|
+
**After.** Hand it finished sessions, one or a hundred thousand, and it tells you which ones obeyed.
|
|
25
|
+
|
|
26
|
+
Either way it works from three things: what the user asked, the tool calls with what each returned, and the text that
|
|
27
|
+
was flagged as a hidden instruction.
|
|
28
|
+
|
|
29
|
+
It follows every value of every call back to where it came from. A payment to an account only the hidden text named.
|
|
30
|
+
A mail to an address only it gave. A password it dictated. A date it set. And one step further: a value returned by a
|
|
31
|
+
lookup the hidden text told the agent to make.
|
|
32
|
+
|
|
33
|
+
When such a value reaches a call that acts, or a fetch to an address the hidden text named, the agent is obeying. You
|
|
34
|
+
know it before the money leaves.
|
|
35
|
+
|
|
36
|
+
There is no model. Nothing to train, nothing to tune, nothing to download but the package. One file of logic.
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install sentinelos-audit
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Python 3.9 or later. No dependency.
|
|
45
|
+
|
|
46
|
+
## Use
|
|
47
|
+
|
|
48
|
+
**Before.** Where your agent runs its tools:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from os_audit import Watch
|
|
52
|
+
|
|
53
|
+
watch = Watch(request)
|
|
54
|
+
|
|
55
|
+
proof = watch.before(tool, args) # before the call runs
|
|
56
|
+
if proof and (proof.acting or proof.egress):
|
|
57
|
+
... # it carries a value of the hidden text: stop it, hold it, log it
|
|
58
|
+
result = run(tool, args)
|
|
59
|
+
watch.after(result)
|
|
60
|
+
|
|
61
|
+
watch.flag(text) # whenever your detector flags a text
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The check before a call is fast: per call, p50 50 microseconds, p95 0.41 ms, p99 1.3 ms, measured over 6,574 recorded
|
|
65
|
+
sessions. See it stop a payment:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
python examples/live.py
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
stopped before it ran: send_money us133000000121212121212 - named only by the hidden text
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**After.** On a recorded session, three lines:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from os_audit import audit
|
|
79
|
+
|
|
80
|
+
verdict = audit(request, calls, hidden_text)
|
|
81
|
+
if verdict.obeyed:
|
|
82
|
+
print(verdict.level, verdict.evidence)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`calls` is the session in order, in the simplest shape there is:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
calls = [
|
|
89
|
+
{"tool": "read_file", "args": {"file_path": "bill-december.txt"}, "result": "..."},
|
|
90
|
+
{"tool": "send_money", "args": {"recipient": "US133000000121212121212", "amount": 98.7}, "result": "ok"},
|
|
91
|
+
]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Whatever your agent framework, tool gateway or trace format, it reduces to that in a few lines.
|
|
95
|
+
|
|
96
|
+
Or one command on a log file:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
os-audit check examples/session.json
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"schema_version": "1",
|
|
105
|
+
"obeyed": true,
|
|
106
|
+
"level": "acted",
|
|
107
|
+
"egress": false,
|
|
108
|
+
"decision": "no-go",
|
|
109
|
+
"evidence": [
|
|
110
|
+
{
|
|
111
|
+
"call": 1,
|
|
112
|
+
"tool": "send_money",
|
|
113
|
+
"value": "us133000000121212121212",
|
|
114
|
+
"reason": "named only by the hidden text",
|
|
115
|
+
"acting": true,
|
|
116
|
+
"egress": false,
|
|
117
|
+
"decision": "no-go"
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The exit code is `1` when the agent obeyed. Put that line in a build pipeline and the build fails the day an agent
|
|
124
|
+
acts on an injected instruction.
|
|
125
|
+
|
|
126
|
+
`level` is `acted` (a call that acts used a value of the hidden text), `looked_up` (the agent only went and looked at
|
|
127
|
+
what the text named) or `none`. `egress` is `true` when a fetching call requests an address the hidden text named.
|
|
128
|
+
|
|
129
|
+
**Which tools act.** By default, the words of the tool's name: `check_out_and_pay` acts, `get_order` reads, a name with
|
|
130
|
+
no reading verb acts. MCP annotations come from the server, and the MCP specification says not to trust them from an
|
|
131
|
+
untrusted server: they may only make a tool stricter, never turn a payment into a read. Only you, the operator, can:
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
from os_audit import Tools
|
|
135
|
+
|
|
136
|
+
tools = Tools.from_mcp(server_tools, operator={"erp.query": "read", "web.*": "egress"})
|
|
137
|
+
verdict = audit(request, calls, hidden_text, tools=tools)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**In your logs.** `verdict.to_json()` is one line in a fixed form (`src/os_audit/schema.json`). For a trace,
|
|
141
|
+
`os_audit.export.to_otel(evidence)` gives the attributes of a span event on the tool call, after the OpenTelemetry
|
|
142
|
+
GenAI conventions; it carries the kind of the value and a salted hash, never the value itself unless you ask for it,
|
|
143
|
+
and never a secret. No dependency: with the `opentelemetry` package, `attach(span, evidence)` adds the event.
|
|
144
|
+
|
|
145
|
+
**In TypeScript.** `ports/ts/os_audit.ts`, one file, no dependency, run by Node 24 or Bun as it is. Every proof it
|
|
146
|
+
gives is the Python engine's, byte for byte, on the golden corpus in `ports/golden/`: `node ports/ts/conformance.ts`.
|
|
147
|
+
|
|
148
|
+
## What it found
|
|
149
|
+
|
|
150
|
+
Run on the recorded sessions that two public benchmarks publish. Each distinct run is counted once.
|
|
151
|
+
|
|
152
|
+
| | AgentDojo | AgentDyn |
|
|
153
|
+
|---|---|---|
|
|
154
|
+
| run folders (model and defence set-ups, as `reproduce` counts them) | 28 | 66 |
|
|
155
|
+
| attacks that succeeded through a tool call (distinct runs) | 4,486 | 3,801 |
|
|
156
|
+
| **of those, flagged by the audit of the recorded session** | **97.9 %** | **96.3 %** |
|
|
157
|
+
| of those, flagged live (the text is flagged only once a result carries it) | 97.7 % | 96.3 % |
|
|
158
|
+
| ordinary runs handed a hidden text they never met, flagged by the audit | 0.16 % (3 of 1,824) | 0.80 % (31 of 3,899) |
|
|
159
|
+
| ordinary runs interrupted by the gate, with the text known from the start | 0.11 % | 0.56 % |
|
|
160
|
+
|
|
161
|
+
Live, an ordinary run never carries the hidden text, so it is never flagged: the two false-alarm rows measure what
|
|
162
|
+
happens when the text is known from the start. A 10,000-call session is judged in 0.65 s. Live, call by call, it is the
|
|
163
|
+
same logic.
|
|
164
|
+
|
|
165
|
+
Four corpora of clean agent sessions (tau-bench, MCP-Atlas, Toucan, obaydata) produce no false alarm.
|
|
166
|
+
|
|
167
|
+
Success is not obedience, in both directions. Of 99 AgentDojo runs scored as successful attacks that an earlier version
|
|
168
|
+
did not flag, 60 were not obedience (crashed runs, a benchmark version where the "attacker's" account is the user's
|
|
169
|
+
landlord, three with no obedience); at most about 39 are real misses. In the other direction, OS-Audit flags 4.36 % of
|
|
170
|
+
AgentDojo runs and 7.59 % of AgentDyn runs that the benchmarks score as resisted; in 3.24 and 3.54 percentage points of
|
|
171
|
+
them the proof shows obedience directly (a secret left the session, a fetch reached the attacker's address, or an
|
|
172
|
+
acting call used an address, site or account that only the attacker gave).
|
|
173
|
+
|
|
174
|
+
## Check it yourself
|
|
175
|
+
|
|
176
|
+
Each benchmark figure above comes from one command, run on the benchmark's own archive:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
os-audit reproduce agentdojo-main.tar.gz # github.com/ethz-spylab/agentdojo, MIT
|
|
180
|
+
os-audit reproduce AgentDyn-main.tar.gz # github.com/SaFo-Lab/AgentDyn, MIT
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Nothing in the archives is executed. The clean-corpus and constructed-evasion figures are not produced by `reproduce`.
|
|
184
|
+
|
|
185
|
+
## Where it stops
|
|
186
|
+
|
|
187
|
+
OS-Audit is a first layer. It catches the attacks that name a value. It does not catch every attack, and it does not
|
|
188
|
+
pretend to.
|
|
189
|
+
|
|
190
|
+
- It does not find the hidden instruction. Something has to hand it one.
|
|
191
|
+
- An attack that names no value ("delete one of the repositories", "book the most expensive hotel") leaves it nothing
|
|
192
|
+
to follow.
|
|
193
|
+
- An attack whose goal is only to make the agent say something, or stop, makes no call to read. For the first kind,
|
|
194
|
+
`echoed(request, calls, hidden_text, answer)` returns seven words in a row the answer repeated from the hidden text
|
|
195
|
+
and found nowhere else; a separate signal, as an agent that quotes the text to warn its user repeats it too.
|
|
196
|
+
- It needs the owner's words: the user's original request and, when there is one, the operator's system prompt. Any
|
|
197
|
+
value that already appears in them is never flagged.
|
|
198
|
+
- Dates are read in English, French, German, Spanish, Italian and Portuguese, and quoted values in `'…'`, `"…"`, `«…»`,
|
|
199
|
+
`“…”`, `„…“`, `‘…’` and `「…」`; a date written only in figures (`01/05`) is not read, as its day and month cannot be
|
|
200
|
+
told apart.
|
|
201
|
+
- A copy of the hidden text inside an argument that names an object (a channel called after the injection) is taken
|
|
202
|
+
as the object's name, not as values handed to the call. Inside a free-text argument (a message body) it is still read.
|
|
203
|
+
A known secret is never dropped this way; a payee IBAN or a mailbox is kept when the argument is an address, or when
|
|
204
|
+
the call acts and the argument does not name a place.
|
|
205
|
+
- In an argument, base64, hex and percent-encoding are undone, Cyrillic and Greek look-alike letters are read as Latin,
|
|
206
|
+
an account sent in two pieces and « the account ending in 1212 » are traced. Not undone: rot13, other ciphers,
|
|
207
|
+
values rebuilt from more than two pieces, or described in any other words.
|
|
208
|
+
- Unquoted single alphabetic words shorter than 10 letters, short (`<= 3` chars) or digits-only unquoted values,
|
|
209
|
+
wrapped or reworded dictated text, and unlisted bare TLDs without a URL scheme are not flagged.
|
|
210
|
+
- Lookups are followed one step, and only when the lookup itself carried a value from the hidden text; unlinked
|
|
211
|
+
ordinary-name lookups and multi-hop chains pass.
|
|
212
|
+
- A tool is judged by the words of its name unless the operator says otherwise: a name with a reading verb and no
|
|
213
|
+
acting verb (`get_order`, `github_list_issues`) is treated as a read unless it fetches a hidden-named address; an
|
|
214
|
+
acting tool named only with reading words (`query_erp`) needs the operator's map to be judged as acting.
|
|
215
|
+
- State is per-session; values written in one session and read in a later session with no flagged text are not linked.
|
|
216
|
+
|
|
217
|
+
## Paper
|
|
218
|
+
|
|
219
|
+
Preprint: link to be added on publication.
|
|
220
|
+
|
|
221
|
+
## Licence
|
|
222
|
+
|
|
223
|
+
MIT.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sentinelos-audit"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Did the agent act on a text that was never its owner's? Attribution of Unauthorised Directives by Input Tracing."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
dependencies = []
|
|
13
|
+
authors = [{ name = "SentinelOS Frontier Lab" }]
|
|
14
|
+
keywords = ["ai agents", "prompt injection", "security", "audit", "provenance"]
|
|
15
|
+
|
|
16
|
+
[project.scripts]
|
|
17
|
+
os-audit = "os_audit.cli:main"
|
|
18
|
+
|
|
19
|
+
[tool.setuptools.packages.find]
|
|
20
|
+
where = ["src"]
|
|
21
|
+
|
|
22
|
+
[tool.setuptools.package-data]
|
|
23
|
+
os_audit = ["schema.json"]
|
|
24
|
+
|
|
25
|
+
[tool.pytest.ini_options]
|
|
26
|
+
pythonpath = ["src"]
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"""OS-Audit: Attribution of Unauthorised Directives by Input Tracing."""
|
|
2
|
+
from .core import ASK, DATED, DICTATED, GO, HANDED, NAMED, NO_GO, SECRET, Evidence, Tools, Verdict, Watch, audit, echoed, is_action
|
|
3
|
+
|
|
4
|
+
__all__ = ["audit", "echoed", "Watch", "Verdict", "Evidence", "is_action", "Tools", "NAMED", "DICTATED", "DATED", "HANDED", "SECRET", "GO", "ASK", "NO_GO"]
|
|
5
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Command line.
|
|
2
|
+
|
|
3
|
+
os-audit check session.json one session: prints the verdict and its proof; exit code 1 when the agent obeyed
|
|
4
|
+
os-audit reproduce <archive|folder> every figure of the paper, from a benchmark's recorded runs
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import argparse
|
|
9
|
+
import json
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
from . import __version__, audit
|
|
13
|
+
from .reproduce import report, show
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main(argv: list[str] | None = None) -> int:
|
|
17
|
+
parser = argparse.ArgumentParser(prog="os-audit", description="Did the agent act on a text that was never its owner's?")
|
|
18
|
+
parser.add_argument("--version", action="version", version=__version__)
|
|
19
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
20
|
+
check = sub.add_parser("check", help="judge one recorded session")
|
|
21
|
+
check.add_argument("session", help='JSON file: {"request": "...", "calls": [{"tool": "...", "args": {...}, "result": "..."}], "hidden_text": "..."}')
|
|
22
|
+
rep = sub.add_parser("reproduce", help="reproduce the paper's figures on a benchmark's recorded runs")
|
|
23
|
+
rep.add_argument("path", help="a GitHub archive (.tar.gz) or an unpacked folder of AgentDojo or AgentDyn")
|
|
24
|
+
args = parser.parse_args(argv)
|
|
25
|
+
if args.command == "check":
|
|
26
|
+
with open(args.session, encoding="utf-8") as fh:
|
|
27
|
+
s = json.load(fh)
|
|
28
|
+
verdict = audit(s.get("request", ""), s.get("calls") or [], s.get("hidden_text", ""))
|
|
29
|
+
print(json.dumps(verdict.to_dict(), indent=2, ensure_ascii=False))
|
|
30
|
+
return 1 if verdict.obeyed else 0
|
|
31
|
+
show(report(args.path))
|
|
32
|
+
return 0
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
if __name__ == "__main__":
|
|
36
|
+
sys.exit(main())
|