9.2 KiB
#922 — a lapsed projected metadata lease is not an access denial
Found in the H3 live gate (H3.md §"Found on the re-run"). Pre-existing v1 projection behaviour (95c5e484).
Root cause
A projected node's authority is its catalog proof, bound to a BoundProjectionLease whose remote MetadataAuthorityLease lasts
MetadataLeaseMilliseconds (15 s on the rig) from the browse that fetched it. Only a subscription ever renewed it
(RemoteNamespaceResolver.RenewExactAsync, Subscribe only). After the lease lapsed:
ProjectedCatalogCache.TryResolveProjected/ValidrequiredLease.IsValid, soProjectedDataAccess.TryAcquirereturnedfalse, and the node manager's Read pre-loop mapped everyfalsetoBadUserAccessDenied. A lapse looked the same as an ACL denial.- HistoryRead:
AuthorizeHistoryRead→DataPlaneAuthorizer→MappedSubjectResolver(TryResolveProjected) returnedDeny⇒BadUserAccessDenied. - Re-browse: a cached parent page is served while its own lease holds, and nothing renews on a cache hit. A re-browse just before the page's lease ran out therefore renewed nothing, and the nodes lapsed seconds later (the H06 observation).
Fix
| Piece | Change |
|---|---|
BoundProjectionLease.Renewable |
the lease is invalid ONLY because it is transient: the remote time ran out or the route was replaced, while the local catalog authority, mapping binding and cache generation are current and nothing called Invalidate |
ProjectedCatalogCache.TryResolveForRenewal |
the retained, non-retired proof that is valid or Renewable (every ValidCore fence except the lease) |
OtOpcUaNodeManager.TryResolveForRenewal (+ IProjectedNodeLookup, sinks) |
the committed live definition without the authority check (lock-free snapshot), so the renewal commits against the exact SDK node |
DataOperationPolicy.AuthorizeMappedSubject |
AuthorizeMapped minus the lease checks. Classifies a refusal only and serves nothing |
IProjectedDataAccess.RenewLapsed → ProjectedLapseOutcome {Denied, Renewing, Unavailable} |
Denied unless the node is lapsed-renewable AND the caller holds the grant for the operation (local grant + mapping bit + op-specific checks). Otherwise starts ONE exact renewal per node (RenewExactAsync generalised to authorizeAs/required = Read or HistoryRead; the subscription default is unchanged), off the request thread, inside the unary budget, with a 250 ms back-off after a failure. A successful Read renewal then schedules a read so the retry is served from cache |
| Read pre-loop | Denied ⇒ BadUserAccessDenied (unchanged); Renewing ⇒ BadWaitingForInitialData (as for a cold read); Unavailable ⇒ BadResourceUnavailable. A non-Value attribute of a lapsed node ⇒ BadResourceUnavailable |
AuthorizeHistoryRead |
renews lapsed projected handles within the request (one block-bridged wait per batch, ≤ 5 s, no Lock held — the SDK released it before dispatching, as H3 recorded), re-authorizes, then serves. A renewal that does not complete ⇒ BadResourceUnavailable |
ProjectedBrowseAccess |
an initial cached page past half its lease is served AND refreshed in the background (one in flight per page key) |
The node-manager Lock is never held across a network renewal. The Read path only starts the task. The renewal commits
through IProjectedNamespacePageSink.TryRenewExact, which takes Lock briefly and performs no I/O.
Red / green (Runtime harness, GrpcDataLeaseLapseWireTests, Trait Issue=922, real consumer SDK session + projection stack)
| Test | master (05f431f5d src) |
fix |
|---|---|---|
| value Read after the lease lapses ⇒ retryable, renews on demand without a browse (twice), attribute read not denied | FAIL (BadUserAccessDenied) |
pass |
no local Read grant ⇒ still BadUserAccessDenied after the lapse; no metadata/read call; renewal counter 0 (counted synchronously at admission) |
pass | pass |
| HistoryRead after the lapse ⇒ renewed in the request, Good, 3 values | FAIL (BadUserAccessDenied) |
pass |
lapsed HistoryRead with the origin unreachable ⇒ BadResourceUnavailable, nothing read; Good after recovery |
FAIL (BadUserAccessDenied) |
pass |
no local HistoryRead grant ⇒ still BadUserAccessDenied after the lapse, unsent |
pass | pass |
| re-browse of a cached page past half its lease renews (origin browse call, lease holds at t0+20 s) | FAIL (no origin call) | pass |
Real ACL denial and lease lapse are tested both ways. The lapse cases are red on master and the ACL-denial controls are green on both. 8 consecutive green runs of the six tests after the final assertion fix. Harness note: the fixture origin observes its single sample once, so the sample's origin age grows with the manual clock. The value tests use a stale timeout and client maxAge longer than the idle gaps, so that age stays out of the result under test.
Gates
dotnet build -c Release (solution) 0 errors. Runtime.Tests 2096 passed / 3 skipped / 2 failed under machine load average
100–150: VirtualTagActorTimerTests.Ticks_during_a_slow_run_coalesce_instead_of_piling_up and
GrpcDataConfiguredDiscoveryWireTests.Failed_sdk_item_construction_releases_candidate_and_fanout_ownership (its first
subscription publish was not Good, and it calls no code path changed here). Once load dropped, both passed 12/12 on master src
and 12/12 on the fix. Cause not established, so this is recorded as load-correlated, not as a flake. OpcUaServer.Tests 1460 passed
(+2 skips). Host.Tests 497 passed, including GrpcDataV1CompatibilityTests (goldens untouched). Core.Tests 385 passed (+1 skip).
Live (grpc-data rig, OrbStack, run f922a-sqlserver, --history --history-backend sqlserver)
history_gate.py with the workaround removed: H04 no longer re-browses before its resume, and H06(c) now deliberately idles
LEASE_LAPSE_SECONDS = 20 (> the 15 s lease) after its restore before the held read. H01–H06 all PASS (47/34/35/44/58/238
assertions).
Value-Read probe (one browse, then never again; Client CLI read --max-age 10000 on CONSUMER, raw/counter and uns/scalar):
the fresh-lease control and both idle legs (20 s and 40 s, i.e. past the lease) answer BadWaitingForInitialData then Good on
the next read, with no BadUserAccessDenied anywhere. With the CLI's default --max-age 0, every projected read (lapsed or
not) stays BadWaitingForInitialData, because the v1 Read path never serves maxAge = 0 from cache. That is separate from this
fix and is filed as a follow-up. rig.py down ⇒ 0 containers / volumes / networks / images.
Security review round 1 (no auth bypass; two availability findings + lows) — fixes
Merged local master first (incl. #916/#917, DataConnections), clean, build 0 errors.
| # | Finding | Resolution | Red/green |
|---|---|---|---|
| 1 | A renewal reserved MaxUnaryBytes in the unary budget: (A) a batch of N lapsed nodes renewed only the first, (B) while one ran, every cold read / write / subscription renewal was refused |
renewals left the unary budget: own resolver pool max(1, maxConcurrentFetches/2) (never _fetchSlots), a bounded queue (64), 256 KiB each, 3 s end to end including the pool wait |
A_read_batch_of_several_lapsed_nodes_renews_every_node…, A_history_batch_of_several_lapsed_nodes…, A_renewal_in_flight_does_not_crowd_out_a_cold_read…: all red on the pre-review fix, green now |
| 2 | AuthorizeHistoryRead waited 5 s before the history batch limiter and ignored the request token, so concurrent HistoryReads against a slow origin pinned SDK threads past the 16-batch cap. The wait also equalled the renewal budget |
the wait first takes a non-local history slot with Wait(0) (none free ⇒ no wait, retryable), honours OperationContext.CancellationToken, and lasts 4 s (≤ HistoryReadDeadline) against a 3 s renewal |
Concurrent_history_reads_against_a_slow_origin…: 24 reads against a silent origin, ≥ 24 − RemoteSlots answer in < 2.5 s, all BadResourceUnavailable, origin untouched, Good after release. Red on the pre-review fix (all 24 waited ~5 s) |
| 3 | Two authorities (policy classifies, DataPlaneAuthorizer vetoes) |
a renewal that completed true and is still vetoed ⇒ BadUserAccessDenied |
by construction; the grant-revoked test below covers the revoked case |
| 4 | Renewals keyed by node only, though each requests its operation's bit | keyed by (realm, id, operation), back-off too | — |
| 5 | Back-off map cleared wholesale at 4096; browse refresh deduped per (caller, MaxResults) | expired entries are evicted first, otherwise the one expiring first; one background refresh per parent node | — |
| 6 | Write / CreateMonitoredItems on a lapsed node | documented in docs/DataConnections.md as not covered (still BadUserAccessDenied until a read/browse renews); reported as a follow-up |
— |
New safety controls, green on both the pre-review fix and now: an Invalidated lease ⇒ BadUserAccessDenied, no renewal, no origin
call. A grant revoked while the renewal is parked at the origin ⇒ nothing served, the renewal never commits, then
BadUserAccessDenied. A mapping removed while renewing ⇒ not revived, not answered as a lapse. 13 #922 tests, 5 consecutive green
runs.