Skip to content

fix(limrun): bind authenticated downloads to the instance origin - #5089

Merged
thymikee merged 17 commits into
feat/0.22-hosted-session-spend-capfrom
fix/0.22-limrun-download-audience
Nov 26, 2026
Merged

thymikee merged 17 commits into
feat/0.22-hosted-session-spend-capfrom
fix/0.22-limrun-download-audience

Conversation

@thymikee

@thymikee thymikee commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Require HTTPS and the same origin as the Limrun instance for every download that uses its bearer. Authenticated loopback HTTP is no longer supported. Standard Fetch refuses redirects on authenticated downloads. Public assets continue to follow redirects.

Before / after

A recording or simulator file served over HTTPS from the instance origin downloads with the scoped bearer. A plaintext or off-origin endpoint fails before fetch with limrun_download_endpoint_blocked and a hint to use an HTTPS instance URL.

Validation

Head 3414ce38. Malformed authenticated URLs return the endpoint refusal and its HTTPS hint before fetch. Public malformed URLs and authenticated fetch failures retain their transport classifications. All 21 focused tests, build, lint, and type checking passed. Fresh CI and affected validation are pending.

Prior head 8688025033fdb2711644e4a62c0f25ab1ac4c22b. The error reference now includes refused redirects under limrun_download_failed. Fetch rejects the redirect before exposing a response status, so the downloader keeps redirect rejection enabled and reports the sanitized request-failed detail. The prose gate and 22 focused tests passed.

All 16 GitHub checks and 8 local affected checks passed at a14528f366, which restored the fetch spy in finally and clarified the two download paths.

Runner screenshots preserve the typed HTTPS endpoint refusal. App logs keep console streams and bundle-ID matching when executable metadata is unavailable. The HTTPS downloader and redirect refusal passed on Node 22, 24, and 26 at 2f5c39df5d. Live hosted evidence at this head is pending.

@thymikee
thymikee added this pull request to stack #5087 November 24, 2026 20:43
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 5.04 MB 5.04 MB +106 B
Package (unpacked) 5.04 MB 5.04 MB +106 B
Package (download) 1.54 MB 1.54 MB +34 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 15.5 ms 13.2 ms -2.3 ms
CLI --help 25.9 ms 23.7 ms -2.2 ms

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on a7b910b. The verdict and the full list are in the summary comment.

@thymikee
thymikee force-pushed the fix/0.22-limrun-download-audience branch from a7b910b to 03de8f7 Compare November 24, 2026 20:57
@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the fix/0.22-limrun-download-audience branch 3 times, most recently from 034d1e3 to e4a0c13 Compare November 24, 2026 21:35
@thymikee
thymikee force-pushed the fix/0.22-limrun-download-audience branch from e4a0c13 to 1ddbbf9 Compare November 24, 2026 21:44
@thymikee
thymikee force-pushed the fix/0.22-limrun-download-audience branch from 1ddbbf9 to b5d9569 Compare November 24, 2026 21:47
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Reviewed b5d9569. The change has three problems to fix, and one needs a live run before merge.

Recording collection and simulator file copy now use redirect: 'error' for authenticated downloads (download-file.ts:44). The base followed redirects, as the SDK's own download does. If a hosted Limrun instance answers /files with a 3xx, for example to object storage, every Limrun record stop and every simulator file copy fails with limrun_download_failed. The unit tests use a local server, so they cannot show what the hosted service does. Please attach one live run at this head against a hosted Limrun instance: an iOS and an Android record start/stop that writes a non-empty MP4, and one iOS command that routes through copyToHost. The output should show success and no limrun_download_failed or limrun_download_endpoint_blocked.

A second independent pass found that the Limrun bearer can still reach a proxy. On Node 26, with environment proxy routing enabled and a non-loopback HTTP proxy, an attached instance's same-origin loopback HTTP download URL is accepted, but the global fetch dispatcher sends it through the proxy (download-file.ts:41). The proxy can read the Authorization header even if the download fails; Node picks the proxy when NO_PROXY has no matching entry, as packages/proxy/README.md:129 describes. The rule: an authenticated loopback HTTP download must use a request-scoped direct transport that keeps the deadline and the first-redirect rejection. HTTPS and public artifacts can keep the existing dispatcher. This path is shared by recording, simulator file copies and Info.plist reads.

