|
| 1 | +--- |
| 2 | +status: accepted |
| 3 | +date: 2026-10-18 |
| 4 | +extends: vitaminc ADR 0002 |
| 5 | +--- |
| 6 | + |
| 7 | +# What a stored value authenticates |
| 8 | + |
| 9 | +Automated reviews of Stack Encrypt keep reporting the same properties as |
| 10 | +vulnerabilities. They are deliberate. This ADR says what a value Stack |
| 11 | +Encrypt stores does and does not authenticate, so a reviewer can check a |
| 12 | +finding against it. The sealing itself is vitaminc's, and the underlying |
| 13 | +decision is vitaminc's ADR 0002 ("Leaves are authenticated; a container's |
| 14 | +membership and order are not"). This applies it to what Stack Encrypt |
| 15 | +stores. |
| 16 | + |
| 17 | +## Decision |
| 18 | + |
| 19 | +**Authenticated**, for every sealed leaf (`"c"`, and each leaf inside a |
| 20 | +nested value): its bytes and type tag, the context it was sealed under |
| 21 | +(including any extension parts and a record's context field), its map key |
| 22 | +or its role as a sequence element, and the wire version. A leaf that opens |
| 23 | +was sealed exactly so, under exactly that context. |
| 24 | + |
| 25 | +**Not authenticated, by design:** |
| 26 | + |
| 27 | +- **A container's membership, order and length.** Which entries a stored |
| 28 | + map holds, and a stored sequence's order, length and duplicates. A |
| 29 | + sequence of records is a set of rows, which a database returns in any |
| 30 | + order and in part. A record's fields are a row's columns, which a query |
| 31 | + selects in part. |
| 32 | +- **A passthrough field.** It is stored in the clear so the record stays |
| 33 | + whole, and comes back exactly as the store holds it. Anyone who can write |
| 34 | + to the store can change it. The exception is a plan's context field: it |
| 35 | + is stored as a passthrough, but every other field was sealed under it, so |
| 36 | + a changed context field fails the expected-context check or leaves the |
| 37 | + sealed fields unable to open. |
| 38 | +- **Which row a leaf belongs to**, unless the context names the row. Two |
| 39 | + leaves sealed under the same column context are interchangeable between |
| 40 | + rows. A caller who needs a value bound to its row puts the row's identity |
| 41 | + (or a tenant) in the context. |
| 42 | + |
| 43 | +## Consequences |
| 44 | + |
| 45 | +- **A typed open separates a failed leaf from a refused shape.** A leaf |
| 46 | + that does not open (wrong key, wrong context, altered bytes) is |
| 47 | + `Error::Aead`. A value whose every leaf opened but whose type or shape the |
| 48 | + target refuses, including a container missing a field the target needs, |
| 49 | + is a shape mismatch: `Error::OpenedType`, not `Aead`. The Go guest maps |
| 50 | + them to `STATUS_AUTH` and `STATUS_ENCODING`. |
| 51 | +- **Review findings of these kinds are not defects.** `AGENTS.md` lists |
| 52 | + them under "Review guidelines", and `.github/copilot-instructions.md` |
| 53 | + repeats them. A finding that a *leaf* is not bound to its context, key, |
| 54 | + role, type or version is still a defect. |
| 55 | +- **Stricter authentication is opt-in, by type.** A caller who needs a |
| 56 | + sequence's positions or a record's field set authenticated will ask for it |
| 57 | + by naming a type that carries that rule, the way `serde_bytes` selects a |
| 58 | + different encoding by type (vitaminc ADR 0002). It is not a default and |
| 59 | + not a flag, and it does not exist yet. |
0 commit comments