Changelog - 2026-11-05
Writes to a child scoped through its parent respect the parent's sharedRows
Security Breaking ChangeIn one line. A model scoped with access.through could be written under a shared parent (a parent row whose scope column is null) by a caller who is not allowed to write that parent. The parent's write.sharedRows now applies to the child's writes, at every hop.
What changed
- The hole. A parent with
resolvereturning{ or: [{ merchantId: { inq: ['m-1'] } }, { merchantId: null }] }andwrite: { sharedRows: false }refuses a write to its shared rows. Itsthroughchildren were not held to that: merchantm-1could update or delete the variants of a shared product, create a variant under it, or move a variant to it. The direct-write version of this was closed earlier; this is the same rule on the hop. - The fix. For
CREATE,UPDATEandDELETE, the parent's scope is narrowed the way a direct write to the parent is, with the parent's ownwritesettings. Update and delete select only the children of parents the caller may write, and a create or a move must name such a parent. Reads are unchanged: the children of a shared parent stay readable. - Several hops. Each hop narrows its own parent, so an
OptionthroughVariantthroughProductanswers toProduct'ssharedRows. - A scope the write guard cannot verify. A parent scope of a shape the guard cannot read on a write (an
orover several columns, a range) now refuses the child's write, as it refuses a direct write to the parent. This includes a child update that never names the foreign key, and a soft delete.
Who is affected
- Models with
access.throughwhose parent reads shared rows (anullbranch) and leaveswrite.sharedRowsoff. Writes to the children of a shared parent are refused now. - The same models with
write.sharedRows: trueon the parent. No action needed. - Models with
resolve, andthroughmodels whose parent has nonullbranch. No action needed.
Breaking changes
WARNING
A write that was allowed before is refused: update and delete skip the children of a shared parent, and a create or a move that names a shared parent returns 403 (core.repository.scope_write_denied).
To keep the old behaviour for a parent whose shared rows the caller may write, set write: { sharedRows: true } on the parent's access.
Details
- The change is in
FilterBuilder.resolveThrough(dialect/filter.ts), the one place both the row selection and the parent-key check read the parent's scope. - Conformance tests on PGlite and libsql cover a shared parent with and without
sharedRows, at one hop and at two.
| File | Package |
|---|---|
src/relational/core/repositories/dialect/filter.ts | connectors |
src/relational/core/repositories/core/base.ts | connectors |