Commit f70eb2c
feat(security): ADR-0090 D10 — agent/service intersection runtime (#2838)
When a request's principal acts `onBehalfOf` a user (an AI agent or a
service acting for a person), the effective permission is now the
INTERSECTION of the principal's own grants and the delegator's grants —
never the union. Confused-deputy prevention: an over-privileged agent
may never see or touch anything the user it stands in for could not,
and vice-versa. Previously `principalKind:'agent'` / `onBehalfOf` was a
P1 context shape the evaluator did not read.
Applied at every axis, gated on the delegation link so the non-delegated
path is byte-identical:
- plugin-security: delegator sets reconstructed once (fail-CLOSED on a
dangling link — a deleted delegator is denied, not resolved to the
additive baseline) and AND-composed into the capability gate, object
CRUD, FLS (read mask + write forbid + predicate guard), row-level
`using` pre-image, `check` post-image, and RLS read injection.
View/Modify-All survives only when BOTH principals hold it.
- plugin-sharing: the OWD/record-share owner-match is identity-scoped,
so it re-runs the visibility filter and canEdit under the delegator's
own identity + depth and AND-s it in — an agent with View-All acting
for a plain member sees exactly that member's rows, not everyone's.
- explain engine: every layer reports the narrower verdict for a
delegated principal; a dangling delegator reads as a fail-closed deny.
Delegator resolution + the pure combinators (intersectFieldMasks,
narrowerScope) are single-sourced in explain-engine.ts and reused by
both the enforcement middleware and the explanation, so they can't drift.
Tests: 11 unit (security-plugin.test.ts) exercising the real middleware
+ a served-engine dogfood (showcase-agent-intersection) proving the
intersection strips View-All on a real private-OWD object yet still
surfaces the delegator's own rows. Full suites green: plugin-security
297, plugin-sharing 76, permission/OWD/sharing dogfood unchanged.
First cut: one delegation hop (a safe lower bound on multi-hop);
tenant-scoped substitution bags inherited from the live principal,
person-specific membership bags left unresolved (narrows, never widens).
The agent grant-ceiling lint (D10 rule 2) is a follow-up — the runtime
intersection already caps the agent, and the lint needs an agent-set
designation convention that does not yet exist.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 6da03ee commit f70eb2c
6 files changed
Lines changed: 745 additions & 40 deletions
File tree
- .changeset
- packages
- dogfood/test
- plugins
- plugin-security/src
- plugin-sharing/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 118 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
0 commit comments