Skip to content

fix(providers): bound credential endpoints and responses - #5244

Merged
thymikee merged 19 commits into
fix/daybreak-daemon-boundariesfrom
fix/daybreak-provider-boundaries
Dec 1, 2026
Merged

thymikee merged 19 commits into
fix/daybreak-daemon-boundariesfrom
fix/daybreak-provider-boundaries

Conversation

@thymikee

@thymikee thymikee commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Bound in-memory provider response reads in Revyl, WebDriver, and hosted provider to 32 MiB, even when a peer omits or misstates Content-Length. Preserve cancellation, BOM-compatible text decoding, typed oversize failures, and WebDriver dispatch disclosure. This is the provider-response layer of the Daybreak remediation stack, based on #5243. Endpoint, origin, redirect, and disk-download policies remain outside this PR.

Before / after

  • Before: a provider could return an unbounded response body for buffered API calls; after: each reader stops before retaining a chunk that crosses the limit.
  • Before: an oversized WebDriver answer could lose its dispatch disclosure; after: it retains the size reason and dispatched: unknown.
  • Before: Revyl reported an oversized body as provider-response-invalid; after: it reports provider_response_too_large with limitBytes.

Validation

Head: 2955f2b942, rebased onto #5243 34e15e22d7. git range-diff marks all 19 provider commits patch-equivalent to the prior head; git diff --check passed. No local gates or tests were run after this rebase. The focused Revyl file passed 21/21 at ea0f9e7b5e; nine focused files passed 162/162 at 3247e1ba9e. CI at the new head is pending. No live hosted provider or Revyl run was performed.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.73 MB 6.73 MB +1.3 kB
Package (unpacked) 6.73 MB 6.73 MB +1.3 kB
Package (download) 2.06 MB 2.06 MB +468 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 36.9 ms 36.1 ms -0.8 ms
CLI --help 77.5 ms 74.6 ms -2.8 ms

Affected plugins

Plugin Installed (including dependencies) Unpacked Download
@agent-device/revyl 179.6 kB → 180.2 kB (+556 B) 179.3 kB → 179.8 kB (+556 B) 58.2 kB → 58.4 kB (+184 B)
@agent-device/testmu 26.1 kB → 26.5 kB (+464 B) 25.7 kB → 26.2 kB (+464 B) 9.4 kB → 9.6 kB (+208 B)
@agent-device/tizen 97.5 kB → 97.5 kB (0 B) 97.2 kB → 97.2 kB (0 B) 34.4 kB → 34.4 kB (+1 B)
@agent-device/webos 96.5 kB → 96.5 kB (0 B) 96.1 kB → 96.1 kB (0 B) 34.1 kB → 34.1 kB (0 B)

@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the fix/daybreak-provider-boundaries branch from 9c192a4 to c3ae788 Compare November 30, 2026 13:16
@blacksmith-sh

This comment has been minimized.

@thymikee
thymikee force-pushed the fix/daybreak-provider-boundaries branch from c3ae788 to ab917d2 Compare November 30, 2026 13:28
@blacksmith-sh

This comment has been minimized.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

At d282619, Limrun runner staging fails on GitHub's asset redirect, and a few other paths need a fix or live proof before merge.

limrun-download-file.ts:46 sets redirect: 'error' for every caller. downloadReleaseRunner downloads the GitHub release manifest and archive with no headers and no expectedOrigin. GitHub answers these asset URLs with a 302 to release-assets.githubusercontent.com. The base followed it, but this head throws limrun_download_failed. So every Limrun iOS or watchOS session on a released version without an AGENT_DEVICE_LIMRUN_*_RUNNER_APP override cannot start. The rule: a download that carries Authorization or is confined by expectedOrigin never follows a redirect, and an unauthenticated release download may. Please derive the redirect mode from those inputs in downloadLimrunFile, reusing the carriesAuthorization value from requireLimrunDownloadUrl. A local-server test should show that a header-less download follows a 302 to a second local path, and that an origin-fenced download fails on a 302. The release-runner test stubs fetch, so it cannot catch this.

device-session.ts:197 now requires the recording URL to share the origin of the instance apiUrl. The fixtures assume that shape, but nothing at this head shows that the live service returns it. If it uses another host, record stop fails with limrun_download_unsafe_url on every session. Can a live record start and record stop on the fixed head show a non-empty MP4 written through downloadRecording?

