@agent-custody/receipts 0.7.0 → 0.9.0
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/README.md +29 -13
- package/dist/approval.d.ts +74 -0
- package/dist/approval.js +196 -0
- package/dist/capture.js +49 -1
- package/dist/check.d.ts +19 -0
- package/dist/check.js +288 -0
- package/dist/cli.js +238 -11
- package/dist/config.d.ts +85 -0
- package/dist/config.js +72 -2
- package/dist/console-page.d.ts +4 -0
- package/dist/console-page.js +342 -0
- package/dist/console.d.ts +20 -0
- package/dist/console.js +521 -0
- package/dist/gateway.d.ts +9 -0
- package/dist/gateway.js +335 -45
- package/dist/index.d.ts +9 -2
- package/dist/index.js +7 -1
- package/dist/issue.d.ts +8 -3
- package/dist/issue.js +13 -4
- package/dist/log-store.d.ts +3 -2
- package/dist/log-store.js +2 -0
- package/dist/operations.d.ts +101 -0
- package/dist/operations.js +239 -0
- package/dist/otel.js +12 -5
- package/dist/policy.d.ts +2 -0
- package/dist/policy.js +10 -0
- package/dist/portal.d.ts +78 -4
- package/dist/portal.js +516 -26
- package/dist/receipt.d.ts +36 -1
- package/dist/rest.js +14 -1
- package/dist/simulate.d.ts +58 -0
- package/dist/simulate.js +204 -0
- package/dist/splunk.js +11 -4
- package/dist/sso.d.ts +47 -0
- package/dist/sso.js +161 -0
- package/dist/verify.d.ts +2 -0
- package/dist/verify.js +241 -7
- package/docs/approvals.md +107 -0
- package/docs/codex-recovery.md +132 -0
- package/docs/configuration.md +224 -0
- package/docs/console.md +79 -0
- package/docs/financial-operations.md +99 -0
- package/docs/policies.md +23 -0
- package/docs/threat-model.md +13 -0
- package/docs/tutorials.md +9 -0
- package/docs/usage.md +49 -4
- package/docs/verification.md +26 -8
- package/package.json +8 -2
- package/vectors/audit.json +27 -27
- package/vectors/canonical.json +5 -5
- package/vectors/receipts.json +2866 -464
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Configuring the gateway
|
|
2
|
+
|
|
3
|
+
Who may use which tools, and where those tools live, is set in three files and a few environment variables. This page is the map: what each one decides, how they fit together, a worked example with two agents on one shared gateway, how it all works in the Docker image, and how to check a config before you start. The full list of config keys is in [the gateway reference](/reference/gateway); the Cedar language is in [policies.md](policies.md).
|
|
4
|
+
|
|
5
|
+
## What you configure, and where
|
|
6
|
+
|
|
7
|
+
| what | file | written by | decides |
|
|
8
|
+
| --- | --- | --- | --- |
|
|
9
|
+
| **The grant** | `<agent>.grant.json`, signed | the principal (the person or organisation delegating), with `agent-custody grant` | which agent may use which tool names, until when |
|
|
10
|
+
| **The policy** | `policy.cedar` | the operator or security owner | whether this particular call, with these arguments and these facts, is allowed |
|
|
11
|
+
| **The gateway config** | `gateway.json` | the operator | where the tools live (the upstreams), what the gateway looks up for itself (facts), which tools are consequential (`precommit`), where receipts and the log go |
|
|
12
|
+
| **Credentials** | environment variables | the operator | the tokens the gateway uses to reach the tools; never in a file, never in an agent |
|
|
13
|
+
|
|
14
|
+
The agent configures none of them. It connects to the gateway as an MCP server, presents its grant, and sees only the tools the grant names.
|
|
15
|
+
|
|
16
|
+
A complete, usable layout, one config directory with a policy, is in [deploy/gateway/example](https://github.com/svayatta/agent-custody/tree/main/deploy/gateway/example).
|
|
17
|
+
|
|
18
|
+
## How a call is decided
|
|
19
|
+
|
|
20
|
+
For each call, in this order, and a refusal at any step is a signed receipt:
|
|
21
|
+
|
|
22
|
+
1. **The grant** is valid, signed by a trusted principal, inside its window, and not revoked.
|
|
23
|
+
2. **The tool** is one of the grant's scopes.
|
|
24
|
+
3. **Facts** the policy needs are fetched by the gateway from an upstream (`facts` in the config).
|
|
25
|
+
4. **The Cedar policy** permits the call. No matching `permit` means deny.
|
|
26
|
+
5. **For `precommit` tools**, the authorization is committed to the log before anything is forwarded.
|
|
27
|
+
6. **The call** is forwarded to the upstream that owns the tool.
|
|
28
|
+
|
|
29
|
+
The one thing that ties all of it together is the **tool name**. The grant's scopes, the policy's `action == Action::"..."`, `facts`, and `precommit` all name the tools the upstreams offer, so a name that is spelled differently in one place is a rule that never applies.
|
|
30
|
+
|
|
31
|
+
## Tool names
|
|
32
|
+
|
|
33
|
+
- A **REST** upstream's tool names are the ones you give them in `tools[].name`.
|
|
34
|
+
- An **A2A** agent offers `<prefix>.send` and `<prefix>.card`, with the prefix you choose.
|
|
35
|
+
- An **MCP** server (stdio or HTTP) offers whatever names the server defines. Run `agent-custody check --config gateway.json --connect` to print them.
|
|
36
|
+
- **One owner per tool.** If two upstreams offer the same name the gateway refuses to start. Give REST and A2A tools a prefix (`billing.refund`, `docs.send`) and the collision cannot happen.
|
|
37
|
+
|
|
38
|
+
## A worked example: two agents, one shared gateway
|
|
39
|
+
|
|
40
|
+
A support agent may look customers up and refund them up to 1,000.00, and only for customers the gateway itself found to be verified. A reporting agent may only read. Both reach the same tools through one gateway.
|
|
41
|
+
|
|
42
|
+
**1. The principal issues one grant per agent.** On the principal's machine, with a key that never goes near the gateway:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
agent-custody grant --key principal.key --principal acme-support --agent support-agent \
|
|
46
|
+
--scopes customer.lookup,billing.refund,kb.search,docs.send --ttl-hours 8 --out support-agent.grant.json
|
|
47
|
+
agent-custody grant --key principal.key --principal acme-support --agent report-agent \
|
|
48
|
+
--scopes customer.lookup,kb.search --ttl-hours 8 --out report-agent.grant.json
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The grants limit *which tools*. The report agent's grant has no `billing.refund`, so it never sees that tool and the policy is not even asked.
|
|
52
|
+
|
|
53
|
+
**2. The operator writes one policy for both.** It limits *how* a tool may be used:
|
|
54
|
+
|
|
55
|
+
```cedar
|
|
56
|
+
// anything in a grant's scopes may read
|
|
57
|
+
permit(principal, action == Action::"customer.lookup", resource);
|
|
58
|
+
permit(principal, action == Action::"kb.search", resource);
|
|
59
|
+
|
|
60
|
+
// refunds: only the support agent, a positive amount of at most 1,000.00 (integer minor units), and only for a
|
|
61
|
+
// customer the gateway itself found to be verified. The gateway does not enforce a tool's inputSchema, so the policy
|
|
62
|
+
// bounds the amount from below as well. context.facts comes from the gateway's own lookup, never from the agent.
|
|
63
|
+
permit(principal == Agent::"support-agent", action == Action::"billing.refund", resource)
|
|
64
|
+
when {
|
|
65
|
+
context.args.amount > 0 &&
|
|
66
|
+
context.args.amount <= 100000 &&
|
|
67
|
+
context.facts has customer &&
|
|
68
|
+
context.facts.customer.verified == true
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// delegating a task to the docs agent: the support agent only
|
|
72
|
+
permit(principal == Agent::"support-agent", action == Action::"docs.send", resource);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**3. The operator writes the gateway config.** One file, four kinds of upstream, one remote log:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"identity": { "keyFile": "/data/keys/gateway.key" },
|
|
80
|
+
"upstreams": [
|
|
81
|
+
{
|
|
82
|
+
"name": "billing",
|
|
83
|
+
"rest": {
|
|
84
|
+
"baseUrl": "https://billing.internal.example.com",
|
|
85
|
+
"headerEnv": { "authorization": "BILLING_API_AUTHORIZATION" },
|
|
86
|
+
"tools": [
|
|
87
|
+
{ "name": "customer.lookup", "method": "GET", "path": "/v1/customers/{customer_id}",
|
|
88
|
+
"inputSchema": { "type": "object", "properties": { "customer_id": { "type": "string" } }, "required": ["customer_id"] } },
|
|
89
|
+
{ "name": "billing.refund", "method": "POST", "path": "/v1/refunds",
|
|
90
|
+
"description": "Refund a customer. amount is in minor units.",
|
|
91
|
+
"inputSchema": { "type": "object", "properties": { "customer_id": { "type": "string" }, "amount": { "type": "integer" } }, "required": ["customer_id", "amount"] } }
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{ "name": "github", "url": "https://mcp.internal.example.com/github", "tokenEnv": "GITHUB_MCP_TOKEN" },
|
|
96
|
+
{ "name": "kb", "command": "kb-mcp-server", "args": ["--root", "/srv/kb"], "env": { "KB_MODE": "read-only" } },
|
|
97
|
+
{ "name": "docs", "a2a": { "url": "https://docs-agent.internal.example.com", "headerEnv": { "authorization": "DOCS_AGENT_BEARER" }, "prefix": "docs" } }
|
|
98
|
+
],
|
|
99
|
+
"trustedPrincipalKeys": ["keys/principal.pub"],
|
|
100
|
+
"policyFile": "policy.cedar",
|
|
101
|
+
"facts": [
|
|
102
|
+
{ "name": "customer", "tool": "customer.lookup", "args": { "customer_id": "$args.customer_id" }, "forTools": ["billing.refund"] }
|
|
103
|
+
],
|
|
104
|
+
"precommit": ["billing.refund", "docs.send"],
|
|
105
|
+
"revokedGrants": "/data/revoked.json",
|
|
106
|
+
"receiptsDir": "/data/receipts",
|
|
107
|
+
"log": { "url": "https://log.agent-custody.dev/t/acme/", "tokenEnv": "AGENT_CUSTODY_LOG_TOKEN", "hashOnly": true, "keys": ["keys/log.pub"] }
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
What each part does:
|
|
112
|
+
|
|
113
|
+
| key | what it says here |
|
|
114
|
+
| --- | --- |
|
|
115
|
+
| `identity.keyFile` | the gateway's signing key, in `/data` because the gateway writes and keeps it. Verifiers check receipts against its public half. |
|
|
116
|
+
| `upstreams` | four tool sources behind one gateway: a REST API described as tools, an MCP server over HTTP, an MCP server the gateway starts, and another agent over A2A. |
|
|
117
|
+
| `…headerEnv`, `tokenEnv` | the **name** of an environment variable holding the credential. The gateway reads it at startup and refuses to start without it. The secret is never in the file. |
|
|
118
|
+
| `kb.env` | what the started MCP server gets. A stdio upstream gets a minimal environment and nothing of the gateway's own, so it cannot read the other upstreams' tokens. |
|
|
119
|
+
| `trustedPrincipalKeys` | the public keys whose grants this gateway accepts. Only public keys go here. |
|
|
120
|
+
| `facts` | before a refund, the gateway calls `customer.lookup` itself with the customer id from the call, and the policy reads the answer as `context.facts.customer`. |
|
|
121
|
+
| `precommit` | the consequential tools: the gateway commits the authorization to the log before it forwards, and withholds the call if the log will not take it. |
|
|
122
|
+
| `revokedGrants` | the file `agent-custody revoke` appends to; the gateway re-reads it on every call. |
|
|
123
|
+
| `receiptsDir`, `log` | full receipts stay on the gateway's disk. The hosted log receives only their hashes (`hashOnly`), and its public key is pinned (`keys`), which `precommit` with a remote log requires. |
|
|
124
|
+
|
|
125
|
+
Paths in `gateway.json` are resolved relative to the file, so `keys/principal.pub` sits beside it, and absolute paths are left as they are.
|
|
126
|
+
|
|
127
|
+
**4. Each agent presents its own grant** when it connects: the grant file, base64url-encoded, as `Authorization: Bearer <value>` or `X-Agent-Custody-Grant`. [The gateway guide](usage.md#one-gateway-for-many-agents-over-http) and [wiring it into an agent host](usage.md#wiring-it-into-an-agent-host) show how for each host. Adding a third agent is issuing it a grant. The gateway config does not change.
|
|
128
|
+
|
|
129
|
+
**Retries and money.** This config does not use `operations`, so the gateway cannot tell a retry from a second refund: an agent that repeats `billing.refund` after a timeout sends a second POST. For real money, configure [financial operations](financial-operations.md): each refund gets a durable identity and an idempotency key your API must honor, its amount is reserved against a daily budget before it is forwarded, and an uncertain outcome is closed by reading your API's own record. It needs the calling agent to send a persistent operation id in the call's `_meta`, an API that honors the idempotency key, and a read tool that returns the refund by that key.
|
|
130
|
+
|
|
131
|
+
## The principal's key
|
|
132
|
+
|
|
133
|
+
A grant is only as good as the key that signed it, so this is the key to handle with the most care. There are several keys in a deployment, and they are different:
|
|
134
|
+
|
|
135
|
+
| key | who holds the private half | what the public half is for |
|
|
136
|
+
| --- | --- | --- |
|
|
137
|
+
| **The principal's key** | the person or organisation delegating authority, on their own machine | the gateway's `trustedPrincipalKeys`: it recognises a grant as genuine because this key signed it. A verifier also takes it, as `--principal-key`. |
|
|
138
|
+
| **The gateway's key** | the gateway only, in `/data/keys` | verifiers check receipts against it (`--issuer-key`) |
|
|
139
|
+
| **The log's key** | the log's signer | a verifier or a gateway pins it (`log.keys`, `--log-key`) |
|
|
140
|
+
|
|
141
|
+
**Make it where grants are issued, not where the gateway runs.**
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
agent-custody keygen --dir ./principal --name principal
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
This writes `principal.key`, the private key, in PEM (PKCS#8) with mode 0600, and `principal.pub`, the public key, in PEM (SPKI), and prints the **key id**, the sha256 of the public key. Write the key id down: it is how you confirm, after copying, that the gateway holds the key you made.
|
|
148
|
+
|
|
149
|
+
**Keep the private key off the gateway.** The gateway never needs it, and a gateway that held it would let anyone who broke into the gateway sign grants for any agent and any tool. So `principal.key` does not go in the gateway's config directory, the image, a ConfigMap, the repository, or CI. Keep it on the machine of whoever issues grants, on an encrypted disk or in a password or secrets manager, and back it up encrypted. `agent-custody grant --key principal.key` reads it from a file, so run that command where the file is.
|
|
150
|
+
|
|
151
|
+
**Give the gateway the public key only.** Copy `principal.pub` into the gateway's config and list it:
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
"trustedPrincipalKeys": ["keys/principal.pub"]
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
In the Docker image that is `/config/keys/principal.pub`, mounted read-only; on Kubernetes it can sit in the ConfigMap, because it is public. List several keys to trust several principals: a grant is accepted when any listed key signed it, and one gateway can serve more than one organisation. A grant signed by a key that is not listed is refused when the agent connects (`delegation grant rejected`). The `--principal` name in a grant (`acme-support`) is only a label that receipts record; the trust is in the key.
|
|
158
|
+
|
|
159
|
+
**Rotating it.** The gateway reads `trustedPrincipalKeys` when it starts, so a rotation is: make the new key pair; add the new public key to the list beside the old one and restart the gateway; issue new grants with the new key; when the old key's grants have expired or been revoked (grants last hours, so this is short), remove the old public key and restart. Verifiers need the new `--principal-key` as well, and accept both while old receipts matter.
|
|
160
|
+
|
|
161
|
+
**If it is lost,** nothing already issued stops working, but no new grant can be signed: make a new pair and add its public key as above. **If it leaks,** remove its public key from `trustedPrincipalKeys` and restart the gateway, which ends open sessions and refuses every grant it signed from then on, and revoke any grant you want refused before that (`agent-custody revoke`). Then make a new pair.
|
|
162
|
+
|
|
163
|
+
`agent-custody init` in the Docker image writes a *demo* principal key under `/config/demo` so that you can try the gateway in a minute. Delete that directory before production, and make the real key where grants are issued.
|
|
164
|
+
|
|
165
|
+
## In the Docker image
|
|
166
|
+
|
|
167
|
+
The same `gateway.json` works in the [gateway image](https://github.com/svayatta/agent-custody/blob/main/deploy/gateway/README.md), with these rules:
|
|
168
|
+
|
|
169
|
+
- **Mount the config read-only at `/config`** (`gateway.json`, `policy.cedar`, and the principals' and log's **public** keys) and a **volume at `/data`**. Relative paths in the file resolve against `/config`.
|
|
170
|
+
- **Anything the gateway writes needs an absolute path under `/data`**: the key, `receiptsDir`, `logFile`, `revokedGrants`. `/config` is read-only, so `"receiptsDir": "receipts"` fails.
|
|
171
|
+
- **Credentials come from the container's environment** (`--env-file`, a compose `.env`, a Kubernetes Secret), under the variable names the config gives.
|
|
172
|
+
- **The gateway key is created on the first start** at the path `identity.keyFile` names, if the file is absent. Keep the volume.
|
|
173
|
+
- **REST, A2A, and MCP-over-HTTP upstreams work as they are.** A **stdio** MCP server (`command`) has to be inside the image. Build on it:
|
|
174
|
+
|
|
175
|
+
```dockerfile
|
|
176
|
+
FROM ghcr.io/svayatta/agent-custody-gateway:<version>
|
|
177
|
+
USER root
|
|
178
|
+
RUN npm install -g kb-mcp-server
|
|
179
|
+
USER custody
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
- `docker run ... <image> init` writes a starter config into an empty `/config`. [The gateway README](https://github.com/svayatta/agent-custody/blob/main/deploy/gateway/README.md) has the whole run, and the limits of a shared gateway.
|
|
183
|
+
|
|
184
|
+
## Check it before you start it
|
|
185
|
+
|
|
186
|
+
`agent-custody check --config gateway.json` reads the config the way the gateway would and reports what would go wrong at startup:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
agent-custody check --config gateway.json --connect
|
|
190
|
+
docker run --rm -v "$PWD/config:/config:ro" -v gateway-data:/data --env-file .env <image> check --config /config/gateway.json --connect
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
| it checks | an error or a warning |
|
|
194
|
+
| --- | --- |
|
|
195
|
+
| the config parses, with each problem and its path | **error** |
|
|
196
|
+
| a key that is not in the schema (a typo such as `precomit` is otherwise silently ignored, and the setting stays at its default) | **error**, with the key it nearly is |
|
|
197
|
+
| the gateway key loads, and is not readable by other users | error, and a warning |
|
|
198
|
+
| every trusted principal key loads | error |
|
|
199
|
+
| the Cedar policy parses, and has at least one `permit` rule (a `permit(` in a comment does not count) | error, and a warning |
|
|
200
|
+
| every credential variable the config names is set: upstream tokens and headers, the log's token, the capture key, the Splunk token, and the OpenTelemetry headers | **error**: the gateway does not start without it |
|
|
201
|
+
| a stdio `command` exists, and a script argument exists | error, and a warning |
|
|
202
|
+
| the receipts, log, revocation, operations database, and approvals paths can be written, and the revocation file is a JSON array | error |
|
|
203
|
+
| the grant the config names verifies, and is inside its window | error, and a warning near expiry |
|
|
204
|
+
| a remote log with an empty `precommit` | warning: a log outage after a call leaves its side effect without evidence |
|
|
205
|
+
|
|
206
|
+
With **`--connect`** it also starts the upstreams, which is where an unreachable server or **two upstreams offering the same tool** shows up, prints the tools they offer, and compares every tool name in `precommit`, `facts`, `approvals`, `operations`, and the grant's scopes with that list. A name in `precommit`, `facts`, `approvals`, or `operations` that no upstream offers is an **error** (for `precommit` it means the tool you meant is forwarded before it is logged); a grant scope that names nothing is a warning. `--connect` starts your stdio upstreams and may create the receipts directory. It exits 1 on any error, so it can gate a deploy.
|
|
207
|
+
|
|
208
|
+
**A console for all of this.** [The gateway console](console.md) shows the same config, the tools, and the check in a browser, and edits the policy with a replay of recorded calls before it saves.
|
|
209
|
+
|
|
210
|
+
## When the gateway does not start
|
|
211
|
+
|
|
212
|
+
| the message | the cause | the fix |
|
|
213
|
+
| --- | --- | --- |
|
|
214
|
+
| `environment variable X is not set` | a `tokenEnv`, `headerEnv`, `log.tokenEnv`, or `captureKeyEnv` names a variable the process does not have | set it where the gateway runs |
|
|
215
|
+
| `tool "t" is offered by both upstream "a" and upstream "b"` | two upstreams offer one name | rename one (give REST and A2A tools a prefix) |
|
|
216
|
+
| `exactly one of upstream or upstreams is required` | both, or neither | use `upstream` for one source and `upstreams` for several |
|
|
217
|
+
| `exactly one of logFile or log is required` | both, or neither | a local file, or a remote log |
|
|
218
|
+
| `precommit with a remote log needs log.keys` | a remote log gating consequential calls without a pinned key | add the log's public key file to `log.keys` |
|
|
219
|
+
| `fact "f" uses tool t, which precommit names as consequential` | a fact lookup must be a read | use a read tool for the fact |
|
|
220
|
+
| `ENOENT … gateway.key` | the key file does not exist | `agent-custody keygen`, or let the container create it |
|
|
221
|
+
| `EROFS` or a permission error on `receipts` | a writable path points into the read-only `/config` | use an absolute path under `/data` |
|
|
222
|
+
| `403 delegation grant rejected: …` (an agent's connection) | the grant is expired, revoked, not signed by a trusted principal, or missing | issue a new grant, and check `trustedPrincipalKeys` |
|
|
223
|
+
|
|
224
|
+
The gateway image runs the static check every time it starts and does not start on an error (`GATEWAY_CHECK=advisory` prints the findings and starts anyway; `off` skips it), and the command exits 1 on an error, so it can gate a deploy. Run `agent-custody check --connect` first: it reports most of these together, instead of one at a time.
|
package/docs/console.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# The gateway console
|
|
2
|
+
|
|
3
|
+
A small admin service for the person who runs a gateway. It shows what the gateway is configured to do and what it has done, validates and replays a policy change before it is saved, and revokes a grant. It is a separate process from the gateway, behind a token, so the gateway never serves an admin page next to the agents' credentials.
|
|
4
|
+
|
|
5
|
+
It is deliberately limited. It holds **no principal key and signs nothing**, so it cannot issue a grant or widen anyone's authority; everything it shows is read from the gateway's own config, receipts, and revocation file; and the only things it changes are the policy file and the revocation file, both of which the gateway reads. [Example 32](../examples/32-console.ts) runs it end to end.
|
|
6
|
+
|
|
7
|
+
## Run it
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
export CONSOLE_TOKEN="$(openssl rand -hex 32)" # the sign-in token; it is read from the environment (or a file), never from a flag
|
|
11
|
+
agent-custody console --config gateway.json --gateway-url http://127.0.0.1:8790
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
It listens on `127.0.0.1:8795` and prints the URL. Open it and sign in with the token.
|
|
15
|
+
|
|
16
|
+
| flag | meaning |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| `--config <gateway.json>` | the gateway's config, read again on every request, so an edit shows at once |
|
|
19
|
+
| `--token-env NAME` | the environment variable holding the token, default `CONSOLE_TOKEN`; the console refuses to start without one |
|
|
20
|
+
| `--token-file <path>` | read the token from a file instead, such as a container secret at `/run/secrets/console_token`; the contents are the secret, not the path |
|
|
21
|
+
| `--port`, `--host` | default `8795` on `127.0.0.1`; any other host prints a reminder to put TLS in front |
|
|
22
|
+
| `--gateway-url <url>` | the running gateway, for its health (reachable, open sessions); omit it and the console does not look |
|
|
23
|
+
| `--state-dir <dir>` | where the console keeps its audit file and the earlier versions of the policy; default `console/` beside the receipts directory |
|
|
24
|
+
|
|
25
|
+
**In the Docker image** it is the same image as the gateway, run as a second service: `docker compose --profile console up -d` in [deploy/gateway](https://github.com/svayatta/agent-custody/blob/main/deploy/gateway/README.md). The token is a **Docker secret mounted only in the console service** (`openssl rand -hex 32 > console-token`), not an entry in the `.env` file that the gateway reads, because the token can rewrite the policy and revoke grants and the gateway must not hold it. The console service is not given that `.env` either, so it holds none of the upstream credentials. It mounts `./config` read-write, because the policy file is what it edits, and the same data volume as the gateway; the gateway keeps its config read-only. Both run as the same user (`GATEWAY_UID`, `GATEWAY_GID`, default 10001), so what one writes the other can read: the gateway's key is mode 0600. On Kubernetes, run the same image with the argument `console`, the token as a Secret mounted as a file and given only to that pod, the same config and data volumes, and a Service that only your administrators can reach.
|
|
26
|
+
|
|
27
|
+
## What it shows and does
|
|
28
|
+
|
|
29
|
+
| tab | what it does |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| **Overview** | the gateway's health and key id, the mode, the upstreams and their kinds, the fact lookups, the log, `precommit`, the trusted principal keys, the number of revoked grants and of receipts, and the config check's result |
|
|
32
|
+
| **Check** | the same checks as `agent-custody check`, except that the credential variables are **not** checked: the console deliberately does not hold the gateway's credentials, so it cannot tell whether they are set where the gateway runs. "Connect" starts the upstreams and lists their tools only for a config that names no credentials; otherwise it says to run `agent-custody check --connect` where the gateway runs, for example `docker compose exec gateway agent-custody check --config /config/gateway.json --connect`. A connect check that does not finish in 60 seconds is stopped and the upstreams it started are closed ([configuration.md](configuration.md#check-it-before-you-start-it)) |
|
|
33
|
+
| **Policy** | the policy file in an editor. *Validate* asks Cedar to parse it. *Replay recorded calls* runs it against the verified receipts, using each call's own arguments and facts, and lists the decisions that would change, with their receipts. **A replay only re-decides calls that already happened**: a limit that no recorded call reached, or removing one, can show no change, so it is not a test of what a policy allows. *Save* writes it, keeping the previous version and recording the change |
|
|
34
|
+
| **Grants** | paste a grant to see whether the gateway would accept it (valid, expired, revoked, signed by a key it does not trust) and what it allows; *Revoke* adds its digest to the revocation file, and the gateway refuses it, and every grant delegated from it, on its next call. Lists the revoked digests |
|
|
35
|
+
| **Receipts** | the newest receipts with their agent, tool, decision, and outcome, each verified against the gateway key, the trusted principals, and the local log; a receipt that does not verify says which checks failed; a row opens the full statement |
|
|
36
|
+
| **Audit** | every change made through the console: who, when, and what, with the policy's digest before and after |
|
|
37
|
+
|
|
38
|
+
## What a saved policy does
|
|
39
|
+
|
|
40
|
+
The gateway reads `policy.cedar` when it starts, so **a saved policy applies after the gateway restarts**, and the console says so each time. Reloading a policy without a restart is a separate change. The save is guarded: Cedar must parse the text; and the operator must confirm a policy that has no `permit` rule (a `permit(` in a comment does not count), because every call would be denied, or a `permit` rule with **no action and no condition**, which allows every tool in a grant's scopes and which a replay cannot show. A save made from a copy that is no longer the file on disk is refused with `409`. The digest check, the history copy, and the write happen under one lock, in this process and, through a lock file in the state directory, across consoles that share it, so two administrators cannot overwrite each other. The previous version is kept under `console/policy-history/` and the change goes in the audit trail.
|
|
41
|
+
|
|
42
|
+
## How it is protected
|
|
43
|
+
|
|
44
|
+
- **A token on every API route.** It is compared in constant time. Five wrong tokens from one address lock it out for a minute. A request with no token is refused and does not count towards that.
|
|
45
|
+
- **Loopback by default.** The transport is plain HTTP. Anything beyond one machine needs TLS in front (a proxy or mesh) and a network only administrators can reach. The console has one shared token, not per-user accounts or roles.
|
|
46
|
+
- **No keys.** It never reads a principal's private key. It reads the gateway's key file only to take the public half, so that it can verify receipts.
|
|
47
|
+
- **The page cannot run what it shows.** Every value is written with `textContent`, never as markup, and the page is served with a content-security-policy that allows exactly its own script and style by hash and nothing else (no inline attributes, no outside requests). The page's own tests check both.
|
|
48
|
+
- **Bounded input.** A request body over a megabyte is refused, and a receipt id must be a UUID, so a path cannot be read through it.
|
|
49
|
+
- **Everything it changes is recorded**, in an append-only file in its state directory, and the policy it replaces is kept.
|
|
50
|
+
|
|
51
|
+
## Limits
|
|
52
|
+
|
|
53
|
+
- It does not issue grants. A grant is signed by a principal's key, which belongs where grants are issued ([configuration.md](configuration.md#the-principals-key)).
|
|
54
|
+
- It does not edit `gateway.json`: upstreams, facts, and `precommit` are changed in the file, and the gateway restarted. The Overview and Check tabs show them.
|
|
55
|
+
- A policy change needs a gateway restart.
|
|
56
|
+
- The credential variables are not checked in the console, and an upstream that needs one is not started there.
|
|
57
|
+
- One token, no per-user accounts, and the audit records the address and not a person.
|
|
58
|
+
- It reads the local receipts directory. With a remote log it verifies receipts against the keys but not the log's inclusion proofs.
|
|
59
|
+
- A shared gateway has one policy and one key for every agent on it, so the console edits one policy.
|
|
60
|
+
|
|
61
|
+
## API
|
|
62
|
+
|
|
63
|
+
Every route except `GET /` (the page) and `GET /healthz` needs `Authorization: Bearer <token>`.
|
|
64
|
+
|
|
65
|
+
| route | does |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `GET /api/overview` | the configuration summary, the gateway's health, and the static check |
|
|
68
|
+
| `POST /api/check` `{ connect? }` | the check; `connect` starts the upstreams |
|
|
69
|
+
| `GET /api/policy` | the policy text, its digest, and the earlier versions kept |
|
|
70
|
+
| `POST /api/policy/validate` `{ text }` | does Cedar parse it, and which things need confirming (`issues`) |
|
|
71
|
+
| `POST /api/policy/simulate` `{ text }` | replay up to 1,000 verified receipts against it |
|
|
72
|
+
| `PUT /api/policy` `{ text, expectDigest, confirm? }` | save it; `400` unless `confirm` is true when the policy has an issue the validate route reported; `409` if the file changed |
|
|
73
|
+
| `POST /api/grants/inspect` `{ grant }` | status, agent, scopes, window, digest |
|
|
74
|
+
| `POST /api/grants/revoke` `{ grant }` | add its digest to the revocation file |
|
|
75
|
+
| `GET /api/revocations` | the revoked digests |
|
|
76
|
+
| `GET /api/receipts?limit=` | recent receipts with their verdicts; `GET /api/receipts/<id>` is one statement |
|
|
77
|
+
| `GET /api/audit` | the console's audit trail |
|
|
78
|
+
|
|
79
|
+
Programmatically: `serveConsole({ configFile, token, port?, host?, gatewayUrl?, stateDir? })` returns `{ url, close() }`.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Safe financial operations
|
|
2
|
+
|
|
3
|
+
An API response is evidence of an API call. Settlement is a separate outcome. Configure `operations` on the gateway to give each payment a durable identity, reserve its amount before forwarding, and close uncertain outcomes with a signed provider reconciliation receipt. [Example 29](../examples/29-financial-operations.ts) runs a payments stand-in, drops a response after acceptance, restarts the gateway, and verifies the reconciliation.
|
|
4
|
+
|
|
5
|
+
## Configuration
|
|
6
|
+
|
|
7
|
+
Add this to a gateway config whose upstream advertises `stripe.refund` and the read-only `refund.lookup`:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"operations": {
|
|
12
|
+
"database": "operations/operations.sqlite",
|
|
13
|
+
"budgets": [{ "id": "refunds", "currency": "GBP", "limit": 100000 }],
|
|
14
|
+
"tools": [{
|
|
15
|
+
"tool": "stripe.refund",
|
|
16
|
+
"budget": "refunds",
|
|
17
|
+
"amountField": "amount",
|
|
18
|
+
"currencyField": "currency",
|
|
19
|
+
"idempotencyHeader": "Idempotency-Key",
|
|
20
|
+
"reconcile": {
|
|
21
|
+
"tool": "refund.lookup",
|
|
22
|
+
"args": { "key": "$operation.idempotencyKey" },
|
|
23
|
+
"statusPath": "status",
|
|
24
|
+
"identityPath": "idempotencyKey",
|
|
25
|
+
"confirmed": ["succeeded"],
|
|
26
|
+
"failed": ["failed"],
|
|
27
|
+
"pending": ["pending"]
|
|
28
|
+
}
|
|
29
|
+
}]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Amounts and limits are safe integers in minor units; an amount must be positive. Currency must match the budget's three-letter uppercase code. The amount and currency field defaults are `amount` and `currency`. The default REST header is `Idempotency-Key`; `identityPath` defaults to `idempotencyKey`, and `pending` defaults to an empty list. Other fields above are required. Tool names and budget ids must be unique, and reconciliation status lists must be disjoint.
|
|
35
|
+
|
|
36
|
+
The database path resolves relative to the config. Its parent directory must be owner-only (`0700`); the gateway creates a missing directory and creates/tightens the database to `0600`. The database contains recovery data, provider responses, and private commitment salts. Keep it private and durable alongside the signing key. Never delete operation records to implement retention or reset a budget: those records prevent old calls from being forwarded again. Financial operations load `node:sqlite` lazily and need Node 22 with that module available.
|
|
37
|
+
|
|
38
|
+
All sessions and gateway processes sharing a budget must use the same SQLite database on the same machine, with the same budget configuration. Use a remote log for multiple gateway processes; a local receipt log has one writer. Budgets cover UTC calendar days. Unknown, submitted, pending, and confirmed operations continue to count in their original day; a retry never moves a reservation into a new day. A new day gets its own daily limit.
|
|
39
|
+
|
|
40
|
+
## Provider contract
|
|
41
|
+
|
|
42
|
+
The provider must honor the supplied idempotency key. REST financial tools receive it in the configured header, overriding any static header of that name. MCP financial tools receive `_meta["agent-custody/operation"] = { id, idempotencyKey }` and must pass the key to their payment provider. A2A financial upstreams are refused because they have no payment idempotency contract.
|
|
43
|
+
|
|
44
|
+
Reconciliation is a read from the provider's authoritative operation record. A REST reconciliation tool must use GET. Its arguments may substitute only `$operation.idempotencyKey`, beside configured constants. The template cannot copy `$operation.id`: the agent chose that UUID, and it must not reach a receipt. The result must contain JSON in its first text item. `statusPath` and `identityPath` traverse own properties using dot-separated names. The identity must equal the operation's idempotency key; a missing or unrelated record cannot close a reservation. The configured `failed` states must mean a terminal provider failure that cannot later settle. An absent record, a transport failure, and an HTTP error are uncertain outcomes and must never be mapped to terminal failure.
|
|
45
|
+
|
|
46
|
+
The write upstream, read upstream, and reconciliation configuration are bound into the durable operation. Reconciliation refuses a changed provider configuration. Its lookup arguments, identity path, and terminal mappings are also committed in the original signed authorization. The gateway observes the provider read; this is not an independent provider signature.
|
|
47
|
+
|
|
48
|
+
## Calling and retrying
|
|
49
|
+
|
|
50
|
+
Generate and persist one lowercase UUID before a consequential call, then retain it across transport failures and restarts:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { randomUUID } from "node:crypto";
|
|
54
|
+
import { OPERATION_META_KEY } from "@agent-custody/receipts";
|
|
55
|
+
|
|
56
|
+
const operationId = randomUUID(); // persist with the business operation before sending
|
|
57
|
+
const call = {
|
|
58
|
+
name: "stripe.refund",
|
|
59
|
+
arguments: { amount: 2500, currency: "GBP", customer_id: "cust_123" },
|
|
60
|
+
_meta: { [OPERATION_META_KEY]: operationId },
|
|
61
|
+
};
|
|
62
|
+
const result = await client.callTool(call);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The first use atomically binds the UUID to the principal, agent, tool, destination, full argument digest, and budget, and reserves the amount before the authorization or forward. Reusing it for different arguments or identity is refused. Identical calls with distinct UUIDs are separate business operations, so generating a fresh UUID after a timeout defeats retry protection.
|
|
66
|
+
|
|
67
|
+
A retry still checks the current grant and policy. It returns the existing logical operation's result, receipt id, and current operation metadata; it never forwards again or reserves again. A retry that policy allows gets a receipt of its own: `execution.status` is `withheld` (the call was not forwarded again), and `operation.originalReceiptId` names the receipt of the first call. The answer carries its id at `_meta["agent-custody/retry-receipt"]`, and `_meta["agent-custody/receipt"]` stays the receipt that holds the outcome. If the gateway died after authorization but before its outcome receipt, the retry reports `unknown` and returns the original signed authorization under `_meta["agent-custody/authorization"]`. There may be no `<originalReceiptId>.json` in that case; the authorization is sufficient for reconciliation.
|
|
68
|
+
|
|
69
|
+
The signed receipt's `execution.status` describes the API call. Its separate `operation.status` records the financial lifecycle:
|
|
70
|
+
|
|
71
|
+
| outcome | meaning | budget |
|
|
72
|
+
| --- | --- | --- |
|
|
73
|
+
| `submitted` | durable reservation exists; forwarding may still be in progress | held |
|
|
74
|
+
| `pending` | API answered; settlement awaits an authoritative read | held |
|
|
75
|
+
| `unknown` | provider acceptance or settlement is uncertain | held |
|
|
76
|
+
| `confirmed` | reconciliation read confirms final success | consumed in the original day |
|
|
77
|
+
| `failed` | reconciliation read confirms terminal failure, or the gateway proves it withheld the forward | released |
|
|
78
|
+
|
|
79
|
+
An initial success response remains `pending` until reconciliation. An HTTP error or thrown call becomes financially `unknown`, even if API execution is `failed` or `error`. Financial authorization logging fails closed in observe mode too; observe suspends Cedar enforcement, never idempotency, budget enforcement, or the required authorization append.
|
|
80
|
+
|
|
81
|
+
## Reconciling
|
|
82
|
+
|
|
83
|
+
An operator holding the config and signing key runs:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
agent-custody reconcile --config gateway.json --operation <uuid>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The command prints JSON with `operation`, terminal `status`, and the receipt file path. A pending/unknown record causes a nonzero exit and keeps the reservation; run the command again after the provider record changes. Repeated completed reconciliations return the same bundle. The operator can reconcile after the original agent's grant expires or is revoked, because this reads an existing operation and sends no new payment.
|
|
90
|
+
|
|
91
|
+
In code, `await host.reconcile(operationId)` returns the bundle. This method is on `GatewayHost` and is never advertised as an agent tool. To recover operation ids after a crash, open the configured `OperationStore` and inspect `store.list()`; close the connection when finished. A submitted operation owned by a live process is refused until that forward returns. After a killed process, its submitted authorization can be reconciled. The gateway stores the creator's PID with its kernel start time (`/proc/<pid>/stat`, or `/bin/ps` with the time zone pinned to UTC where there is no `/proc`, because `ps` prints local time). A live process with the same PID and another start time is not the creator, so a gateway that is PID 1 in a restarted container does not block recovery. When the gateway cannot read a start time, it treats the PID as the creator and recovery waits: it never releases the budget of a live forward. The check needs the creator and the operator to share one PID namespace, such as `docker exec` into the gateway container. A second container on the same volume sees other PIDs and must not run `reconcile` while a gateway can still be forwarding.
|
|
92
|
+
|
|
93
|
+
The gateway saves the signed authorization before it forwards. A submitted operation with a dead creator and no saved authorization therefore proves that the call was never sent. `reconcile` closes it with a receipt, with `execution.status: "withheld"` and `operation.status: "failed"`, and then releases the reservation. It makes no provider read. A wrong liveness answer cannot cause a double forward: the creator saves its authorization with a compare-and-set, and it refuses to forward once recovery has closed the operation. Recovery in turn refuses to close the call when an authorization was saved meanwhile. A retry of a closed call is told that the call was not sent and that a new operation id is needed. The recovery store keeps the call's request values until then, so keep the database private.
|
|
94
|
+
|
|
95
|
+
The reconciliation embeds the original receipt or pre-forward authorization, preserves operation identity, and records the configured provider read as `execution.result`. It commits the exact signed/captured receipt and private salts in the recovery store before appending it. Only after the log accepts that receipt does a terminal failure release budget. A log outage or process crash retains the amount; retry uses the same signed bytes and salts. Concurrent recovery can append identical evidence more than once, but cannot choose conflicting terminal outcomes or duplicate a payment.
|
|
96
|
+
|
|
97
|
+
Verify it with the usual `agent-custody verify` command and the gateway/principal public keys. Both verifiers check the original signature and inclusion proof, operation linkage, precommitted lookup, provider record identity and final status, result digest, and log order. Capture rules apply to the reconciliation result too: withheld provider details verify as committed until disclosed or decrypted. The operation metadata never copies the payment amount into clear fields. Under a private capture rule, `operation.id` is withheld too, as one commitment, because the agent chose it. Receipts link by the gateway-derived `idempotencyKey`, which stays in clear.
|
|
98
|
+
|
|
99
|
+
A reconciliation receipt records a provider read. The gateway evaluated no policy for it, and it did not run the payment tool again. Its `policy.reasons` say so. The OpenTelemetry span and the Splunk event mark it: the span has `agent_custody.reconciliation` and `agent_custody.operation.status`, no policy decision, and the status `reconciled`. The span status is an error when the provider reports the operation as failed. A dashboard therefore never counts it as a second allowed call. `explain` and `review` also show it as a provider read (`reconciled`), not as an allowed execution of the tool.
|
package/docs/policies.md
CHANGED
|
@@ -114,6 +114,7 @@ The memory server in `@agent-custody/state` is an upstream like any other, so it
|
|
|
114
114
|
| `memory.read` | the query, and `includeClaimed` or `requireVerified` when the caller asks for them | |
|
|
115
115
|
| `memory.retract`, `memory.forget`, `memory.hold`, `memory.release` | `factId` and `reason` | `target`, the fact being changed |
|
|
116
116
|
| `memory.sweep` | `before`, `space`, `reason` | |
|
|
117
|
+
| `memory.repair` | `reason`, and optionally `before` (an earlier cutoff) | |
|
|
117
118
|
| `memory.confirm` | `factId` | |
|
|
118
119
|
|
|
119
120
|
A looked-up `target` has `space`, `actor`, `provenance` (`claimed`, `attested`, or `verified`), `subject`, `predicate`, `value`, and `retracted`. Fields that would be null are absent, so test with `has`. The lookup config that makes `target` available is in the [state package README](../../state/README.md#the-memory-server).
|
|
@@ -199,3 +200,25 @@ const d = evaluate(policy, {
|
|
|
199
200
|
```
|
|
200
201
|
|
|
201
202
|
Write one case per branch of every `when` clause, plus one for the missing-attribute path.
|
|
203
|
+
|
|
204
|
+
## Simulating a policy against recorded history
|
|
205
|
+
|
|
206
|
+
Use `policy simulate` before enforcing a tighter policy. It verifies local receipt bundles with your public keys, then evaluates the proposed Cedar text against the arguments and fact values each receipt recorded at call time. Gateway receipts also supply the principal and scopes from their signed delegation as `context.grant`; SDK receipts keep their original context of `args` and `facts: {}`. Replay runs offline, without fetching new facts or executing tools.
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
agent-custody policy simulate --policy proposed.cedar --receipts receipts \
|
|
210
|
+
--issuer-key keys/gateway.pub --principal-key keys/principal.pub \
|
|
211
|
+
--out simulation.json
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
For SDK receipts, use the application's public key as `--issuer-key`; no principal key is needed. Add `--log-key keys/log.pub` when another key signed the log's tree heads. Add `--approval-key keys/approver.pub` when the history holds calls that a human approved: `verify` needs those keys for a forwarded call that carries an approval, and the command fails without them. Each key flag may be repeated when the history spans several keys. The directory is read in filename order, without recursion, one bundle at a time, so it never holds the tool results of the whole history in memory. A malformed or unverifiable bundle, or invalid Cedar syntax in the proposed policy, fails the command.
|
|
215
|
+
|
|
216
|
+
A gateway that dies after it forwards a `precommit` call leaves `<id>.authorization.json` and no `<id>.json`. The command verifies each such file as an authorization statement (the issuer key, the tree head, and the inclusion proof) and lists the call under `skipped`, so the report is `INCOMPLETE`. An authorization that does not verify fails the command. An authorization that sits beside its receipt is not read twice.
|
|
217
|
+
|
|
218
|
+
A receipt under a capture rule needs its withheld arguments and fact values to replay. Give `--capture-key-env NAME` to decrypt the values that mode `encrypted` withheld, as `verify` does. Give `--disclose <file>`, which you can repeat, for the values that mode `digest` withheld. Each file is a disclosure as `reveal` writes it, and it applies only to the receipt that its `receiptId` names. A key or a disclosure that does not match a commitment skips that receipt as malformed. The key comes from the environment, never from a flag value.
|
|
219
|
+
|
|
220
|
+
The report lists every call whose `allow` or `deny` decision changes, grouped by tool and the proposed decision's policy ids or evaluation errors, with the receipt ids and both decisions. A call executed in observe mode may already have a recorded deny: replay compares that recorded decision, not whether the tool ran. Calls with the same decision stay unchanged even when different policy ids match. Cedar evaluation errors remain denials.
|
|
221
|
+
|
|
222
|
+
Every run records a `runId`, `timestamp`, the proposed text's sha256 as `policyDigest`, and the original digests as `previousPolicyDigests`. `--out` saves the full JSON report, and `--json` prints it to stdout. Changes alone exit 0. A report that cannot replay every call says `INCOMPLETE` and exits 1: `skipped` names each receipt and why. This includes record-only receipts with no policy baseline, withheld arguments or fact values, calls whose receipt is missing, and calls stopped before Cedar could evaluate. Grant failures cannot become permits through a policy change, and neither can an approval refusal: the gateway checks the approval before Cedar runs, so the call is skipped as a non-policy gate. The approval record says so even under a private rule. Withheld results alone do not prevent replay.
|
|
223
|
+
|
|
224
|
+
The report is an analysis of the supplied receipt directory; it does not prove that the directory contains the whole history. Keep the report beside the proposed policy and review the changed receipt ids before switching from observe mode to enforcement. [Tutorial 28](../examples/28-policy-simulation.ts) records three refunds, stops the gateway, and replays them against a lower limit.
|
package/docs/threat-model.md
CHANGED
|
@@ -100,6 +100,19 @@ Each row names the attacker, the move, the defence, and whether the defence is a
|
|
|
100
100
|
| Steal a tenant token | Tokens are bearer secrets; a stolen one appends noise to that tenant's log until revoked. Rate limits bound the damage per second; the tenant's usage shows it. | deployment |
|
|
101
101
|
| Escape a per-address limit by forging `X-Forwarded-For` | Behind the proxy the deployment runs, the limiter keys on the address the proxy appended, the rightmost entry, never on one the client supplied. | deployment |
|
|
102
102
|
|
|
103
|
+
### On the portal accounts
|
|
104
|
+
|
|
105
|
+
The portal is not part of the evidence: it publishes policy names and mints log tokens. A stolen account can mint a token, so the portal limits who may.
|
|
106
|
+
|
|
107
|
+
| attack | defence | kind |
|
|
108
|
+
| --- | --- | --- |
|
|
109
|
+
| Guess or steal a member's password | Optional TOTP MFA on the account. A code works once, wrong codes are throttled per address and per account, and the half-signed-in cookie is never a session. A GitHub or Google sign-in goes through the same code step. | deployment |
|
|
110
|
+
| A member acts beyond their job | Four roles: `readonly` reads, `reviewer` also publishes policy versions, `admin` also manages keys and members below owner, `owner` also manages billing and owners. A new write route needs `admin` unless it is listed. The last owner cannot be removed or demoted. | deployment |
|
|
111
|
+
| Claim an invited address to join a tenant | An invite is accepted only by an account with a verified address, and an account belongs to one tenant. | deployment |
|
|
112
|
+
| Sign in through an IdP the tenant does not own | The operator sets single sign-on, never the tenant. An IdP is trusted only for the email domains of its tenant, and a domain belongs to one tenant. The portal checks the OIDC `id_token` signature against the IdP's key set, or the signed SAML assertion through a maintained library, and ties the sign-in to the request that started it. | deployment |
|
|
113
|
+
| Lock a member out of their SSO tenant by registering their address first | The IdP proves the address, so it wins over an account that never verified it. The sign-in deletes that account with its password, sessions, memberships, and linked providers. A tenant that the account created stays, for the operator to deal with. Registering with a tenant, or linking a provider, does not change this. The one limit: an account in another tenant that has other members is refused, so that tenant keeps its members. | deployment |
|
|
114
|
+
| Keep access after leaving the company | With enforcement on, members sign in only through the IdP, so removal at the IdP ends access at the next sign-in. Sessions that began earlier end when enforcement is turned on. A member removed in the portal loses access at once, also in an SSO tenant: the IdP sign-in joins them again only after an admin invites the address again, also when they never verified their address. An API key that the member minted stays valid until an admin revokes it. | deployment |
|
|
115
|
+
|
|
103
116
|
## What is not defended
|
|
104
117
|
|
|
105
118
|
Stated plainly, because a security review that finds these itself will not believe the rest.
|
package/docs/tutorials.md
CHANGED
|
@@ -37,6 +37,11 @@ Suggested reading order is the numbering. Output lands in `examples-out/`, which
|
|
|
37
37
|
| 25 | an agent delegating to an agent over A2A | [25-a2a-delegation.ts](../examples/25-a2a-delegation.ts) | a stand-in document agent speaking A2A 1.0, the gateway serving A2A in front of it with the document agent's card at its own address, an engagement agent delegating twice as an A2A client: one task allowed and answered with the receipt id in its metadata, one refused as a rejected task because it names a privileged matter, the policy deciding on the card the gateway fetched itself; both receipts verified, the allowed one carrying the card as a fact and the authorization logged before the task went out | `src/a2a.ts`, `src/gateway.ts` |
|
|
38
38
|
| 26 | private evidence | [26-private-evidence.ts](../examples/26-private-evidence.ts) | a capture rule for a refund: the arguments encrypted except the amount and the customer id, the provider's answer and the customer record withheld as digests; the receipt file carrying commitments and none of the phone number, the card, the note, or the record; verified as committed without the key; `reveal` with the key writing the disclosure and `verify --capture-key-env` recomputing every digest; a disclosure that lies failing the commitment | `src/capture.ts`, `src/verify.ts` |
|
|
39
39
|
| 27 | revoking an agent's authority mid-session | [27-revocation.ts](../examples/27-revocation.ts) | a support agent and the sub-agent it delegated to, both mid-session on one gateway, cut off on their next call when the operator runs `agent-custody revoke` from another process: no key rotated, no restart, each refusal a signed receipt that verifies, and a new session, a repacked grant, or a fresh delegation from it all refused | `src/gateway.ts` (`revokedGrants`, re-read on every call), `src/delegation.ts` (`grantDigest`, the chain), `src/cli.ts` (`revoke`) |
|
|
40
|
+
| 28 | policy simulation | [28-policy-simulation.ts](../examples/28-policy-simulation.ts) | three refunds recorded in observe mode, then the gateway stopped and their receipts replayed against a lower limit: only one changes decision, grouped by tool and reason with its receipt id, the proposed policy digest saved with the run | `src/simulate.ts`, `src/cli.ts` |
|
|
41
|
+
| 29 | financial operations | [29-financial-operations.ts](../examples/29-financial-operations.ts) | a refund accepted before its response is dropped, a restart and retry producing no second request, the unknown reservation blocking an over-budget refund, and a provider reconciliation receipt that verifies | `src/operations.ts`, `src/gateway.ts`, `src/verify.ts` |
|
|
42
|
+
| 30 | payload-bound human approvals | [30-payload-bound-approvals.ts](../examples/30-payload-bound-approvals.ts) | two people sign the exact refund; missing approval, one signer, changed amount or beneficiary, extra arguments, and expiry are refused; the approved call executes once, its replay is refused, and every receipt verifies with separately trusted approval keys | `src/approval.ts`, `src/gateway.ts`, `src/verify.ts` |
|
|
43
|
+
| 31 | enterprise sign-in and roles | [31-enterprise-sign-in.ts](../examples/31-enterprise-sign-in.ts) | an enterprise tenant signs in through its own identity provider, a stand-in OIDC IdP: the operator sets single sign-on, a member joins as readonly and is refused a policy write, an owner promotes them to reviewer, and enforcement turns password sign-in off | `src/sso.ts`, `src/portal.ts` |
|
|
44
|
+
| 32 | the gateway console | [32-console.ts](../examples/32-console.ts) | a gateway that has made two receipts, and its operator's console: a token on every route, the receipts with a verdict each, a stricter policy replayed against the recorded calls before it is saved, the save recorded with the old version kept and a stale edit refused, and a grant inspected, revoked, and then refused by the gateway | `src/console.ts`, `src/console-page.ts` |
|
|
40
45
|
|
|
41
46
|
## How policies are defined, in one paragraph
|
|
42
47
|
|
|
@@ -45,6 +50,10 @@ A policy is a Cedar file. The gateway turns each tool call into a Cedar request:
|
|
|
45
50
|
## Where each guide goes deeper
|
|
46
51
|
|
|
47
52
|
- [usage.md](usage.md): gateway setup and wiring into hosts
|
|
53
|
+
- [codex-recovery.md](codex-recovery.md): the opt-in live Codex support incident, operator-reviewed recovery, and its offline state example
|
|
54
|
+
- [approvals.md](approvals.md): exact-action signatures, two-person thresholds, consumption, and privacy limits
|
|
55
|
+
- [console.md](console.md): the admin console: run it, what each tab does, how it is protected, and its limits
|
|
56
|
+
- [financial-operations.md](financial-operations.md): payment retries, budget reservations, provider contract, and operator reconciliation
|
|
48
57
|
- [sdk.md](sdk.md): the interceptor and every adapter
|
|
49
58
|
- [policies.md](policies.md): the Cedar mapping, evaluation rules, tested examples, gotchas
|
|
50
59
|
- [verification.md](verification.md): every check and what a verified receipt does and does not prove
|