Skip to content

Commit 7c1a0ab

Browse files
authored
Merge pull request #1258 from cipherstash/docs/integrity-model-review-guidance
docs: record what a stored value authenticates, and tell reviewers what is not a finding
2 parents b5ed21e + 7ab2614 commit 7c1a0ab

3 files changed

Lines changed: 112 additions & 0 deletions

File tree

‎.github/copilot-instructions.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copilot instructions for cipherstash/stack
2+
3+
The project instructions are in `AGENTS.md`. When reviewing a pull request,
4+
follow its "Review guidelines", in particular these known non-findings,
5+
which are deliberate design decisions and not defects:
6+
7+
- A sealed container's membership, order and length are not authenticated:
8+
which entries a stored map holds, and a stored sequence's order, length
9+
and duplicates, are not bound into any AAD, because stored values are
10+
database rows and columns that come back in any order and in part. A
11+
target that refuses a container's shape is a shape mismatch
12+
(`Error::OpenedType`), not tampering (`Error::Aead`).
13+
- A passthrough field is stored in the clear and is not authenticated,
14+
except a plan's context field, which every other field is sealed under.
15+
- Two leaves sealed under the same context are interchangeable between rows;
16+
binding a value to its row is the caller's choice of context.
17+
18+
A leaf that is not bound to its context, map key, role (single value or
19+
sequence element), type tag or wire version is still a defect. See
20+
`packages/stack-encrypt/docs/adr/0010-what-a-stored-value-authenticates.md`.

‎AGENTS.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,39 @@ pnpm changeset:publish
975975
A skills-only change is **not** internal: `skills/` ships inside the
976976
`stash` tarball, so it needs a `stash` patch changeset.
977977

978+
## Review guidelines
979+
980+
These apply to every agent that reviews a pull request here, human-prompted
981+
or automated (Codex, Copilot, CodeRabbit, Claude Code's `/code-review`).
982+
983+
### Known non-findings
984+
985+
These are deliberate design decisions, recorded in ADRs. Do not report them
986+
as defects or security issues, and do not change code to "fix" them. If a
987+
change seems to need one reversed, say so and link the ADR.
988+
989+
- **A sealed container's membership, order and length are not
990+
authenticated.** Each leaf is bound to its context, its map key, its role
991+
(single value or sequence element), its type tag and the wire version. But
992+
which entries a stored map holds, and a stored sequence's order, length
993+
and duplicates, are deliberately not bound: stored values are database
994+
rows and columns, which come back in any order and in part. A target that
995+
refuses a container's shape (a missing field, say) is a shape mismatch,
996+
`Error::OpenedType`, not tampering, `Error::Aead`. Stricter authentication
997+
will be opt-in, through named types. See
998+
`packages/stack-encrypt/docs/adr/0010-what-a-stored-value-authenticates.md`
999+
and vitaminc's ADR 0002.
1000+
- **A passthrough field is not authenticated.** It is stored in the clear,
1001+
by definition, and comes back as the store holds it. A plan's context
1002+
field is the exception: every other field is sealed under it, so a change
1003+
to it is caught. Same ADR.
1004+
- **Two leaves sealed under the same context are interchangeable between
1005+
rows.** Binding a value to its row is the caller's choice of context (a
1006+
row id or tenant in it). Same ADR.
1007+
1008+
A finding that a *leaf* is not bound to its context, key, role, type or
1009+
version is a real defect: report it.
1010+
9781011
## Useful Links
9791012

9801013
- `README.md` for quickstart and feature overview
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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

Comments
 (0)