Commit c5b9ccc
fix(objectql): privileged driver-level reads join the ambient transaction (#11435)
* fix(objectql): privileged driver-level reads join the ambient transaction
The engine's three privileged read verbs — resolveSecret,
resolveSecretField and resolveInternalField — read at DRIVER level on
purpose: that is the only layer where a masked or `internal: true`-omitted
value still exists, and bypassing hooks, field-level security and sharing
is the declared trust each places in its in-process caller. What they also
bypassed, not by design, was the connection the surrounding transaction is
holding: buildDriverOptions threads the ambient handle (ADR-0034) onto
every ordinary read, while these three passed the driver NO options, so
their read went to a FRESH pooled connection.
Invisible on a roomy pool; a deadlock on a single-connection one. SQLite's
knex pool is max=1 (driver-sqlite-wasm and driver-sql/better-sqlite3 both),
which encodes SQLite's single-writer model rather than a tuning choice.
Where the two met: AuthManager.handleRequest runs SESSION_ERASURE_PATHS
inside engine.transaction(...), the vendor's session re-read reaches
resolveInternalField through plugin-auth's internal-field readback, and the
read waited for a connection that could not be freed until the transaction
waiting on the read finished. knex's acquire timeout fired and the route
degraded the block into an authentication refusal. Measured on the default
datasource before this change: a caller better-auth's own admin gate ADMITS
answered 401 after 120,196ms with the target row still present, and a
signed-in member got the same 401 after 120,025ms instead of
403 YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS. After: 200 with the row deleted,
403, and an anonymous caller's 401 unchanged — all prompt.
Reads only; the privileged write paths are untouched. The #5351 same-origin
gate still decides whether the handle is this object's driver's to use, so
a privileged read resolving to a different datasource keeps its own
connection.
The dogfood admin-route sweep's remove-user carve-out (which accepted
UNAUTHENTICATED as an additional denial code) is deleted with the defect.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01APWX2AwT3a4xDcjPCe8bk4
* test(objectql,verify): keep the two new test files inside the TEST_DEBT ratchet
`check:type-check-debt --re-measure` counts raw `tsc --noEmit` errors per
package with the test exclusion lifted, so a package's own green `typecheck`
says nothing about the files it hides. Both new files landed inside that
hidden layer and drifted the shrink-only ledger: @objectstack/objectql 354 ->
364 (+10) and @objectstack/verify 8 -> 9 (+1). Every one of the 11 was in the
new files, so the drift is attributable, not inherited.
Fixed rather than re-baselined — raising a shrink-only entry is maintainer-only
and hands back what an earlier PR paid to press it down:
- registerObject(schema, packageId, ...) requires 2 arguments; the three
calls passed 1. Supplied '__test__', the packageId the sibling engine
transaction tests already use.
- Array.prototype.at sits above the `lib` this program targets. Replaced the
seven `.at(-1)!` sites with a local indexed `last()` helper rather than
widening the compiler configuration for a test convenience.
- './harness' -> './harness.js'; NodeNext needs the explicit extension, and
two sibling verify tests already spell it that way.
Re-measured after the repair: objectql 354 = ledger 354, verify 8 = ledger 8,
zero errors in either new file.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01APWX2AwT3a4xDcjPCe8bk4
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 20cecbb commit c5b9ccc
5 files changed
Lines changed: 468 additions & 24 deletions
File tree
- .changeset
- packages
- objectql/src
- qa/dogfood/test
- verify/src
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 205 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5937 | 5937 | | |
5938 | 5938 | | |
5939 | 5939 | | |
| 5940 | + | |
| 5941 | + | |
| 5942 | + | |
| 5943 | + | |
| 5944 | + | |
| 5945 | + | |
| 5946 | + | |
| 5947 | + | |
| 5948 | + | |
| 5949 | + | |
| 5950 | + | |
| 5951 | + | |
| 5952 | + | |
| 5953 | + | |
| 5954 | + | |
| 5955 | + | |
| 5956 | + | |
| 5957 | + | |
| 5958 | + | |
| 5959 | + | |
| 5960 | + | |
| 5961 | + | |
| 5962 | + | |
| 5963 | + | |
| 5964 | + | |
| 5965 | + | |
| 5966 | + | |
| 5967 | + | |
| 5968 | + | |
| 5969 | + | |
| 5970 | + | |
| 5971 | + | |
| 5972 | + | |
| 5973 | + | |
| 5974 | + | |
| 5975 | + | |
| 5976 | + | |
| 5977 | + | |
| 5978 | + | |
| 5979 | + | |
5940 | 5980 | | |
5941 | 5981 | | |
5942 | 5982 | | |
| |||
5953 | 5993 | | |
5954 | 5994 | | |
5955 | 5995 | | |
5956 | | - | |
| 5996 | + | |
| 5997 | + | |
| 5998 | + | |
| 5999 | + | |
| 6000 | + | |
5957 | 6001 | | |
5958 | 6002 | | |
5959 | 6003 | | |
| |||
6018 | 6062 | | |
6019 | 6063 | | |
6020 | 6064 | | |
6021 | | - | |
| 6065 | + | |
| 6066 | + | |
| 6067 | + | |
| 6068 | + | |
| 6069 | + | |
6022 | 6070 | | |
6023 | 6071 | | |
6024 | 6072 | | |
| |||
6100 | 6148 | | |
6101 | 6149 | | |
6102 | 6150 | | |
6103 | | - | |
6104 | | - | |
6105 | | - | |
6106 | | - | |
| 6151 | + | |
| 6152 | + | |
| 6153 | + | |
| 6154 | + | |
| 6155 | + | |
| 6156 | + | |
| 6157 | + | |
| 6158 | + | |
6107 | 6159 | | |
6108 | 6160 | | |
6109 | 6161 | | |
| |||
Lines changed: 14 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
585 | 585 | | |
586 | 586 | | |
587 | 587 | | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
593 | 594 | | |
594 | | - | |
595 | | - | |
596 | | - | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
597 | 598 | | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
608 | 604 | | |
609 | 605 | | |
610 | 606 | | |
| |||
0 commit comments