Skip to content

fix: cancel LLRT host calls on timeout#16

Merged
robinbraemer merged 1 commit into
mainfrom
codex/llrt-cancel-host-calls
Jun 16, 2026
Merged

fix: cancel LLRT host calls on timeout#16
robinbraemer merged 1 commit into
mainfrom
codex/llrt-cancel-host-calls

Conversation

@robinbraemer

Copy link
Copy Markdown
Member

Summary

  • abort LLRT host-call contexts when execution finishes or times out
  • forward AbortSignal through CodeMode request bridge and cancel response readers on abort/error
  • add maxRequestBytes to cap request payloads before forwarding to host handlers
  • bump fixed release versions to @robinbraemer/llrt@0.1.2 and @robinbraemer/codemode@0.3.2

Context

Security audit found that @robinbraemer/codemode@0.3.1 / @robinbraemer/llrt@0.1.1 can return a timeout while in-flight host-side async work continues. Those versions were published before this finding; they should be superseded by 0.3.2 / 0.1.2 before CNAP adopts LLRT as the default path.

The host-call abort context is bound as the host function this value instead of appended as a user argument, so rest-argument callbacks do not observe sandbox metadata as guest input.

Verification

  • mise exec -- task ci
  • pnpm --filter @robinbraemer/llrt run test:native

Follow-up

After merge, create release v0.3.2 so the release workflows publish @robinbraemer/codemode@0.3.2, @robinbraemer/llrt@0.1.2, and the four native optional packages at 0.1.2. Then update CNAP to consume those versions.

Rationale: Security review found that LLRT wall-time timeouts returned to callers while host-side request work could keep running, which could exhaust handler concurrency or backend capacity. This also adds a request-body byte cap so sandbox code cannot amplify payloads into unbounded host allocations.

Rejected: Passing abort context as an extra user argument because rest-argument callbacks would observe it as guest input. The context is bound as the host function this value instead, preserving guest argument arity.

Risk: Host callbacks must cooperate with AbortSignal for their own long-running async work, but CodeMode's request bridge now forwards the signal to RequestInit and cancels response readers on abort/error.

Tested: mise exec -- task ci

Tested: pnpm --filter @robinbraemer/llrt run test:native
@robinbraemer robinbraemer merged commit 4abb0bb into main Jun 16, 2026
6 checks passed
@robinbraemer robinbraemer deleted the codex/llrt-cancel-host-calls branch June 16, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant