Repository navigation
fix(daemon): require the session lease id on every request to a leased session - #4911
Conversation
Size Report
Startup median (7 runs, lower is better):
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Code at b414200 has blocking problems. The new lease check is the right rule, but a second independent pass found nine routes that still reach a leased session without its lease ID, or refuse it wrongly. No conflicts. The cancelled Body rules job looks like a concurrency cancel from a later edit. The diff does not touch the check, and the body passes the gate when recomputed, so a re-run should pass. Not verified here: live behavior, since no tests were run and the iOS proxy run is author-reported. A second independent pass found that a caller with the shared proxy token and the locator of a diagnostics record in another client's leased session gets the record without a lease ID (packages/daemon/src/server/request-diagnostics-http.ts:137). The proxy forwards this route and static-token mode supplies no attested tenant. The rule: the lease ID presented on the request must match the record's owner before the file opens, and the proxy must forward the existing lease header and keep the typed refusal fields on REST errors. Should ownership travel with the record if it can outlive its session? A second independent pass found that another client with the same proxy token and tenant label can list the artifact ID of a pending screenshot from an active leased session and download it without the lease ID (packages/daemon/src/resources/artifact-tracking.ts:245). Finalization stores only the tenant, and HTTP and RPC inventory and download check only the tenant. The rule: leased output records its producing lease, and the common inventory and download boundary applies that credential through the existing artifact header. Deliberately retained post-lease artifacts keep their current lifetime rules. A second independent pass found that, for an active provider-backed leased session, a caller who knows the provider session ID and declares the tenant can invoke artifacts with no lease (packages/daemon/src/sessions/handlers/lease.ts:556). The provider lookup matches the tenant label only, and the handler then supplies the stored lease ID itself. The rule: active provider-session artifact lookup requires the caller to present the recorded lease ID. Post-close lookup of released provider sessions keeps its retention policy. A second independent pass found that an explicit open of an existing proxy-leased session with the owner labels and no lease ID fails with INVALID_ARGS before the credential check can return LEASE_SESSION_MISMATCH (packages/daemon/src/sessions/request-admission.ts:200). With the right ID and a missing optional label, the same preflight contradicts the label rule in the daemon contract doc. The rule: an existing session runs the session credential assertion first, and the full proxy metadata requirement applies only to fresh opens, rechecked under the session lock. A second independent pass found that a request arriving after the lease deadline but before background expiry settles can tear the session down before its credential is checked (packages/daemon/src/server/request-execution-scope.ts:468). For example, a close with no lease ID consumes the expired entry, and the later check rereads the store after retirement, so no mismatch is returned. A no-ID request can also reach the resource probe first. The rule: the presented credential is checked under the session lock before any request-driven teardown or session-resource inspection, and the expiry owner cleans up independently. A second independent pass found that a devices request with no lease ID resolves the address of an active leased iOS session and refreshes its runner-backed recording (packages/daemon/src/server/request-execution-scope.ts:732). Devices ignores the lease by design, yet the refresh probes the leased device and can invalidate its recording. The rule: lease-independent commands stay detached from the resolved session for recording health, session binding and inline expiry. A second independent pass found that a no-ID doctor request is admitted while its address is empty, and if an owner opens the leased session there before dispatch finishes, doctor returns its session and device evidence (packages/daemon/src/sessions/handlers/session-doctor.ts:67). Doctor is exempt from the session execution lock. The rule: authorize the session at the actual read, or pin an authorized reference at admission, for every unlocked route that rereads session state. A second independent pass found that a replay request with the correct credential in flags.leaseId passes intake, but native replay steps inherit only the listed parent flags, which omit leaseId, so the step fails LEASE_SESSION_MISMATCH where base admitted it (packages/daemon/src/server/request-router.ts:427). The rule: the replay-scoped invoker, including its fallback, uses the same parent lease handoff as ordinary nested calls. A second independent pass found that in a direct batch, the wrapper puts the parent's lease ID in child meta, and the parser prefers it over a different flags.leaseId on a step, so a step with an explicit mismatch now runs (packages/daemon/src/core/lease-context.ts:126). Base refused it. The rule: fill missing child scope fields from the parent only after resolving the child's meta and flags together, keeping any lease ID or labels the child supplied. A second independent pass found that on direct daemon RPC, a replay test attempt's address can already hold a leased session, and cleanup and optional video start and stop then call the close and record handlers directly, bypassing admission (packages/daemon/src/sessions/handlers/session-replay-command.ts:325). The rule: authorize the actual attempt session with the suite's presented credential before its reads and before any direct video or cleanup call, keeping cleanup bound to the lifetime the attempt owned. Not blocking, and each can be taken or left: the connect proxy help line and remote-proxy.md:30 say connect saves the lease ID, but open saves it (cli-help.ts:634); client-api.md:352 could add one sentence that commands on a leased session need the lease's leaseId, else UNAUTHORIZED with reason LEASE_SESSION_MISMATCH; the refusal hint in lease-context.ts:168 could name the leaseId param instead of CLI flags; the session-lease-id capability at http-server.ts:87 has no reader and HTTP_DAEMON_CAPABILITIES could be derived from DAEMON_CAPABILITIES; the find-session-lease test at request-router-find-session-lease.test.ts:87 passes at base, so the Validation line could say it guards the nested hand-down; putHostLease at lease-registry.ts:112 still accepts 64-bit ids for a credential; and request events are recorded for a leased session before admission at request-execution-scope.ts:297, which fits a follow-up issue. After these fixes, the Body rules job needs a re-run before merge. |
|
Thanks. Dispositions at 6eef3a8: Fixed here. These are regressions or ordering faults in the rule this PR adds:
Follow-ups. These are new ownership surfaces or paths that predate this PR; the PR stays at one invariant:
Validation at 6eef3a8: full |
|
@apex-sentinel-staging review |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 5a24fb5. The verdict and the full list are in the summary comment.
This comment has been minimized.
This comment has been minimized.
|
Several findings from the earlier review (b414200, #4911 (comment)) are now fixed at fd97ec9, including the flags-only parent case for nested requests, but six defects remain. The leaseBackend comparison now exists at lease-context.ts:185, and its thread no longer applies (#4911 (comment)). The 16 checks at fd97ec9 are green, and no conflicts were reported. No tests were run for this review. The regression checks for the replay, batch, open-preflight and leaseBackend tests come from reading the b414200 code paths. The routes moved to #4912 and #4913 were not re-checked, as agreed. A second independent pass found that a supplied scope label is dropped when the session has no value for it. lease-context.ts:193: allocate an iOS lease with tenant and run only, then open a session with it. A snapshot with the correct leaseId plus a clientId, deviceKey or leaseProvider passes the assertion, because the stored label is undefined. The projection at lease-context.ts:111-113 removes the supplied value before registry admission. Base 3925b05 kept it, and lease-registry-scope.ts:271-273 refused it. The rule: a supplied label must mismatch whenever it differs from the session lease value, including when that value is absent. A second independent pass found that leaseBackend sent in flags is ignored. lease-scope.ts:122 reads only meta.leaseBackend, while CommandFlags carries leaseBackend through CliFlags. A named snapshot on an active iOS simulator session with the correct meta.leaseId and flags.leaseBackend set to android-instance reaches the assertion at lease-context.ts:185 with no requested backend, and the command runs. The rule: resolve leaseBackend from flags when meta does not supply it, like the other flag-backed lease fields, and use that resolution in admission and nested handoff. A second independent pass found that equivalent backend values are now refused. lease-context.ts:185: on an ios-simulator session, send the correct leaseId with meta.leaseBackend set to IOS-SIMULATOR through agent_device.command. The RPC only checks that meta is an object (http-rpc-methods.ts:55-63). Base 3925b05 passed the value to the registry, which trims and lowercases it (lease-registry-scope.ts:171-176). Head compares the raw strings and refuses. The rule: compare supplied and stored backends through the existing backend canonicalization, and keep LEASE_SESSION_MISMATCH for a different backend. A second independent pass found that parent metadata masks a batch step's own lease credential. batch.ts:350: send a direct batch with the session's correct leaseId in meta and a snapshot step whose flags.leaseId names another lease. The step builder copies all parent meta onto the child, so the handoff at lease-context.ts:128 sees the parent id (lease-scope.ts:119 prefers meta), and the snapshot runs. The flags-only parent test at request-router-nested-session-lease.test.ts:134 passes, but the meta case is still open. The rule: do not inherit lease metadata for any field the step supplies, and let the shared handoff fill the rest from the parent. A second independent pass found that a devices request touches a leased session without the credential. request-execution-scope.ts:733: an active iOS leased session has a runner-backed recording with touches enabled. A devices request names the session and sends no lease id. The devices descriptor ignores the session lease (registry.ts:299), yet scope preparation resolves the session and calls its recording refresh, which can set the runner ID or invalidate the recording (request-recording-health.ts:18-36). The rule: lease-independent devices requests must not bind the session used by recording refresh. This is tracked as #4913 item 2, so the maintainer may keep it in that issue. A second independent pass found that the active provider-session lookup validates the id but not the other labels. lease.ts:600: with no agent-device session at the request address, request artifacts by the id of an active provider session, with the correct tenant, provider and leaseId but a different runId or leaseBackend. The index keys on provider and id and checks tenant (provider-session-ownership.ts:70-77), and the guard checks only leaseId, so the request reaches the cloud artifact provider at lease.ts:555. The rule: resolve the active lease's scope and validate the supplied id and labels with the same session mismatch assertion before provider dispatch. Fixing the five findings that are not tracked in #4913 needs a re-run of the snapshot, batch and artifact routes above, each showing LEASE_SESSION_MISMATCH. After that, merge once the maintainer accepts the #4912/#4913 split. |
|
Dispositions at 7b08a40. Each new test fails at fd97ec9 and shows
Validation at 7b08a40: |
This comment has been minimized.
This comment has been minimized.
|
The five findings from the earlier review (#4911 (comment)) are fixed at 7b08a40, and the checks show 16 passing with none failing. A second independent pass found six cases where a lease label is skipped or masked, so these need a fix before merge. No conflicts. A second independent pass found that a snapshot on an active leased session with A second independent pass found that a batch on tenant-a's leased session can run a snapshot step with A second independent pass found that the proxied A second independent pass found that an artifacts request for an active WebDriver provider session skips label checks on the lease-ID path at lease.ts:554. With no agent-device session, the active A second independent pass found that the provider-session index masks a tenant mismatch at lease.ts:575. A request with the active A second independent pass found a change from base at lease-context.ts:191. An active BrowserStack Nested lease inheritance now has two owners: The earlier inline thread on Not verified here: test runs, since none were run, and whether each regression test fails at fd97ec9, which was judged by reading the code paths. The routes deferred to #4912, #4913, #4908, #4909, #4910 and #4923 were not re-checked. Label comparison uses raw string equality except for the backend, so a whitespace variant on the provider-session path could mismatch. No production client sends such values. Once these six are fixed and the maintainer accepts the #4912 and #4913 split, the PR is ready to merge. |
|
Dispositions at 6e51e09. Each new test fails at 7b08a40 and passes now:
Optional single-owner batch inheritance: not taken here. The current code holds the rule on the batch route, and moving the key list beside The leaseBackend inline thread is resolved. Validation at 6e51e09: |
This comment has been minimized.
This comment has been minimized.
…d session A request on a session that holds a lease must send that lease's id. The daemon no longer fills a missing lease id or label from the session, so a client that holds only the shared proxy token and a session name cannot read, drive, or close another client's session. Requests the daemon builds inside an admitted request carry the parent's lease scope, and install_from_source reads a leaseId param. Caller-chosen lease ids on allocate need 128 bits. Daemons report the session-lease-id capability.
…session lease rule - Replay steps get the parent's lease scope, like other nested requests. - A nested request keeps a lease id or label that it names in its flags. - An open on an existing leased session checks the lease id before the fresh-open proxy metadata rule. - An active provider-session artifact lookup needs the lease id. - Docs: open saves the lease id; client API names the refusal.
- A label the request sends differs from a lease that does not carry it. - leaseBackend is read from flags when meta lacks it, and compared in canonical form (readLeaseBackend in kernel, shared with the registry). - A batch step's lease fields in flags win over the inherited batch meta; the tenant stays in meta. - An active provider-session artifact lookup checks the id and every label against the active lease.
- An omitted label is not compared; an empty label differs from the lease. - Tenants are compared after the existing tenant normalization. - A batch step tenant must name the inherited (possibly attested) tenant. - install_from_source reads every lease label; release_materialized_paths reads the tenant that the paired install recorded. - artifacts checks a presented active lease id and its labels before the tenant-filtered provider-session lookup and before provider dispatch.
|
The earlier findings from 7b08a40 are fixed at 6e51e09: the lease backend now goes through the shared checker, and an empty backend also mismatches, so the inline thread on backend comparison (#4911 (comment)) can be resolved. Five problems remain, and a second independent pass found each of them. A second independent pass found that http-rpc-methods.ts:210 drops a supplied lease backend on install_from_source. A request with the right leaseId and leaseBackend set to android-emulator or "" on an iOS leased session is admitted, because the check at lease-context.ts:194 sees no backend. The lease contract doc promises a differing backend is refused. Project the backend into meta.leaseBackend with the other install lease labels, and keep an explicit empty value so the shared checker returns UNAUTHORIZED with field leaseBackend. A second independent pass found that HTTP attestation masks a conflicting tenant label (http-server.ts:682). With an auth hook that attests tenant-a, a call carrying the right leaseId and an empty or different tenantId is admitted, because intake replaces the declared tenant at lines 682-690 and lease-context.ts:193 compares only the attested value. Keep the attested tenant as the routing identity, keep the caller-declared tenant as a separate lease label, and compare it with the lease whenever the request acts on a leased session. A second independent pass found that session-batch.ts:42 now rejects steps on unleased sessions. A batch on an unleased local session with meta tenant-a and a step carrying flags.tenant tenant-b ran on base. At head it returns UNAUTHORIZED before dispatch, because the guard runs whenever meta carries a tenant. Apply the step tenant comparison only when the child acts on a leased session. A second independent pass found that the same check (session-batch.ts:43) drops completed work. If step one completes and step two has a different tenant, the throw reaches the outer catch at batch.ts:142, which returns no failing step, completed count, partial results or dispatch status. The batching docs promise that evidence so a caller can resume without repeating steps. Return the mismatch as the child's error response so the step failure builder at batch.ts:150 keeps it. A second independent pass found that lease-context.ts:180 refuses equivalent spellings of the lease id on the provider-session route. For an active WebDriver provider session, an uppercase or space-padded copy of the correct hex leaseId resolved on base. At head the registry still finds the lease through its normalizer (lease-registry.ts:324), but the raw comparison then refuses it. Compare using the existing lease id canonicalization, reject missing, malformed or different ids, and pass the validated canonical id to the provider. Not blocking, and fine to take or leave: readLeaseLabelParams (http-rpc-methods.ts:209) repeats the label aliases that toLeaseDaemonRequest writes inline, so toLeaseDaemonRequest could spread it; install_from_source and release_materialized_paths now treat a tenant param as client-declared, so a release must send the same tenant as its install, which the release ledger rationale could state; and the step tenant check at session-batch.ts:42 fits #4910's single inheritance owner. All 16 checks pass at 6e51e09. Not verified here: tests were not run in this review, so the pass at head relies on the reported results and the green checks, and the routes deferred to #4908, #4909, #4910, #4912, #4913 and #4923 were not re-checked. The PR has merge conflicts with main. After the five fixes above, it needs to merge cleanly before it can land. |
…ngs on leased sessions - A tenant flag is compared with the session lease at admission, so a batch step that names another tenant fails as that step (partial results kept), and a step on an unleased session is not refused. - install_from_source reads the leaseBackend (or backend) param. - The lease id is compared in canonical form (case, surrounding space), and the active provider lease's canonical id goes to the provider.
6e51e09 to
f86ae74
Compare
|
Rebased onto the rewritten Rebase. Only this PR's commits were replayed ( Fixed. Each new test fails at the rebased previous head:
Not taken: a separate declared tenant label under HTTP attestation. An auth hook attests the tenant from the client's credential, which is a stronger identity than any label the client declares. Admission compares that attested tenant with the lease, so a request with the right lease id and a wrong attested tenant is refused. A declared tenant that the hook overrides cannot widen access, and comparing it would refuse callers whose hook maps their declared label to another tenant name. A tenant the client sends in flags is now compared on leased sessions (see the batch item), which covers the step case. If you want the meta-declared tenant kept as a label too, that belongs with the typed session-lease state in #4910. Not blocking: the release ledger rationale now says a release sends the same tenant as its install. Validation at f86ae74. Format, lint, typecheck, layering, fallow and build pass, and the daemon unit suite passes (4,260 tests). The affected gate's related-tests stage had one provider-integration timeout ( |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 11e6472. The verdict and the full list are in the summary comment.
|
At 11e6472, four of the five findings from the earlier review are fixed in the existing admission owner, and the attested-tenant one is answered. A second independent pass found four remaining gaps where one supplied lease label can hide another, listed below. All 16 checks are green at this commit, and there are no conflicts. These four gaps need a fix before merge. A second independent pass found that HTTP tenant attestation overwrites conflicting lease labels. An auth hook attests tenant-a. A command or batch targeting a tenant-a leased session sends the correct lease id but declares tenant-b in A second independent pass found that metadata shadows other supplied lease labels. On a leased session, a request can send the correct A second independent pass found that install RPC aliases can hide a mismatched backend or other label. A caller installing on an iOS leased session sends the correct lease id, a matching A second independent pass found that batch steps can replace the active request scope on an unleased session. Take an existing unleased iOS session and a batch with a valid active lease id, tenant and run in its outer meta. A snapshot step carries a different, inactive lease id in flags. The base keeps the outer lease id ahead of the step flag and runs the snapshot. At head, the outer request is admitted without attaching the lease to that session (lease-lifecycle.ts), but the batch helper deletes the inherited id before the child is admitted. The child then tries the inactive id and fails UNAUTHORIZED at lease-registry.ts. Please keep the inherited meta as the step's effective request scope, and compare the step's supplied lease fields separately where the child checks a leased target, so unleased steps keep base precedence. Not blocking, and fine to take or leave: Not verified here: tests were not run in this review. The step 2 and Neither open inline thread still needs action. This thread on step-owned meta can be resolved: |
…elds on leased sessions A batch step keeps the inherited batch meta as its scope again, so a step on an unleased session runs as on base. On a leased session, admission compares every lease field the request sends in flags with the lease, so a step that names another lease id or tenant is still refused.
|
Round 5 at 11e6472. The maintainer scoped this PR to stop at its invariant: a request on a leased session must send the lease id, and labels never grant access. This round therefore fixes only the regression. The rest moves to #4935. Fixed (regression) at fdafb13: batch step scope on an unleased session. A batch step keeps the inherited batch meta as its scope again, and the meta-stripping helper in Moved to #4935:
Both open inline threads are resolved, as the review notes. Validation at fdafb13: daemon unit (4,261) and |
Apex Sentinel · ✅ Approve · review of
|
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
|
This PR is ready at fdafb13. The earlier findings from #4911 (comment) are fixed: batch steps on unleased sessions again get the base scope, and on leased sessions the lease label comparison now also covers flag-carried labels. All 16 checks pass at this commit, and there are no conflicts. Not blocking, take or leave: https://github.com/callstack/agent-device/blob/fdafb13/packages/daemon/src/core/lease-context.ts#L186 checks the lease id twice (assertRequestSendsLeaseId, then assertSuppliedLeaseLabels), so assertRequestSendsLeaseId could check only that the id is present; and https://github.com/callstack/agent-device/blob/fdafb13/packages/daemon/src/core/lease-context.ts#L173 reads flags.provider as a lease label when flags.leaseProvider is absent, so a hand-built RPC on a proxy-leased session that sends the cloud provider name in flags.provider (for example for artifacts) is refused with field leaseProvider, which the CLI, Node client and MCP paths avoid because they always send flags.leaseProvider, and that alias could go into a follow-up issue. Of the open inline threads, the one on batch step meta (#4911 (comment)) no longer applies because steps cannot own meta and session-batch.ts matches the base again, and the one on the backend label check (#4911 (comment)) is fixed at this head, so both can be resolved. Not verified here: tests were not run, the author's counts (daemon unit 4,261, provider-integration 318) were not reproduced, and the claim that the new test fails at 11e6472 rests on a code read; raw JSON-RPC callers that send different lease values in flags and meta were checked by code read only. |
…d session (#4911) * fix(daemon): require the session lease id on every request to a leased session A request on a session that holds a lease must send that lease's id. The daemon no longer fills a missing lease id or label from the session, so a client that holds only the shared proxy token and a session name cannot read, drive, or close another client's session. Requests the daemon builds inside an admitted request carry the parent's lease scope, and install_from_source reads a leaseId param. Caller-chosen lease ids on allocate need 128 bits. Daemons report the session-lease-id capability. * docs(proxy): keep the session sentence next to its subject * refactor(daemon): name the session lease assertion and type the HTTP capability list * fix(daemon): close the nested, open and provider-session gaps in the session lease rule - Replay steps get the parent's lease scope, like other nested requests. - A nested request keeps a lease id or label that it names in its flags. - An open on an existing leased session checks the lease id before the fresh-open proxy metadata rule. - An active provider-session artifact lookup needs the lease id. - Docs: open saves the lease id; client API names the refusal. * refactor(daemon): split the unleased-request decision out of lease admission * fix(daemon): check the lease backend label against the session lease * fix(daemon): treat every sent lease label as checked against the lease - A label the request sends differs from a lease that does not carry it. - leaseBackend is read from flags when meta lacks it, and compared in canonical form (readLeaseBackend in kernel, shared with the registry). - A batch step's lease fields in flags win over the inherited batch meta; the tenant stays in meta. - An active provider-session artifact lookup checks the id and every label against the active lease. * fix(daemon): compare empty, batch and RPC lease labels against the lease - An omitted label is not compared; an empty label differs from the lease. - Tenants are compared after the existing tenant normalization. - A batch step tenant must name the inherited (possibly attested) tenant. - install_from_source reads every lease label; release_materialized_paths reads the tenant that the paired install recorded. - artifacts checks a presented active lease id and its labels before the tenant-filtered provider-session lookup and before provider dispatch. * refactor(daemon): publish the session lease reasons from typed reason tables * fix(daemon): check flag tenants, install backends and lease id spellings on leased sessions - A tenant flag is compared with the session lease at admission, so a batch step that names another tenant fails as that step (partial results kept), and a step on an unleased session is not refused. - install_from_source reads the leaseBackend (or backend) param. - The lease id is compared in canonical form (case, surrounding space), and the active provider lease's canonical id goes to the provider. * docs(wire-compat): say a release sends the tenant its install sent * fix(daemon): keep the batch scope for steps and compare flag lease fields on leased sessions A batch step keeps the inherited batch meta as its scope again, so a step on an unleased session runs as on base. On a leased session, admission compares every lease field the request sends in flags with the lease, so a step that names another lease id or tenant is still refused.
…d session (callstack#4911) * fix(daemon): require the session lease id on every request to a leased session A request on a session that holds a lease must send that lease's id. The daemon no longer fills a missing lease id or label from the session, so a client that holds only the shared proxy token and a session name cannot read, drive, or close another client's session. Requests the daemon builds inside an admitted request carry the parent's lease scope, and install_from_source reads a leaseId param. Caller-chosen lease ids on allocate need 128 bits. Daemons report the session-lease-id capability. * docs(proxy): keep the session sentence next to its subject * refactor(daemon): name the session lease assertion and type the HTTP capability list * fix(daemon): close the nested, open and provider-session gaps in the session lease rule - Replay steps get the parent's lease scope, like other nested requests. - A nested request keeps a lease id or label that it names in its flags. - An open on an existing leased session checks the lease id before the fresh-open proxy metadata rule. - An active provider-session artifact lookup needs the lease id. - Docs: open saves the lease id; client API names the refusal. * refactor(daemon): split the unleased-request decision out of lease admission * fix(daemon): check the lease backend label against the session lease * fix(daemon): treat every sent lease label as checked against the lease - A label the request sends differs from a lease that does not carry it. - leaseBackend is read from flags when meta lacks it, and compared in canonical form (readLeaseBackend in kernel, shared with the registry). - A batch step's lease fields in flags win over the inherited batch meta; the tenant stays in meta. - An active provider-session artifact lookup checks the id and every label against the active lease. * fix(daemon): compare empty, batch and RPC lease labels against the lease - An omitted label is not compared; an empty label differs from the lease. - Tenants are compared after the existing tenant normalization. - A batch step tenant must name the inherited (possibly attested) tenant. - install_from_source reads every lease label; release_materialized_paths reads the tenant that the paired install recorded. - artifacts checks a presented active lease id and its labels before the tenant-filtered provider-session lookup and before provider dispatch. * refactor(daemon): publish the session lease reasons from typed reason tables * fix(daemon): check flag tenants, install backends and lease id spellings on leased sessions - A tenant flag is compared with the session lease at admission, so a batch step that names another tenant fails as that step (partial results kept), and a step on an unleased session is not refused. - install_from_source reads the leaseBackend (or backend) param. - The lease id is compared in canonical form (case, surrounding space), and the active provider lease's canonical id goes to the provider. * docs(wire-compat): say a release sends the tenant its install sent * fix(daemon): keep the batch scope for steps and compare flag lease fields on leased sessions A batch step keeps the inherited batch meta as its scope again, so a step on an unleased session runs as on base. On a leased session, admission compares every lease field the request sends in flags with the lease, so a step that names another lease id or tenant is still refused.
…d session (#4911) * fix(daemon): require the session lease id on every request to a leased session A request on a session that holds a lease must send that lease's id. The daemon no longer fills a missing lease id or label from the session, so a client that holds only the shared proxy token and a session name cannot read, drive, or close another client's session. Requests the daemon builds inside an admitted request carry the parent's lease scope, and install_from_source reads a leaseId param. Caller-chosen lease ids on allocate need 128 bits. Daemons report the session-lease-id capability. * docs(proxy): keep the session sentence next to its subject * refactor(daemon): name the session lease assertion and type the HTTP capability list * fix(daemon): close the nested, open and provider-session gaps in the session lease rule - Replay steps get the parent's lease scope, like other nested requests. - A nested request keeps a lease id or label that it names in its flags. - An open on an existing leased session checks the lease id before the fresh-open proxy metadata rule. - An active provider-session artifact lookup needs the lease id. - Docs: open saves the lease id; client API names the refusal. * refactor(daemon): split the unleased-request decision out of lease admission * fix(daemon): check the lease backend label against the session lease * fix(daemon): treat every sent lease label as checked against the lease - A label the request sends differs from a lease that does not carry it. - leaseBackend is read from flags when meta lacks it, and compared in canonical form (readLeaseBackend in kernel, shared with the registry). - A batch step's lease fields in flags win over the inherited batch meta; the tenant stays in meta. - An active provider-session artifact lookup checks the id and every label against the active lease. * fix(daemon): compare empty, batch and RPC lease labels against the lease - An omitted label is not compared; an empty label differs from the lease. - Tenants are compared after the existing tenant normalization. - A batch step tenant must name the inherited (possibly attested) tenant. - install_from_source reads every lease label; release_materialized_paths reads the tenant that the paired install recorded. - artifacts checks a presented active lease id and its labels before the tenant-filtered provider-session lookup and before provider dispatch. * refactor(daemon): publish the session lease reasons from typed reason tables * fix(daemon): check flag tenants, install backends and lease id spellings on leased sessions - A tenant flag is compared with the session lease at admission, so a batch step that names another tenant fails as that step (partial results kept), and a step on an unleased session is not refused. - install_from_source reads the leaseBackend (or backend) param. - The lease id is compared in canonical form (case, surrounding space), and the active provider lease's canonical id goes to the provider. * docs(wire-compat): say a release sends the tenant its install sent * fix(daemon): keep the batch scope for steps and compare flag lease fields on leased sessions A batch step keeps the inherited batch meta as its scope again, so a step on an unleased session runs as on base. On a leased session, admission compares every lease field the request sends in flags with the lease, so a step that names another lease id or tenant is still refused.
Summary
Targets 0.22. A request on a leased session must send that lease's id. The daemon filled a missing lease id from the session, so any holder of a shared proxy token who knew a session name could read, drive and close another client's session. Now a missing id fails with
UNAUTHORIZED,LEASE_SESSION_MISMATCH,field: leaseId. Labels are checked when present and never grant access. Nested daemon requests (find, batch, replay) carry the parent's lease scope without overriding their own. Active provider-session artifact lookup needs the lease id. Caller-chosen allocate ids need 128 bits. Health reportssession-lease-id. ADR 0007 states the trust model.Breaking for older clients and direct RPC/SDK callers that relied on inheritance. The current CLI already sends the saved lease id.
Follow-ups: #4908, #4909, #4910, #4912, #4913. #4171 was fixed by #4177.
Before / after
Value
Validation
At
6eef3a85f9: fullunit-coreandprovider-integrationpass; lint, typecheck, layering and wire-compat clean. New tests fail at base; the find, batch and replay tests guard the nested hand-down.check:affected --runpassed atcecfae508b(exactCommit).Live, iOS 26.2 simulator, checkout proxy, three state dirs: C's snapshot/press/close refused. B's open got
DEVICE_IN_USE. A's connect, open, snapshot, press, close and disconnect passed.