You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 336e191
Browse filesBrowse the repository at this point in the historyBrowse files
fix(security): close out the stored-metadata-body family — project or refuse every further read/copy/evaluate exit (#21144)
Fixes#21120
Clause-②: no (narrowing)
> **Security boundary — human floor. This PR stays in DRAFT.** It
narrows a
> credential-disclosure surface; landing is the maintainer's. No AI seat
flips
> it ready, queues it or arms auto-merge.
## What this does
Stored metadata bodies (`sys_metadata` / `sys_metadata_history`'s
`metadata`
column — stored datasource credential material included) are declared
write-only and are already redacted on the `/meta` and datasource doors
and, as
of #21086, on the generic data door's reads. This PR closes out the
remaining
surfaces that can **serve, copy or evaluate** such a body, so each
either goes
through the one shared redaction seam or refuses — and adds an
enumeration pin
so a future surface fails the pin instead of joining the family
silently.
- **One seam, no second dialect.** The family-wide primitives — the
object set,
the body predicate, the column names and the per-type body redactor —
now live
once in `@objectstack/spec/kernel`, beside the redactor registry they
build
on. The data door's wrappers (projection, `dropType`, the groupBy and
the new
filter/sort refusals) consume that one definition, as do the audit,
analytics
and realtime exits — none of which depends on
`@objectstack/metadata-protocol`.
- **Audit / activity copy** (`@objectstack/plugin-audit`). The audit
writer
copies a stored-metadata row into `sys_audit_log.new_value` /
`old_value` and
`sys_activity.metadata` at write time — a second, admin-readable,
at-rest
store. The copy now projects the body through the shared redactor, so
the
credential is withheld there too, and a one-off migration
(`os migrate audit-metadata-bodies`, dry-run by default, `--apply`,
idempotent)
rewrites the copies already at rest. Fail-closed: a body the redactor
cannot
judge is dropped from the recorded copy.
- **Analytics** (`@objectstack/service-analytics`). A query naming the
stored
body column of these objects as a dimension, measure, filter or sort is
refused (`400 INVALID_FIELD`) at the service door, ahead of every
strategy —
the posture analytics already takes for a member it will not evaluate.
- **Realtime** (`@objectstack/objectql`). A `data.record.*` event
projects its
`after` / `changes` body through the same redactor, so a subscriber to
these
objects' events receives no stored credential. (Predicate/bulk events
carry
only a count, so they were already safe.)
- **Data door filter / sort** (`@objectstack/metadata-protocol`,
maintainer
ruling A). A filter or sort on the body column is refused (`400
INVALID_FIELD`),
the same family and shape as the merged groupBy refusal. This lands on
#21086's
seam, now on `main` (merged in; no stacked branch).
What stays answerable on both tables: every scalar column — `type`,
`name`,
`scope`, `state`, timestamps — is still grouped, filtered, sorted,
counted and
served. Only the body column is affected, and only on these two objects.
## Enumeration pin
`packages/metadata-protocol/src/stored-metadata-body-family.pin.test.ts`
pins
the family: the object set is the boundary, every declared `apiMethods`
verb on
the two objects is a covered read verb (a new verb or a write verb fails
the
pin), and each family surface is enumerated with its disposition and
owning
per-package pin.
## Tests
- spec: the shared seam (register/lookup, fail-closed, by-reference) —
`metadata-type-redaction.test.ts`.
- metadata-protocol: the family enumeration pin; the merged #21086
data-door suite still green on the reconciled seam.
- plugin-audit: the writer redaction (create / update rotation / clean
body) in `audit-writers.test.ts`; the migration planners and driven
runner (dry-run, apply, idempotent) in
`stored-metadata-body-migration.test.ts`.
- service-analytics: the member refusal —
`stored-metadata-body-refusal.test.ts`.
- objectql: the realtime event redaction —
`engine-realtime-stored-metadata-body.test.ts`.
Changed lines well under the 5,000 human-merge threshold.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01MRdbfpy4sQT8bUjmMhxsN7
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(security)!: stored metadata bodies are projected or refused at the audit, analytics, realtime and data-door filter/sort exits too
9
+
10
+
Clause-②: no (narrowing)
11
+
12
+
<!-- adr-0087: not-required (no-migration-prescription) further read/copy/evaluate exits for a stored metadata body (sys_metadata / sys_metadata_history), each routed through the one shared redactor or refused: the audit/activity write-time copy is projected, a data-door filter or sort on the body column is refused (the sibling of the already-registered-as-not-required groupBy refusal), an analytics query member on the body column is refused, and a data.record.* realtime event body is projected. No authorable key, spelling, export or stored shape moves, and no stored row is read differently by any metadata consumer; the published surfaces gain and lose nothing. The other categories are closed on facts: the packages publish (not `unpublished`); no ADR-0087 id covers a filter/sort target, an analytics member or an event body (not `registered` / `already-registered`); and the change is runtime behaviour, not a declaration (not `runtime-interface-only` / `type-surface-only`). -->
13
+
14
+
**BREAKING**: this narrows what three doors accept or serve for the two stored-metadata tables — the generic data door refuses a filter or sort on the body column, the analytics door refuses it as a dimension / measure / filter / sort member, and the realtime event and the audit/activity copy now carry the body as its type's read projection instead of the stored bytes. It ships as `minor` under the launch-window convention for accept-set narrowings. No export or published type changes.
15
+
16
+
**What changes.**
17
+
18
+
-**Audit / activity copy (`@objectstack/plugin-audit`).** The audit writer copies a `sys_metadata` / `sys_metadata_history` row into `sys_audit_log.new_value` / `old_value` and `sys_activity.metadata`. That copy now projects the body through the shared redactor, so stored credential material is withheld from the second store too. A new `os migrate audit-metadata-bodies` command rewrites the copies already at rest (dry run by default, `--apply` to write, idempotent).
19
+
-**Analytics (`@objectstack/service-analytics`).** A query naming the stored body column of these objects as a dimension, measure, filter or sort is refused with `400 INVALID_FIELD`, before any strategy runs — the posture analytics already takes for a member it will not evaluate.
20
+
-**Realtime (`@objectstack/objectql`).** A `data.record.*` event projects its `after` / `changes` body through the same redactor, so a subscriber to these objects' events receives no stored credential.
21
+
-**Data door filter / sort (`@objectstack/metadata-protocol`).** A filter or sort on the body column is refused with `400 INVALID_FIELD`, the same family and shape as the existing groupBy refusal.
22
+
23
+
**What stays answerable.** Every scalar column of these objects — `type`, `name`, `scope`, `state`, timestamps — is still grouped, filtered, sorted, counted and served; only the body column is affected. Every other object is unchanged.
Copy file name to clipboardExpand all lines: content/docs/permissions/tenant-audit-census.mdx
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,7 +122,7 @@ are reported as `undecidable` rather than assumed either way.
122
122
123
123
The same holds twice over for the context. An options argument spelled as a
124
124
literal can be read; one spelled `options`, `{ ...opts }`, or handed through a
125
-
forwarding shim cannot, and **67 of the 218 sites are spelled that way**. A
125
+
forwarding shim cannot, and **67 of the 219 sites are spelled that way**. A
126
126
context resolved from an inline literal or a local `const` can be tested for
127
127
`isSystem`; one arriving from a helper call cannot.
128
128
@@ -187,10 +187,10 @@ reproduce them. Where it disagrees, it disagrees on the page:
187
187
188
188
| carried figure | where it survives | this census |
189
189
| :--- | :--- | ---: |
190
-
| 175 write call sites | quoted in the merged changeset |**218**|
190
+
| 175 write call sites | quoted in the merged changeset |**219**|
191
191
| 24 carrying no tenant context | quoted in the merged changeset |**9** provable and tenancy-enabled; **34** more whose options argument is unreadable |
192
-
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card |**144 of 218** decidable, **74** undecidable |
193
-
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration**|**not reproduced**: 99 decidably elevated, 0 decidably not, 102 undecidable |
192
+
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card |**144 of 219** decidable, **75** undecidable |
193
+
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration**|**not reproduced**: 100 decidably elevated, 0 decidably not, 102 undecidable |
194
194
| 141 and 132, two independent re-derivations | the card that filed this work | — |
195
195
196
196
**The differences are not reconciled, and deliberately so.** The old census's
@@ -207,11 +207,11 @@ would report a smaller number and would not say so.
207
207
208
208
The fourth row is the one worth flagging to anyone citing it. **The 135 / 77%
209
209
figure has no surviving corroboration anywhere in the tree.** This census reads
210
-
99 of 218 (45%) as decidably elevated, with 102 more whose elevation is a
210
+
100 of 219 (46%) as decidably elevated, with 102 more whose elevation is a
211
211
run-time fact — so the claim is neither confirmed nor refuted, and the honest
212
212
answer is that a static reading cannot settle it.
213
213
214
-
⇒ **Cite `9 / 218`, and say what it is**: the sites whose options argument was
214
+
⇒ **Cite `9 / 219`, and say what it is**: the sites whose options argument was
215
215
READ and holds no tenant context, against a decidably tenancy-enabled object.
216
216
That is the control's provable yield surface. ⛔ Do not cite it as "the sites
217
217
without tenant context" — **34 further sites** have an options argument this
@@ -223,31 +223,31 @@ cannot read, and they are neither in nor out.
223
223
224
224
| what | count |
225
225
| :--- | ---: |
226
-
| write call sites on the application surface |**218**|
226
+
| write call sites on the application surface |**219**|
227
227
| …whose object name is statically decidable | 144 |
228
-
| …whose object name is chosen at run time |74|
228
+
| …whose object name is chosen at run time |75|
229
229
| …against an object with tenancy ENABLED | 143 |
230
230
| …against an object that declares tenancy off | 1 |
231
-
| threading a tenant context |134|
231
+
| threading a tenant context |135|
232
232
| PROVABLY carrying none (options read, no context key) |**17**|
233
233
| …of those, against a decidably tenancy-enabled object |**9**|
234
234
| options argument UNREADABLE — may or may not carry one | 67 |
235
235
| …of those, against a decidably tenancy-enabled object | 34 |
236
-
| threading a decidably ELEVATED (`isSystem`) context |99|
236
+
| threading a decidably ELEVATED (`isSystem`) context |100|
237
237
| threading a context that is decidably NOT elevated | 0 |
238
238
| threading a context whose elevation is a run-time fact | 102 |
239
239
240
240
| how the instrument reached the site | count |
241
241
| :--- | ---: |
242
-
| receiver carried a readable engine type |174|
242
+
| receiver carried a readable engine type |175|
243
243
| receiver erased, placed by the object NAME | 24 |
244
244
| receiver erased, placed by an `object: string` PARAMETER | 15 |
245
245
| receiver erased, placed by an `UNTYPED_RECEIVERS` row | 5 |
246
246
247
247
| object name spelled inline | 101 |
248
248
| object name spelled through a `const`| 43 |
249
249
| object name is an `object: string` parameter | 17 |
250
-
| object name is some other run-time expression |57|
250
+
| object name is some other run-time expression |58|
251
251
252
252
### Subtractions the census could NOT defend — enforced
253
253
@@ -297,13 +297,13 @@ holds still. They are required to be HERE and to say WHEN they were true;
297
297
their values are not compared. The reasoning, and the measurement behind it,
0 commit comments