flare-redact 1.5.1 → 1.6.1
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.
- package/CHANGELOG.md +68 -0
- package/README.md +97 -4
- package/bench/agent-flow-cases.json +59 -0
- package/bench/agent-flow.mjs +288 -0
- package/dist/agent.d.ts +136 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +620 -0
- package/dist/agent.js.map +1 -0
- package/dist/gateway/config.d.ts +12 -0
- package/dist/gateway/config.d.ts.map +1 -1
- package/dist/gateway/config.js +37 -0
- package/dist/gateway/config.js.map +1 -1
- package/dist/gateway/runtime.d.ts +31 -3
- package/dist/gateway/runtime.d.ts.map +1 -1
- package/dist/gateway/runtime.js +0 -0
- package/dist/gateway/runtime.js.map +1 -1
- package/dist/gateway/server.d.ts +2 -1
- package/dist/gateway/server.d.ts.map +1 -1
- package/dist/gateway/server.js +100 -3
- package/dist/gateway/server.js.map +1 -1
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +40 -2
- package/dist/help.js.map +1 -1
- package/docker/README.md +59 -3
- package/docker/flare-gateway.example.json +21 -0
- package/package.json +15 -3
- package/spec/FLAREFLOW.md +297 -0
package/dist/help.js
CHANGED
|
@@ -250,6 +250,43 @@ gateway answers itself — everything else under /v1 is proxied to your upstream
|
|
|
250
250
|
A container image ships in the repository under docker/.
|
|
251
251
|
|
|
252
252
|
Full flag list: flare-redact gateway help`,
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: 'agent-flow',
|
|
256
|
+
summary: 'FlareFlow: source-to-sink capabilities for AI tools',
|
|
257
|
+
body: `AGENT FLOW — control where protected values may be restored
|
|
258
|
+
|
|
259
|
+
FlareFlow is a library and gateway API for model-produced tool calls. It binds
|
|
260
|
+
each protected value to a runtime-owned source and detector, then restores it
|
|
261
|
+
only when a capability also matches the resolved sink, exact JSON Pointer path,
|
|
262
|
+
and remaining cumulative budget.
|
|
263
|
+
|
|
264
|
+
import { createAgentFlow } from 'flare-redact/agent';
|
|
265
|
+
|
|
266
|
+
const flow = createAgentFlow({
|
|
267
|
+
sinks: {
|
|
268
|
+
'postgres.execute': {
|
|
269
|
+
capabilities: [{
|
|
270
|
+
id: 'credential', sources: ['config'],
|
|
271
|
+
detectors: ['url_credentials'],
|
|
272
|
+
paths: ['/args/connectionString'], maxUses: 1
|
|
273
|
+
}]
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
const safe = flow.protectForModel('config', sourceData);
|
|
279
|
+
const local = flow.authorizeForSink(runtimeTool.id, modelCall);
|
|
280
|
+
|
|
281
|
+
Do not take source ids, sink ids, or policy from model output. A forged,
|
|
282
|
+
cross-flow, expired, wrong-path, key-position, or over-budget token blocks the
|
|
283
|
+
whole call without partial restoration.
|
|
284
|
+
|
|
285
|
+
This controls exact placeholder declassification. It is not a general prompt-
|
|
286
|
+
injection defense and cannot protect data the model already saw.
|
|
287
|
+
|
|
288
|
+
Specification: spec/FLAREFLOW.md
|
|
289
|
+
Benchmark: npm run benchmark:agent -- --json`,
|
|
253
290
|
},
|
|
254
291
|
{
|
|
255
292
|
name: 'library',
|
|
@@ -271,6 +308,7 @@ Adapters live behind subpath imports, so you pay for what you import:
|
|
|
271
308
|
flare-redact/http flare-redact/fetch HTTP layers
|
|
272
309
|
flare-redact/llm flare-redact/session prompts and conversations
|
|
273
310
|
flare-redact/tool MCP and multi-tool agent boundaries
|
|
311
|
+
flare-redact/agent provenance, path and budget enforcement for agents
|
|
274
312
|
flare-redact/stream flare-redact/csv streams and tabular data
|
|
275
313
|
flare-redact/middleware framework middleware
|
|
276
314
|
flare-redact/ml the learned confidence classifier
|
|
@@ -294,10 +332,10 @@ else, and it pulls no dependencies of any kind.
|
|
|
294
332
|
Go go get github.com/flare-collection/flare-redact/sdk/go
|
|
295
333
|
|
|
296
334
|
Python pip install "flare-redact @ \\
|
|
297
|
-
git+https://github.com/flare-collection/flare-redact@v1.
|
|
335
|
+
git+https://github.com/flare-collection/flare-redact@v1.6.1#subdirectory=sdk/python"
|
|
298
336
|
|
|
299
337
|
Rust flare-redact = { git = "https://github.com/flare-collection/flare-redact", \\
|
|
300
|
-
tag = "v1.
|
|
338
|
+
tag = "v1.6.1" }
|
|
301
339
|
|
|
302
340
|
The Python and Rust engines are not on PyPI or crates.io yet, so they install
|
|
303
341
|
from the repository. The commands above are the ones that work today.
|
package/dist/help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAWvC,MAAM,CAAC,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqEnB,CAAC;AAEF,MAAM,UAAU,GAAyB;IACvC;QACE,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,2CAA2C;QACpD,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDA+B0C;KACjD;IACD;QACE,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,6DAA6D;QACtE,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;iDAuBuC;KAC9C;IACD;QACE,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,8CAA8C;QACvD,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;6CAsBmC;KAC1C;IACD;QACE,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,6DAA6D;QACtE,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uFA8B6E;KACpF;IACD;QACE,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,uDAAuD;QAChE,IAAI,EAAE;;;;;;;;;;;;;;;;8CAgBoC;KAC3C;IACD;QACE,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,6DAA6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E,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAEjF,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAClE,IAAI,KAAK;QAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAEvD,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAEjD,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM;QAC7B,CAAC,CAAC,iBAAiB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO;QAChD,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,EAAE,IAAI,EAAE,gBAAgB,KAAK,SAAS,IAAI,GAAG,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAChF,CAAC"}
|
package/docker/README.md
CHANGED
|
@@ -32,6 +32,7 @@ Without Docker: `npx flare-redact gateway --upstream https://api.openai.com`.
|
|
|
32
32
|
- [Which parts of the body](#which-parts-of-the-body)
|
|
33
33
|
- [Restoring the answer](#restoring-the-answer)
|
|
34
34
|
- [The redaction API](#the-redaction-api)
|
|
35
|
+
- [FlareFlow for agent tools](#flareflow-for-agent-tools)
|
|
35
36
|
- [Configuration](#configuration)
|
|
36
37
|
- [Operating it](#operating-it)
|
|
37
38
|
- [Security model](#security-model)
|
|
@@ -126,6 +127,13 @@ not what you want:
|
|
|
126
127
|
| `POST /v1/sessions/:id/redact` | mask, remembering the mapping |
|
|
127
128
|
| `POST /v1/sessions/:id/restore` | put the originals back |
|
|
128
129
|
| `DELETE /v1/sessions/:id` | discard the mapping |
|
|
130
|
+
| `POST /v1/flows` | open an operator-policy-controlled FlareFlow |
|
|
131
|
+
| `POST /v1/flows/:id/protect` | protect `{source,input}` before model context |
|
|
132
|
+
| `POST /v1/flows/:id/inspect` | preflight `{sink,input}` without restoration |
|
|
133
|
+
| `POST /v1/flows/:id/authorize` | atomically restore or return a value-free 403 decision |
|
|
134
|
+
| `POST /v1/flows/:id/restore` | trusted final-application restoration |
|
|
135
|
+
| `GET /v1/flows/:id/snapshot` | value-free provenance, budget and audit state |
|
|
136
|
+
| `DELETE /v1/flows/:id` | discard mappings and counters |
|
|
129
137
|
| `GET /healthz`, `GET /readyz` | liveness |
|
|
130
138
|
| `GET /metrics` | Prometheus text |
|
|
131
139
|
|
|
@@ -133,8 +141,8 @@ Set `FLARE_GATEWAY_TOKEN` and every `/v1` call needs
|
|
|
133
141
|
`Authorization: Bearer <token>`. Health and metrics stay open so a probe does not
|
|
134
142
|
need a credential.
|
|
135
143
|
|
|
136
|
-
Those
|
|
137
|
-
only ones that shadow your upstream. Everything else under `/v1` — `/v1/chat/
|
|
144
|
+
Those listed control paths are the only ones the gateway answers itself, and
|
|
145
|
+
they are the only ones that shadow your upstream. Everything else under `/v1` — `/v1/chat/
|
|
138
146
|
completions`, `/v1/models`, `/v1/messages` — is proxied like any other path, which
|
|
139
147
|
is the whole point of putting the sidecar in front of a vendor that owns that
|
|
140
148
|
namespace.
|
|
@@ -144,6 +152,52 @@ Sessions are held in memory, expire after `sessions.ttlMs` and are capped at
|
|
|
144
152
|
attached. Because they are per-process, a replicated gateway needs sticky routing
|
|
145
153
|
for session traffic — the stateless `/v1/redact` path does not.
|
|
146
154
|
|
|
155
|
+
## FlareFlow for agent tools
|
|
156
|
+
|
|
157
|
+
Ordinary sessions remember placeholder mappings. FlareFlow additionally decides
|
|
158
|
+
where each protected value may be restored, using runtime-owned source,
|
|
159
|
+
detector, sink, JSON Pointer path, and cumulative-budget constraints. It is a
|
|
160
|
+
declassification boundary around model-produced tool calls, not a model prompt.
|
|
161
|
+
|
|
162
|
+
Enable it only with an operator policy in the gateway configuration:
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"agentFlow": {
|
|
167
|
+
"enabled": true,
|
|
168
|
+
"sinks": {
|
|
169
|
+
"postgres.execute": {
|
|
170
|
+
"capabilities": [{
|
|
171
|
+
"id": "database-credential",
|
|
172
|
+
"sources": ["config"],
|
|
173
|
+
"detectors": ["url_credentials"],
|
|
174
|
+
"paths": ["/args/connectionString"],
|
|
175
|
+
"maxUses": 1
|
|
176
|
+
}]
|
|
177
|
+
},
|
|
178
|
+
"http.fetch": { "capabilities": [] }
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Clients open a flow with an empty `POST /v1/flows` body. They cannot submit or
|
|
185
|
+
widen its policy. A complete round trip is:
|
|
186
|
+
|
|
187
|
+
```text
|
|
188
|
+
POST /v1/flows
|
|
189
|
+
POST /v1/flows/<id>/protect {"source":"config","input":...}
|
|
190
|
+
POST /v1/flows/<id>/authorize {"sink":"postgres.execute","input":...}
|
|
191
|
+
DELETE /v1/flows/<id>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Denials are HTTP 403 with `ERR_AGENT_FLOW_BLOCKED` and a decision containing
|
|
195
|
+
only paths, labels, counts, and limit names. A denial restores nothing and does
|
|
196
|
+
not consume budget. Flow records are memory-only, idle-TTL-bound, capped by
|
|
197
|
+
`agentFlow.max`, and exported as the `flare_gateway_agent_flows` gauge. See the
|
|
198
|
+
[FlareFlow specification](../spec/FLAREFLOW.md) for the threat model and exact
|
|
199
|
+
invariant.
|
|
200
|
+
|
|
147
201
|
## Configuration
|
|
148
202
|
|
|
149
203
|
Three layers, later winning: a config file, the environment, the command line.
|
|
@@ -166,7 +220,7 @@ flare-redact gateway --config docker/flare-gateway.example.json --print-config
|
|
|
166
220
|
| `FLARE_GATEWAY_LOG` | `silent`, `info`, `debug` |
|
|
167
221
|
|
|
168
222
|
See [`flare-gateway.example.json`](./flare-gateway.example.json) for the full
|
|
169
|
-
shape, including per-route policies.
|
|
223
|
+
shape, including per-route policies and an operator-owned FlareFlow policy.
|
|
170
224
|
|
|
171
225
|
## Operating it
|
|
172
226
|
|
|
@@ -196,6 +250,8 @@ which makes "is the proxy actually in the path?" answerable from a single curl.
|
|
|
196
250
|
- **The gateway's policy wins.** A client may pass options, but the configured
|
|
197
251
|
policy is layered over them, so no caller can send `{"disable":["email"]}` and
|
|
198
252
|
opt out. `transformSecret` from a client is rejected outright.
|
|
253
|
+
- **Agent clients cannot define declassification policy.** `/v1/flows` accepts
|
|
254
|
+
only an empty body; `agentFlow.sinks` comes from operator configuration.
|
|
199
255
|
- **It binds to loopback by default.** In a container that has to be `0.0.0.0`;
|
|
200
256
|
publish it as `127.0.0.1:8787:8787` or keep it on an internal network. A
|
|
201
257
|
redaction proxy reachable from the internet is a proxy anyone can send data
|
|
@@ -41,6 +41,27 @@
|
|
|
41
41
|
],
|
|
42
42
|
|
|
43
43
|
"sessions": { "ttlMs": 1800000, "max": 10000 },
|
|
44
|
+
"agentFlow": {
|
|
45
|
+
"enabled": true,
|
|
46
|
+
"ttlMs": 1800000,
|
|
47
|
+
"max": 10000,
|
|
48
|
+
"limits": { "tokenTtlMs": 3600000, "maxMappings": 10000, "maxEvents": 1000 },
|
|
49
|
+
"sinks": {
|
|
50
|
+
"postgres.execute": {
|
|
51
|
+
"capabilities": [
|
|
52
|
+
{
|
|
53
|
+
"id": "database-credential",
|
|
54
|
+
"sources": ["config", "postgres.result"],
|
|
55
|
+
"detectors": ["url_credentials"],
|
|
56
|
+
"paths": ["/args/connectionString"],
|
|
57
|
+
"maxUses": 2
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"budget": { "maxUses": 4, "maxUniqueValues": 2, "maxBytes": 1024 }
|
|
61
|
+
},
|
|
62
|
+
"http.fetch": { "capabilities": [] }
|
|
63
|
+
}
|
|
64
|
+
},
|
|
44
65
|
"limits": { "maxBodyBytes": 8388608, "requestTimeoutMs": 120000 },
|
|
45
66
|
"auditFindings": true,
|
|
46
67
|
"metrics": true,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flare-redact",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Zero-dependency secret and PII redaction for
|
|
3
|
+
"version": "1.6.1",
|
|
4
|
+
"description": "Zero-dependency secret and PII redaction for logs, prompts, and agent tools — with FlareFlow information-flow control and a polyglot sidecar.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -55,6 +55,10 @@
|
|
|
55
55
|
"types": "./dist/middleware.d.ts",
|
|
56
56
|
"default": "./dist/middleware.js"
|
|
57
57
|
},
|
|
58
|
+
"./agent": {
|
|
59
|
+
"types": "./dist/agent.d.ts",
|
|
60
|
+
"default": "./dist/agent.js"
|
|
61
|
+
},
|
|
58
62
|
"./pack": {
|
|
59
63
|
"types": "./dist/pack.d.ts",
|
|
60
64
|
"default": "./dist/pack.js"
|
|
@@ -74,6 +78,7 @@
|
|
|
74
78
|
"dist",
|
|
75
79
|
"bin",
|
|
76
80
|
"spec/SPEC.md",
|
|
81
|
+
"spec/FLAREFLOW.md",
|
|
77
82
|
"spec/detectors.json",
|
|
78
83
|
"spec/detectors.schema.json",
|
|
79
84
|
"spec/conformance",
|
|
@@ -83,6 +88,8 @@
|
|
|
83
88
|
"bench/performance.mjs",
|
|
84
89
|
"bench/adversarial-runtime.mjs",
|
|
85
90
|
"bench/graph-vault.mjs",
|
|
91
|
+
"bench/agent-flow.mjs",
|
|
92
|
+
"bench/agent-flow-cases.json",
|
|
86
93
|
"README.md",
|
|
87
94
|
"CHANGELOG.md",
|
|
88
95
|
"MIGRATION.md",
|
|
@@ -98,6 +105,7 @@
|
|
|
98
105
|
"spec:conformance": "npm run build && node scripts/build-conformance.mjs",
|
|
99
106
|
"gateway": "npm run build && node bin/flare-gateway.mjs",
|
|
100
107
|
"benchmark": "npm run build && node bench/performance.mjs",
|
|
108
|
+
"benchmark:agent": "npm run build && node bench/agent-flow.mjs",
|
|
101
109
|
"benchmark:adversarial": "npm run build && node bench/adversarial-runtime.mjs",
|
|
102
110
|
"prepublishOnly": "npm run build",
|
|
103
111
|
"benchmark:graph": "npm run build && node bench/graph-vault.mjs",
|
|
@@ -170,7 +178,11 @@
|
|
|
170
178
|
"mcp",
|
|
171
179
|
"ai-agents",
|
|
172
180
|
"data-loss-prevention",
|
|
173
|
-
"sdk"
|
|
181
|
+
"sdk",
|
|
182
|
+
"information-flow-control",
|
|
183
|
+
"agent-security",
|
|
184
|
+
"prompt-injection",
|
|
185
|
+
"nemo-guardrails"
|
|
174
186
|
],
|
|
175
187
|
"author": "Umud Hasanli (https://github.com/umudhasanli)",
|
|
176
188
|
"license": "MIT",
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# FlareFlow 1 — Source-to-sink declassification for tool-using agents
|
|
2
|
+
|
|
3
|
+
Status: experimental specification, August 2026
|
|
4
|
+
|
|
5
|
+
FlareFlow is a deterministic information-flow boundary for reversible redaction
|
|
6
|
+
in tool-using language-model applications. It prevents a model-produced call
|
|
7
|
+
from turning a protected placeholder back into its original value unless a
|
|
8
|
+
runtime-owned capability authorizes the value's source, detector class,
|
|
9
|
+
destination sink, and JSON location. It also limits cumulative restoration
|
|
10
|
+
across turns.
|
|
11
|
+
|
|
12
|
+
The key words **MUST**, **MUST NOT**, **SHOULD**, and **MAY** are normative.
|
|
13
|
+
|
|
14
|
+
## 1. Scope
|
|
15
|
+
|
|
16
|
+
FlareFlow protects one narrow but important boundary:
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
trusted source ──protect──▶ model context ──authorize──▶ trusted sink
|
|
20
|
+
original opaque token original or refusal
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
It controls exact restoration of values that Flare Redact detected and replaced.
|
|
24
|
+
It is model-independent: enforcement does not depend on a system prompt, model
|
|
25
|
+
classification, tool description, or the model following an instruction.
|
|
26
|
+
|
|
27
|
+
FlareFlow is not:
|
|
28
|
+
|
|
29
|
+
- a general prompt-injection detector or prevention system;
|
|
30
|
+
- semantic taint tracking for information the model has already observed;
|
|
31
|
+
- an authorization system for deciding whether a tool itself may run;
|
|
32
|
+
- protection against a compromised host runtime, policy owner, detector, or
|
|
33
|
+
trusted sink;
|
|
34
|
+
- a guarantee that detection found every sensitive value.
|
|
35
|
+
|
|
36
|
+
## 2. Trust model
|
|
37
|
+
|
|
38
|
+
The following components are trusted:
|
|
39
|
+
|
|
40
|
+
- the host runtime that calls FlareFlow;
|
|
41
|
+
- source identifiers assigned by that runtime;
|
|
42
|
+
- sink identifiers resolved through the runtime's tool registry;
|
|
43
|
+
- the sink capability policy and resource limits;
|
|
44
|
+
- detectors used before a value enters model context;
|
|
45
|
+
- a final application boundary that deliberately calls `restoreForApp`.
|
|
46
|
+
|
|
47
|
+
The following inputs are untrusted:
|
|
48
|
+
|
|
49
|
+
- model text and structured tool-call arguments;
|
|
50
|
+
- tool names or source labels emitted by a model;
|
|
51
|
+
- placeholders copied from another session or constructed by an attacker;
|
|
52
|
+
- any object location chosen by a model.
|
|
53
|
+
|
|
54
|
+
A conforming integration MUST NOT derive the selected sink, source identity, or
|
|
55
|
+
capability policy from model output without first resolving it to runtime-owned
|
|
56
|
+
metadata. In the gateway profile, clients cannot submit a policy when creating a
|
|
57
|
+
flow; the gateway operator owns it.
|
|
58
|
+
|
|
59
|
+
## 3. Terms and state
|
|
60
|
+
|
|
61
|
+
- **Source**: a stable runtime identifier for data entering model context, such
|
|
62
|
+
as `postgres.result`, `user.message`, or `config`.
|
|
63
|
+
- **Detector**: the Flare Redact detector identifier that classified a value,
|
|
64
|
+
such as `url_credentials` or `email`.
|
|
65
|
+
- **Sink**: a stable runtime identifier for an operation that may receive a
|
|
66
|
+
restored value, such as `postgres.execute` or `http.fetch`.
|
|
67
|
+
- **Path**: the JSON Pointer location of a placeholder in the complete
|
|
68
|
+
model-produced call.
|
|
69
|
+
- **Capability**: an operator rule that authorizes a set of source and detector
|
|
70
|
+
labels at a set of paths for one sink.
|
|
71
|
+
- **Declassification**: replacement of an opaque token with its original value.
|
|
72
|
+
- **Flow**: one isolated in-memory mapping, budget state, and value-free audit
|
|
73
|
+
history.
|
|
74
|
+
|
|
75
|
+
For each protected value, a flow stores a record:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
token → (original, source, detector, created_at, expires_at, use_count)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
For each sink and capability it stores cumulative use counters. Mappings MUST be
|
|
82
|
+
isolated between flows, bounded in count, and removed when expired or revoked.
|
|
83
|
+
|
|
84
|
+
## 4. Tokens
|
|
85
|
+
|
|
86
|
+
The reference profile uses:
|
|
87
|
+
|
|
88
|
+
```text
|
|
89
|
+
[FR_FLOW_<32 lowercase hexadecimal characters>]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The hexadecimal component carries 128 bits sampled with Web Crypto. Tokens MUST
|
|
93
|
+
be unpredictable, MUST NOT encode the original, source, detector, or sequence
|
|
94
|
+
number, and MUST be unique among live mappings in the flow.
|
|
95
|
+
|
|
96
|
+
A well-formed token with no live record in the current flow is an unknown token.
|
|
97
|
+
Unknown tokens MUST NOT be restored. This includes forged tokens, expired or
|
|
98
|
+
revoked tokens, and tokens copied from another flow.
|
|
99
|
+
|
|
100
|
+
## 5. Capability policy
|
|
101
|
+
|
|
102
|
+
Each sink contains an ordered array of capabilities and an optional cumulative
|
|
103
|
+
budget:
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"postgres.execute": {
|
|
108
|
+
"capabilities": [
|
|
109
|
+
{
|
|
110
|
+
"id": "database-connection",
|
|
111
|
+
"sources": ["postgres.result"],
|
|
112
|
+
"detectors": ["url_credentials"],
|
|
113
|
+
"paths": ["/args/connectionString"],
|
|
114
|
+
"maxUses": 1
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
"budget": {
|
|
118
|
+
"maxUses": 4,
|
|
119
|
+
"maxUniqueValues": 2,
|
|
120
|
+
"maxBytes": 512
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`sources` and `detectors` are either `"*"` or a non-empty list of identifiers.
|
|
127
|
+
Omitted `detectors` means `"*"`. Paths are RFC 6901 JSON Pointers with two
|
|
128
|
+
extensions:
|
|
129
|
+
|
|
130
|
+
- `*` matches exactly one segment;
|
|
131
|
+
- `**`, only as the final segment, matches zero or more remaining segments.
|
|
132
|
+
|
|
133
|
+
The first capability whose source selector, detector selector, and path all
|
|
134
|
+
match an occurrence is selected. Capability order is therefore observable and
|
|
135
|
+
MUST be preserved. A placeholder in an object or map key is never eligible for
|
|
136
|
+
declassification, regardless of path policy.
|
|
137
|
+
|
|
138
|
+
All budgets are cumulative for the lifetime of a flow:
|
|
139
|
+
|
|
140
|
+
- `maxUses`: number of restored token occurrences;
|
|
141
|
+
- `maxUniqueValues`: number of distinct token records restored to a sink;
|
|
142
|
+
- `maxBytes`: sum of UTF-8 byte lengths of every restored occurrence.
|
|
143
|
+
|
|
144
|
+
Missing budgets are unbounded. Counters do not reset between model turns.
|
|
145
|
+
|
|
146
|
+
## 6. Operations
|
|
147
|
+
|
|
148
|
+
### 6.1 Protect
|
|
149
|
+
|
|
150
|
+
`protectForModel(source, input)` MUST:
|
|
151
|
+
|
|
152
|
+
1. validate the runtime-owned source identifier;
|
|
153
|
+
2. remove expired mappings;
|
|
154
|
+
3. detect sensitive spans under the configured Flare Redact policy;
|
|
155
|
+
4. replace each span with a token bound to `(source, detector)`;
|
|
156
|
+
5. return a graph-safe copy without mutating the input;
|
|
157
|
+
6. record only value-free audit metadata.
|
|
158
|
+
|
|
159
|
+
The same `(source, detector, original)` SHOULD reuse one live token. Protection
|
|
160
|
+
is transactional: a resource-limit or audit failure MUST roll back every mapping
|
|
161
|
+
minted by that call.
|
|
162
|
+
|
|
163
|
+
### 6.2 Inspect
|
|
164
|
+
|
|
165
|
+
`inspectForSink(sink, input)` MUST evaluate the complete call without restoring a
|
|
166
|
+
value or consuming a budget. Its decision reports occurrence counts, projected
|
|
167
|
+
budget use, and value-free violations.
|
|
168
|
+
|
|
169
|
+
### 6.3 Authorize
|
|
170
|
+
|
|
171
|
+
`authorizeForSink(sink, input)` MUST perform a complete preflight before any
|
|
172
|
+
declassification. For every token occurrence it MUST verify:
|
|
173
|
+
|
|
174
|
+
1. a live record exists in the same flow;
|
|
175
|
+
2. the token is in a value position;
|
|
176
|
+
3. one capability for this sink matches its source, detector, and path;
|
|
177
|
+
4. the capability's projected use remains within its limit;
|
|
178
|
+
5. the sink's projected use, unique-value count, and byte count remain within
|
|
179
|
+
their limits.
|
|
180
|
+
|
|
181
|
+
If any occurrence violates any check, the complete operation MUST fail: no token
|
|
182
|
+
is restored and no capability or sink counter is consumed. Passing through a
|
|
183
|
+
partially restored call is forbidden.
|
|
184
|
+
|
|
185
|
+
If all occurrences pass, the implementation MUST first construct the restored
|
|
186
|
+
copy, then emit its value-free audit event, then commit counters, and finally
|
|
187
|
+
return the copy. This ordering ensures cloning or audit failures do not consume
|
|
188
|
+
authorization state or return unaudited plaintext.
|
|
189
|
+
|
|
190
|
+
Audit callbacks MUST NOT re-enter the same flow while an operation is in
|
|
191
|
+
progress. The reference implementation rejects every such call so a callback
|
|
192
|
+
cannot invalidate the preflight snapshot or race a budget commit.
|
|
193
|
+
|
|
194
|
+
A call with no FlareFlow token MAY pass through by identity, including at an
|
|
195
|
+
unconfigured sink. FlareFlow does not authorize the tool call itself; it
|
|
196
|
+
authorizes declassification.
|
|
197
|
+
|
|
198
|
+
### 6.4 Trusted restoration and revocation
|
|
199
|
+
|
|
200
|
+
`restoreForApp(input)` restores live mappings without sink policy and MUST be
|
|
201
|
+
used only at a trusted final application boundary. `revokeSource(source)` removes
|
|
202
|
+
all mappings minted by that source. `reset()` removes every mapping and counter;
|
|
203
|
+
the reference implementation replaces retained history with one value-free reset
|
|
204
|
+
event. Audit delivery for revocation and reset occurs before mutation; failure
|
|
205
|
+
leaves their mapping, counter, and retained-event state unchanged.
|
|
206
|
+
|
|
207
|
+
## 7. Security invariant
|
|
208
|
+
|
|
209
|
+
Let `R(t) = (v, s, d, …)` be the live record for token `t`. Let an occurrence of
|
|
210
|
+
`t` appear at path `p` in a call resolved by the runtime to sink `k`.
|
|
211
|
+
|
|
212
|
+
FlareFlow releases `v` at that occurrence only if there exists a configured
|
|
213
|
+
capability `c` for `k` such that:
|
|
214
|
+
|
|
215
|
+
```text
|
|
216
|
+
source(c, s) ∧ detector(c, d) ∧ path(c, p)
|
|
217
|
+
∧ within_capability_budget(c)
|
|
218
|
+
∧ within_sink_budget(k)
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
and every other token occurrence in the same call also satisfies its checks.
|
|
222
|
+
|
|
223
|
+
Under the trust model in section 2, this gives the reference implementation an
|
|
224
|
+
exact-token noninterference property: changing model-controlled text, sink
|
|
225
|
+
arguments, key positions, or token placement cannot cause an original value to
|
|
226
|
+
appear in the authorized output unless the runtime's policy already grants that
|
|
227
|
+
specific declassification. A denial leaves the flow's authorization counters
|
|
228
|
+
unchanged.
|
|
229
|
+
|
|
230
|
+
This property says nothing about paraphrases, encoded information, or values the
|
|
231
|
+
model saw before protection.
|
|
232
|
+
|
|
233
|
+
## 8. Violations and audit
|
|
234
|
+
|
|
235
|
+
The reference profile reports these value-free reasons:
|
|
236
|
+
|
|
237
|
+
| Reason | Meaning |
|
|
238
|
+
|---|---|
|
|
239
|
+
| `unknown_token` | No live mapping exists in this flow |
|
|
240
|
+
| `key_position` | A token appears in an object or map key |
|
|
241
|
+
| `capability_denied` | Source, detector, sink, or path is not authorized |
|
|
242
|
+
| `capability_budget_exceeded` | The selected capability lacks remaining uses |
|
|
243
|
+
| `sink_budget_exceeded` | A sink-wide use, unique-value, or byte limit would be exceeded |
|
|
244
|
+
|
|
245
|
+
Audit records MAY contain time, source or sink identifiers, detector ids,
|
|
246
|
+
capability ids, JSON paths, counts, limits, and aggregate budget use. They MUST
|
|
247
|
+
NOT contain originals or token strings. Token-bearing object keys MUST be
|
|
248
|
+
represented by a positional label rather than copied into an audit path. Audit
|
|
249
|
+
retention MUST be bounded.
|
|
250
|
+
|
|
251
|
+
## 9. Resource and graph behavior
|
|
252
|
+
|
|
253
|
+
Implementations MUST bound live mappings and SHOULD bound retained events and
|
|
254
|
+
flow count. A gateway flow SHOULD have both a mapping TTL and an idle-flow TTL.
|
|
255
|
+
When a hard mapping limit is reached, protection MUST fail closed and roll back
|
|
256
|
+
the incomplete transaction.
|
|
257
|
+
|
|
258
|
+
The JavaScript reference preserves cycles, sparse arrays, shared references,
|
|
259
|
+
maps, sets, errors, URLs, enumerable symbol properties, and property descriptors
|
|
260
|
+
to the same extent as the core graph transformer. Accessor properties are not
|
|
261
|
+
invoked. Atomic host objects are not traversed.
|
|
262
|
+
|
|
263
|
+
## 10. Reference APIs
|
|
264
|
+
|
|
265
|
+
JavaScript and TypeScript:
|
|
266
|
+
|
|
267
|
+
```js
|
|
268
|
+
import { createAgentFlow } from 'flare-redact/agent';
|
|
269
|
+
|
|
270
|
+
const flow = createAgentFlow({ policy, sinks, limits });
|
|
271
|
+
const safe = flow.protectForModel('postgres.result', toolResult);
|
|
272
|
+
const decision = flow.inspectForSink('postgres.execute', modelCall);
|
|
273
|
+
const localCall = flow.authorizeForSink('postgres.execute', modelCall);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Gateway control plane:
|
|
277
|
+
|
|
278
|
+
```text
|
|
279
|
+
POST /v1/flows
|
|
280
|
+
POST /v1/flows/:id/protect
|
|
281
|
+
POST /v1/flows/:id/inspect
|
|
282
|
+
POST /v1/flows/:id/authorize
|
|
283
|
+
POST /v1/flows/:id/restore
|
|
284
|
+
GET /v1/flows/:id/snapshot
|
|
285
|
+
DELETE /v1/flows/:id
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
The sidecar makes the same operator policy available to any JSON/HTTP client.
|
|
289
|
+
The repository ships standard-library clients for Python and Go.
|
|
290
|
+
|
|
291
|
+
## 11. Reproducibility profile
|
|
292
|
+
|
|
293
|
+
`bench/agent-flow-cases.json` defines deterministic attack and utility families.
|
|
294
|
+
`npm run benchmark:agent -- --json` evaluates the legacy shared vault, the
|
|
295
|
+
tool-scoped vault, and FlareFlow. The corpus measures exact-token restoration
|
|
296
|
+
only. Results MUST be reported with the corpus scope statement and MUST NOT be
|
|
297
|
+
presented as a general prompt-injection benchmark.
|