Found while implementing #6577 (the limit: 0 presence fix), whose file surface was these exact two methods. Out of that card's scope — a different defect with a different blast radius, and folding a tenant-isolation fix into a limit: 0 PR would bury it — so filed rather than fixed, per Prime Directive #10.
Fact (located by inspection on origin/main @ 3172831, not executed)
applyTenantScope says of itself, verbatim:
This is the single chokepoint for read-side tenant isolation in the SQL driver; every CRUD method routes through it.
It is called at 13 sites in packages/drivers/driver-sql/src/sql-driver.ts — findRows (the door find() uses), the readbacks, count, distinct, the write paths. It is not called by two:
So the declared invariant is false as written: two doors bypass the chokepoint.
Why the two are not equally severe
What is NOT claimed here
Not measured end-to-end. I did not build a multi-tenant fixture and read another tenant's rows through this door — this is located by reading the call sites and the method's own contract, and it is stated at that strength deliberately. What reaches findWithWindowFunctions in practice needs checking before grading severity: it is not on IDataDriver (it is callable only on a SQL driver instance, per its own docstring), so the exposure depends on who calls it and whether they pass options.tenantId. A grader should measure that reachability first — it is the difference between a latent trap and a live P0.
Also note the layers above: ADR-0021 RLS and the Layer 0 authorization wall may or may not already constrain the callers of this door. "The layer above catches it" is a reason to grade lower, not a reason for the driver's own stated chokepoint to have a hole.
Suggested shape of a fix (not prescriptive)
Add this.applyTenantScope(builder, object, options) to both, beside the getBuilder call, as every other door does. The interesting question is not the two lines but the missing enforcement: nothing makes a new read door route through the chokepoint, which is exactly how these two got out. A gate that asserts every method taking (object, …, options) and returning rows calls applyTenantScope would be the durable version — the check:-script shape this repo already uses for the same class of claim.
Dedup
Searched applyTenantScope, findWithWindowFunctions, and tenant-scope/read-door phrasings across the repo's issues. Nearest neighbours are all closed and different: #3724 (driver-mongodb has no row-level isolation at all), #3249 / #2754 (tenant scope hiding NULL-org platform rows — the opposite direction), #4286 (window-function door liveness, not its tenancy). No open card covers this.
Filed unassigned, finding posture.
Found while implementing #6577 (the
limit: 0presence fix), whose file surface was these exact two methods. Out of that card's scope — a different defect with a different blast radius, and folding a tenant-isolation fix into alimit: 0PR would bury it — so filed rather than fixed, per Prime Directive #10.Fact (located by inspection on
origin/main@3172831, not executed)applyTenantScopesays of itself, verbatim:It is called at 13 sites in
packages/drivers/driver-sql/src/sql-driver.ts—findRows(the doorfind()uses), the readbacks,count,distinct, the write paths. It is not called by two:findWithWindowFunctions(object, query, options)— the live window-function read door ([P2] data:QueryASTdeclares 12 members no executor runs — the liveness ledger governs metadata types, not the request surface #4286). Builds viagetBuilder(object, options), applieswhere/ window functions /orderBy/ pagination, and returns rows. NoapplyTenantScope.analyzeQuery(object, query, options)(andexplain(), which forwards to it). Same omission.So the declared invariant is false as written: two doors bypass the chokepoint.
Why the two are not equally severe
findWithWindowFunctionsreturns ROWS. On a deployment whereapplyTenantScopewould have added a predicate — i.e.options.tenantIdis set and the object has a tenant field — this door returns rows from every tenant. That is cross-tenant read exposure at the driver layer, the same class as driver-mongodb 完全没有行级租户隔离:读不加谓词、写不打戳,多租户下跨租户可读写 #3724, not a cosmetic inconsistency.analyzeQueryreturns a PLAN, not rows. Lower severity, but it is the same defect this method was just fixed for in [drivers]InMemoryDriver.findapplieslimiton truthiness, solimit: 0returns every row — the #6485 defect one layer below the client #6577: a plan is only worth reading if it explains the statementfind()would actually run, and a missing tenant predicate makes it a plan for a different query (different selectivity, different index choice).What is NOT claimed here
Not measured end-to-end. I did not build a multi-tenant fixture and read another tenant's rows through this door — this is located by reading the call sites and the method's own contract, and it is stated at that strength deliberately. What reaches
findWithWindowFunctionsin practice needs checking before grading severity: it is not onIDataDriver(it is callable only on a SQL driver instance, per its own docstring), so the exposure depends on who calls it and whether they passoptions.tenantId. A grader should measure that reachability first — it is the difference between a latent trap and a live P0.Also note the layers above: ADR-0021 RLS and the Layer 0 authorization wall may or may not already constrain the callers of this door. "The layer above catches it" is a reason to grade lower, not a reason for the driver's own stated chokepoint to have a hole.
Suggested shape of a fix (not prescriptive)
Add
this.applyTenantScope(builder, object, options)to both, beside thegetBuildercall, as every other door does. The interesting question is not the two lines but the missing enforcement: nothing makes a new read door route through the chokepoint, which is exactly how these two got out. A gate that asserts every method taking(object, …, options)and returning rows callsapplyTenantScopewould be the durable version — thecheck:-script shape this repo already uses for the same class of claim.Dedup
Searched
applyTenantScope,findWithWindowFunctions, and tenant-scope/read-door phrasings across the repo's issues. Nearest neighbours are all closed and different: #3724 (driver-mongodb has no row-level isolation at all), #3249 / #2754 (tenant scope hiding NULL-org platform rows — the opposite direction), #4286 (window-function door liveness, not its tenancy). No open card covers this.Filed unassigned,
findingposture.