A second independent pass found the same redirect failure at limrun-download-file.ts:46. The anonymous manifest request fails on the 302, and the archive request would fail on its own 302 even if the manifest were served directly. The base used the default follow mode. Requests with neither an Authorization header nor an expectedOrigin must keep that default, and all others must refuse redirects.

A second independent pass found that webdriver-utils.ts:128 may now reject JSON that starts with a UTF-8 byte-order mark. Response.text() stripped the mark, but the Buffer decoding keeps it. JSON.parse in webdriver-transport.ts:355 could then fail after the hub has already created the session. The same reader feeds the upload, verification and session-details parser. Every bounded body that is parsed as text should decode like the base did, for example with the built-in TextDecoder and its default BOM handling over the joined bytes.

A second independent pass found the same likely problem in limrun-http-response.ts:25. A successful runner sync reply with a byte-order mark was accepted by Response.json(), but JSON.parse would now throw and stop runner staging. This also covers simulator file listing and staging replies. The same decoding rule applies to every caller of this reader.

Not blocking: these can be taken or left: import isLoopbackHostname from @agent-device/contracts/loopback-host instead of the copy (later sharing one credentialTransportRefusal-based admission helper across WebDriver, Limrun download and Revyl); later merge the bounded-body reader with the Revyl, WebDriver and apple-runner loops; pass a per-call maxBytes for recordings, or document that the 512 MiB cap also limits file pulls, Info.plist reads and the runner archive; add a chunked over-limit response without Content-Length, because the size tests only reach the header precheck; and tie redirect refusal (and the one in fetchProviderVerificationJson) to the presence of auth, so unauthenticated hubs that redirect keep working.

Could this be simpler with WebDriver admission through credentialTransportRefusal(url, {}, hint) plus a userinfo check, one bounded-body reader for Revyl, WebDriver, Limrun control and apple-runner that throws provider_response_too_large, and a downloadLimrunFile that derives redirect refusal from Authorization or expectedOrigin, follows redirects for the GitHub release, and takes a per-call maxBytes for recordings?

All 17 checks pass at this commit. They do not exercise a real GitHub 302, because the release-runner test stubs fetch.

The 302 was confirmed with curl for the v0.21.44 manifest URL. Not verified here: the v0.21.45 URL returned 404 to curl although the asset is listed, and this was not investigated; the Limrun recording URL origin was not compared with the instance apiUrl on the live service or the current @limrun/api version; whether any unauthenticated WebDriver hub redirects was not checked; no local tests were run, and the eager-closure budget claim rests on the passing checks.

Before merge, header-less, unfenced downloads must follow redirects, with the local 302 test. Two live runs on the fixed head are also required and are still missing. First, start a Limrun iOS session on a released version without AGENT_DEVICE_LIMRUN_IOS_RUNNER_APP, reach runner staging, and show that the GitHub manifest and archive downloads succeed. Second, run Limrun record start and record stop, and show that downloadRecording with expectedOrigin writes an MP4 with a non-zero size.

@thymikee

Copy link
Copy Markdown
Member Author

Addressed the code regressions at 33f91219f2:

  • downloadLimrunFile now follows redirects for anonymous, unfenced release downloads. Requests with Authorization or expectedOrigin still refuse redirects. A local HTTP test covers both outcomes.
  • The bounded Limrun control and WebDriver response readers now use TextDecoder, preserving the prior UTF-8 BOM behavior. Focused JSON tests cover both readers.

The three affected test files pass (14, 2, and 19 tests). CI at the pushed head is pending. Live Limrun runner staging and a non-empty MP4 from record stop are still unverified, so the PR remains draft and is not merge-ready.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

At 33f9121, the three code problems from the earlier review are fixed: the redirect handling for anonymous downloads and the BOM decoding in both readers. Two live Limrun runs are still required before merge.

The runner download path still lacks the live proof requested earlier, and the author reports it as unverified. These header-less, unfenced calls now use follow redirects, as the base fetch default did, and a local 302 test covers this. The 512 MiB bound and the bounded runner-sync reader with BOM handling have not run against the real service. On this head, start a Limrun iOS session on a released version without AGENT_DEVICE_LIMRUN_IOS_RUNNER_APP. The run must reach runner staging, show that both the GitHub manifest and archive downloads succeed, and show that runner sync completes.

A live record start and record stop on this head is also required. The output must show that downloadRecording with expectedOrigin writes a non-empty MP4.

Not blocking: this can be taken or left, but if the live service returns the recording URL on another origin (such as a CDN or presigned storage), the new fence would reject it with limrun_download_unsafe_url before any byte is fetched, so could the fence then come from the URL the service actually returns, with the Bearer credential kept off any other origin?

Not verified here: tests were not run locally (pass counts rest on the author's report and CI), the real GitHub release 302 was not exercised (follow was checked in the code and the local 302 test), and the origin of the live recording URL could not be compared with the instance apiUrl because the @limrun/api client source was not available.

All 16 other checks pass. The Body rules check was cancelled, not failed; it validates the PR description, this update does not touch it, and a newer description edit likely superseded the run.

@thymikee
thymikee marked this pull request as ready for review November 30, 2026 19:15

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 23 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/core/limrun-download-file.ts Resolved
Comment thread src/core/limrun-download-file.ts Resolved
@blacksmith-sh

This comment has been minimized.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

At 81674ee, the threads listed below are fixed, but the live proof asked for in the earlier review is still missing.

The runner download path releases with empty headers and no origin fence, so redirects are followed, and its admission check uses the same rule as before. The 512 MiB download bound and the bounded runner-sync reader have still not run against the real GitHub release and Limrun service, and the PR description reports this as unverified. Before merge, start a Limrun iOS session on this head, on a released version without AGENT_DEVICE_LIMRUN_IOS_RUNNER_APP. The run must reach runner staging and show that the GitHub manifest and archive downloads succeed and that runner sync completes.

A live Limrun record start / record stop on this head is also required before merge. downloadRecording still sends a Bearer header and pins the download to the origin of session.apiUrl, so a recording URL on another origin would be refused with limrun_download_unsafe_url before any byte arrives. The base has no such fence. The output must show that downloadRecording writes a non-empty MP4 with that origin check in place.

Not blocking: both of these can be taken or left: if the service returns the recording URL on another origin, taking the fence from that returned URL while keeping the Bearer header off any other origin, and widening the limrun_download_unsafe_url row to cover an invalid, insecure or cross-origin Limrun API or download URL, since a cleartext file API URL now raises it at construction.

These threads no longer apply and can be resolved: any non-empty header now requires an expected origin and refuses redirects; a streaming over-limit test without Content-Length was added; the same-backend case now passes the IP and loopback checks, with a test; authenticated requests now refuse redirects; the error now carries an unknown dispatch disclosure, with a test; the file API URL is now checked at construction; non-backend loopback uploads are now refused and tested; typed errors are now rethrown before the transport wrap; the body is now cancelled before the download size error; the response reasons moved to the remote facade; the body is now cancelled before the response size error; URL parse failures are now typed errors.

All 18 checks pass.

Not verified here: tests were not run locally, and pass results rest on the author's report and the checks. The live recording URL origin was not compared with the instance API URL. The real GitHub release redirect was not exercised; redirect following was confirmed only in code and in the local 302 test. It was also not traced whether every withMethodScope caller turns the new synchronous refusal of a cleartext remote API URL into a rejection, although the refusal reaches the caller either way.

Before merge, both live Limrun runs above need to pass on this head with their output shared.

@thymikee
thymikee added this pull request to stack #5297 December 1, 2026 06:43
@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Please narrow this to provider responses buffered in memory. Keep the byte counters, cancellation, BOM-compatible decoding, typed failures and dispatch disclosure. Remove the new endpoint, origin and redirect rules, including the blanket WebDriver redirect refusal, and move disk-download quotas to a separate change with realistic file sizes. The existing recording and runner routes can then retain their prior behavior. The reader and request tests cover the retained invariant. A live Limrun recording or runner-staging session adds no merge evidence for this scope.

@thymikee
thymikee force-pushed the fix/daybreak-provider-boundaries branch from 81674ee to 3247e1b Compare December 1, 2026 08:02
@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Narrowed #5244 at 3247e1ba9e to buffered in-memory provider responses. It retains byte counters, cancellation, BOM-compatible text decoding, typed oversize failures, and WebDriver dispatch disclosure. Endpoint/origin/redirect rules and the disk-download quota are out of this PR. Nine focused test files passed (162 tests); independent review found no blocking issue. Current-head CI is pending. Disk-download quotas can be handled in a separate change with their own destination policy.

@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

At 3247e1b, no code changes are requested. The PR now keeps only the bounded response reads and their typed errors, and the endpoint, redirect and disk-download rules are removed. The two live Limrun runs asked for after the earlier findings are no longer needed, because recording download and the runner release download behave as on the base.

These threads no longer apply and can be resolved. Fixed: a streaming over-limit test without Content-Length exists; the oversize error reports an unknown dispatch, with a test; typed errors are rethrown before the transport wrap; the response reasons are in the remote facade; the body is cancelled before the size error. Moot after the removals: the download redirect guard is gone; the Revyl IP check is gone; verification requests use the default redirect behavior again; the Limrun API URL check is gone; the validator behind the localhost case is gone; the disk download limit is gone; the endpoint URL check is gone.

Lint, Typecheck & Package fails on unused imports in packages/replay-port/src/daemon-port/__tests__/script-source.test.ts, and on formatting in that file and packages/command-surface/src/cli-grammar/types.ts. This PR changes neither file, so the failures likely come from the base through #5243. Smoke, Coverage, Integration Tests and Repo Guards pass, and one other check is still pending.

Not verified here: tests were not run locally, and pass results rest on the checks and the author's report of 162 focused tests. The two failures were not reproduced on the base branch head 47da635. Cancellation of a body read that is already in progress through the fetch signal was confirmed by code reading only.

No fix is needed in this PR for merge. The Lint and Typecheck failures must be fixed in #5243 before the checks can pass.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Dec 1, 2026
@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 3247e1b. The verdict and the full list are in the summary comment.

@thymikee
thymikee force-pushed the fix/daybreak-provider-boundaries branch 2 times, most recently from ea0f9e7 to 51ed0d4 Compare December 1, 2026 08:31
@thymikee
thymikee force-pushed the fix/daybreak-provider-boundaries branch from 51ed0d4 to 2955f2b Compare December 1, 2026 08:33
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 2955f2b

Since the review of 3247e1b: 0 new · 0 still open · 1 no longer raised (1 marked fixed)

No open findings.

🔧 1 finding marked fixed in their threads
Finding Fixed by Where
Revyl oversized-response error uses a different reason than the new shared constant thymikee ea0f9e7 · reply

1 finding below minor hidden (user_settings.min_severity).

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

💬 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 merged commit e16c912 into fix/daybreak-daemon-boundaries Dec 1, 2026
18 of 19 checks passed
@thymikee
thymikee deleted the fix/daybreak-provider-boundaries branch December 1, 2026 09:06
thymikee added a commit that referenced this pull request Dec 1, 2026
* fix(providers): bound credential endpoints and responses

* fix(providers): require origin fences for authenticated downloads

* fix(providers): bound Limrun control responses

* fix(providers): satisfy response boundary gates

* fix(providers): share response failure vocabulary

* fix(providers): cancel stalled Limrun response reads

* docs: regenerate provider response reasons

* chore(gates): refresh contracts export snapshot

* test(providers): narrow stalled response observation

* fix(providers): preserve observed Limrun rejection status

* test(providers): await client-observed rejection body

* test(providers): observe retry conflict body seam

* fix(providers): keep response reason in existing closure

* fix: preserve anonymous Limrun release redirects and BOM decoding

* fix(providers): close credential and response boundaries

* fix(contracts): keep response reasons in remote facade

* docs(contracts): summarize provider response reason

* fix(providers): narrow response bounds to buffered bodies

* fix(revyl): report oversized responses with shared reason
thymikee added a commit that referenced this pull request Dec 1, 2026
* fix(providers): bound credential endpoints and responses

* fix(providers): require origin fences for authenticated downloads

* fix(providers): bound Limrun control responses

* fix(providers): satisfy response boundary gates

* fix(providers): share response failure vocabulary

* fix(providers): cancel stalled Limrun response reads

* docs: regenerate provider response reasons

* chore(gates): refresh contracts export snapshot

* test(providers): narrow stalled response observation

* fix(providers): preserve observed Limrun rejection status

* test(providers): await client-observed rejection body

* test(providers): observe retry conflict body seam

* fix(providers): keep response reason in existing closure

* fix: preserve anonymous Limrun release redirects and BOM decoding

* fix(providers): close credential and response boundaries

* fix(contracts): keep response reasons in remote facade

* docs(contracts): summarize provider response reason

* fix(providers): narrow response bounds to buffered bodies

* fix(revyl): report oversized responses with shared reason
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