A second independent pass also found that an attached instance with a localhost. HTTP URL is rejected. Node resolves localhost. to loopback and URL.parse keeps the trailing dot, but the hostname misses both the localhost check and the IP checks in transport.ts:304. So download-file.ts:73 rejects recording and iOS file transfers before any request, where the base sent them. The rule: accept the fully qualified localhost. spelling for direct loopback HTTP, and keep the exact origin comparison between the instance API and download URLs.

Not blocking, and each can be taken or left: a refused redirect still reports limrun_download_failed with transport invalid-request (download-file.ts:125), which the docs row describes as failing before the instance was asked (the open thread at #5089 (comment) still applies); provider-revyl and daemon-client keep their own loopback BlockList copies of the rule now in isLoopbackUrlHostname (revyl-client.ts:690); and the second half of the invariant, that unauthenticated public artifacts still follow redirects, has no test (download-file.test.ts:237).

Not verified here: whether hosted Limrun /files redirects authenticated GETs, and the author's test, lint, typecheck and gate claims. The SDK behavior was read from the published @limrun/api@0.69.1 files.

CI at this head is not complete: Prose/links, two Body rules and Bundle Size were cancelled as superseded runs, not failures, and one other check is still running. The diff touches website/docs/docs/error-reasons.md and a provider bundle import, so the Prose and Bundle Size jobs must rerun green. No conflicts are known. Before merge, the live hosted-Limrun run above is required, then green reruns of those jobs.

@thymikee
thymikee force-pushed the fix/0.22-limrun-download-audience branch from b5d9569 to 08ac3f0 Compare November 24, 2026 23:00
@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the fix/0.22-limrun-download-audience branch from 08ac3f0 to 573596f Compare November 24, 2026 23:33
@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the fix/0.22-limrun-download-audience branch from 573596f to ae627e5 Compare November 25, 2026 04:24
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on ae627e5. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

The three problems from the earlier review are fixed at ae627e5. Four problems on the new direct loopback route still need a fix.

A second independent pass found that the node:http request likely exposes the instance bearer in diagnostics. With NODE_DEBUG=net, Node 26 logs the connection options, including the Authorization header and the supplied URL. The daemon sends stderr to its log (first site, second site). An in-memory Node 26.11.1 check showed a harmless fixture header and query value with this request shape, and neither with the base Fetch path. Supported Node 22.12.0 has the same header exposure in its HTTP connection diagnostic. No Node socket diagnostic on an authenticated download should contain the bearer or the URL. Can the loopback route stay on Fetch, with a request-scoped direct dispatcher whose socket options carry only connection data, and keep the abort signal and redirect policy? Please validate with a loopback download under Node diagnostics, and show that stderr contains neither fixture value.

A second independent pass found that the direct request can likely send the bearer in plaintext off the machine. Matching http://localhost.:port instance and download origins pass the transport check and the origin check. Skipping the proxy still leaves ordinary OS resolution in place, so a non-loopback answer for localhost. receives the bearer. The previously reviewed head rejected this spelling. For localhost and localhost., the socket must connect only to loopback addresses, while the Host header and the exact origin comparison keep the requested hostname. A test where the lookup returns a non-loopback address should show that no request or bearer is sent.

A second independent pass found that the new promise likely never settles on an HTTP 101 reply with Upgrade. Node closes the socket without a response callback or a request error, even after the abort signal fires. Recording and file-copy callers can then hang past their deadline. A loopback-only Node 26.11.1 check reproduced this, and base Fetch rejected the same reply immediately. Every request that closes before it delivers a response must reject, with the current response, error and cancellation handling kept. A loopback server that replies 101 should make the download reject.

A second independent pass found that compressed replies are likely saved without decoding. The route requests identity, but a loopback instance or local reverse proxy can still return 200 with Content-Encoding: gzip. Base Fetch wrote the decoded file, while the new route writes the gzip bytes unchanged. A Node 26.11.1 loopback check confirmed the byte mismatch. An iOS Info.plist read then parses compressed bytes, and a file or recording copy can report success with unusable bytes. Every supported Content-Encoding on this route must be decoded before the file is complete, either by Fetch or inside the existing deadline-bounded pipeline. A gzip reply from a loopback server should produce a file that matches the original bytes.

One lower-priority review thread still applies. This thread does not apply and can be resolved, because every authenticated caller passes the instance, so no reachable route drops the bearer.

The required evidence is satisfied. The hosted Limrun live result comes from the PR author's written summary without command output. It is accepted because the hosted HTTPS route at this commit matches the Fetch path that the run exercised. Not verified here: whether hosted Limrun /files ever answers an authenticated GET with a 3xx, and whether CI uses a Node build with --use-env-proxy, without which the env-proxy regression test is skipped.

Coverage is the only check shown as failing. The available failed-step log ends after the fuzz-envelope argument tests and shows no test failure or threshold line. Not verified here: the cause of this failure. An overlap with a coverage or CRAP threshold is possible, because the PR adds openDirectDownload and a child-process test that coverage may not instrument.

Before merge, the four problems need fixes, and a rerun or a log excerpt must show that Coverage passes or that its failure is unrelated.

@thymikee
thymikee force-pushed the fix/0.22-limrun-download-audience branch from ae627e5 to 429329c Compare November 25, 2026 05:25
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

No code problems were found at 44e6a01, following the earlier review at 8688025. The HTTP-failure test now restores the fetch spy, and the download docs and comments now cover both download kinds and authenticated redirects. The required evidence is still satisfied, because the changes since then add nothing device-facing.

These threads no longer apply and can be resolved. Redirect reason: the redirect is still refused, and the error docs now describe it under the existing reason. Optional instance: every bearer caller passes it, and only public release downloads omit it. Localhost spelling: the CLI origin file has no change against the base and accepts only the exact name localhost. Fetch spy: the test restores it in finally. Download wording: both public and instance-authenticated downloads are now named. Redirect docs: the reason row and code comment now include authenticated redirects.

CI is green. The one failed step is the combined Apple jobs check inside a cancelled run, and each cancelled job name also has a successful run, including Smoke Tests.

Not verified here: local tests, typecheck and a live Limrun run were not run, so the run evidence is CI. The author's 198-test run at f898e60 and the runs at earlier commits were not reproduced. Code covered by the earlier review was only traced against the claims and upstream interactions. The earlier acceptance of the hosted run rested on the author's written summary.

No code change is needed before merge. The PR is stacked on feat/0.22-hosted-session-spend-cap, and the PR body still marks live hosted evidence at this head as pending. The maintainer owns that note and the merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 26, 2026
@thymikee
thymikee force-pushed the fix/0.22-limrun-download-audience branch from 44e6a01 to da4b345 Compare November 26, 2026 12:06
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 3414ce3

Since the review of da4b345: 0 new · 0 still open · 1 no longer raised

No open findings.

2 findings below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (a8104885ebbf).

💬 Talking to Sentinel

In a finding's thread, reply with:

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.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 26, 2026
@thymikee

Copy link
Copy Markdown
Member Author

No code problems were found at 3414ce3 in the changes since the earlier review. An authenticated URL that cannot be parsed is now refused as a disallowed download endpoint before any request, instead of being reported as a transport request failure.

This thread on the malformed URL case no longer applies and can be resolved: the new refusal is in place and covered by a test.

The 18 reported checks show no failures.

Not verified here: local tests, build and typecheck were not run, and no live Limrun run was made. A live run is not required for this change, because it only changes how a malformed endpoint is classified before any request. Code covered by the earlier review was only re-traced for the claims and doc sentences affected by this update.

No code change is needed before merge. The PR body still marks live hosted evidence at this head as pending, and that note and the merge order of the stacked base are for the maintainer to settle.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 26, 2026
@thymikee
thymikee merged commit 55e8d53 into 0.22 Nov 26, 2026
18 checks passed
@thymikee
thymikee deleted the fix/0.22-limrun-download-audience branch November 26, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant