Skip to content

RQ-2426: sandbox rule code in an isolated-vm isolate (RCE fix)#109

Draft
dinex-dev wants to merge 1 commit into
masterfrom
fix/RQ-2426-sandbox-rule-code
Draft

RQ-2426: sandbox rule code in an isolated-vm isolate (RCE fix)#109
dinex-dev wants to merge 1 commit into
masterfrom
fix/RQ-2426-sandbox-rule-code

Conversation

@dinex-dev

Copy link
Copy Markdown
Member

Security fix for RQ-2426 (Critical) — supply-chain RCE.

Problem

"Code"-type Modify Request/Response rules ran rule-supplied JS via new Function(...) directly in the proxy's Node process (full require/process/fs/child_process). Code rules travel verbatim via shared lists, import/export, and team sync — so importing + enabling a foreign rule = arbitrary native code as the victim.

Fix

Run rule code inside an isolated-vm V8 isolate: no host realm, hard 5s timeout, 128MB cap. Only copied data crosses (args, $sharedState); narrow bridged shims preserve the existing contract: console, atob/btoa, and fetch (async, 10s/10MB bounded). getFunctionFromString (eval) → isValidFunctionString (compile-only check). Both processors pass the source string.

Verified

Standalone harness (11/11 core + 4/4 fetch): require/process/constructor-escape blocked even with fetch present; infinite loop times out; JSON transforms, async, console, base64, $sharedState write-back, and fetch all preserved.

⚠️ Review/integration caveats

  • Native dep: isolated-vm needs electron-rebuild (Electron ABI) before it runs in the desktop background renderer.
  • Parity gaps (intentional): no Buffer/timers/URL/TextEncoder in the isolate — add bridges if real rules need them.
  • Companion: RQ-2429 (auth the rule listener) closes the remote push path.

Draft — pending review.

"Code"-type Modify Request/Response rules ran rule-supplied JS via
new Function(...) directly in the proxy's Node process — full require/process/
fs/child_process. Since code rules travel between users (shared lists, export/
import, team sync) with no sanitization, this was a supply-chain RCE: import +
enable a foreign rule and arbitrary native code runs as the victim.

- Run rule code inside an isolated-vm V8 isolate: no host realm (no require/
  process/fs), hard 5s timeout, 128MB memory cap.
- Cross only copied data: args and $sharedState (ExternalCopy), read $sharedState
  back and write it to GlobalStateProvider — same contract as before.
- Explicitly bridge the safe capabilities rules relied on: console (-> ctx.rq
  .consoleLogs, same {type,args} shape), atob/btoa (host Buffer), and fetch
  (async host reference; 10s timeout, 10MB response cap, forwards method/headers/
  body; Response-like object with status/ok/headers.get()/text()/json()).
- Replace getFunctionFromString (in-process eval) with isValidFunctionString
  (compile-only parse check in a throwaway isolate); update both processors to
  validate then pass the source string (also fixes the request vs response
  call-site inconsistency).
- Add isolated-vm@6.1.2; rebuild dist.

Verified via standalone harness: require/process/constructor-escape blocked
(even with fetch present), infinite loop times out, and JSON transforms, async/
promise, console, atob/btoa, $sharedState write-back, and fetch all work.

Integration notes: isolated-vm is native -> needs electron-rebuild for the
Electron 27 renderer (ABI 118). Remaining parity gaps (no Buffer/timers/URL/
TextEncoder) — add bridges if real rules need them.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 113a83ce-9779-4abf-a129-eec320a41c7a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/RQ-2426-sandbox-rule-code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-new Bot commented Jun 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@requestly/requestly-proxy@109

commit: a1678b5

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