fix: cancel LLRT host calls on timeout#16
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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
thisvalue instead of appended as a user argument, so rest-argument callbacks do not observe sandbox metadata as guest input.Verification
mise exec -- task cipnpm --filter @robinbraemer/llrt run test:nativeFollow-up
After merge, create release
v0.3.2so 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.