Repository navigation
Close the holes a security review of main turned up - #2
Merged
Merged
Conversation
R could run JavaScript on the app's page through webR's eval_js and through wasm modules loaded with dyn.load, so any program in any project could read the user's other projects. webR is now patched when it is copied in (the build stops if a patch no longer matches), and Opcode refuses an unpatched copy. The rest: - server.mjs: a long path no longer crashes it, folder redirects stay on the site, X-Forwarded-Host only counts with OPCODE_TRUST_PROXY=on, the app can't be framed, and the preview host page is sandboxed (OPCODE_APP_ORIGINS limits who may embed it). - wisp-server.mjs: only real host names reach a --via-proxy CONNECT line, a name learned from DNS is used only if the relay's own lookup agrees, the Wisp window is enforced and reading pauses when too much is waiting, and reused stream ids no longer leak sockets. - Preview: host frames are sandboxed and there is one per server, so a previewed page can't navigate the Opcode tab or see the next project's requests. The Linux bridge's response parser has limits and no longer loops on a negative chunk size. - ?machine= links ask first, aren't cached, and machine files are checked (header, unpacked size, v86 format) before they are saved. An offline machine's page-fetch adapter is turned off before it runs. - Zip import enforces real sizes, export leaves out unsafe names, and the editor mirrors at most 5,000 files and 50 MB. - Build: cached inputs are hashed again, Actions are pinned to commits, Docker publishing has its own job, base images and Alpine inputs are pinned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ubuntu-latest is now Ubuntu 26.04, where Playwright 1.56 can't install
Chromium ("Playwright does not support chromium on ubuntu26.04-x64"), so
the end-to-end job failed before running a test. Pin the runner like the
actions themselves; move it along with a Playwright update.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
I ran a security review of main (ed98ad1) and this fixes what it found. I'm keeping the step-by-step write-up and the proof scripts out of the repo for now, since opcode-dev.com stays as it is until this is merged and the preview Worker is redeployed.
The one that matters most is R. webR's
eval_js()runs JavaScript on the page that started it, and any program in a sandbox can ask Opcode to run Rscript through~/.opcode/host, so a bad pip or npm package could read and rewrite every project. Wasm modules loaded withdyn.loadcould do the same.scripts/copy-npm-toolchains.mjsnow patches webR when it copies it (each patch has to match exactly or the build stops), andcreateRrefuses a copy that still runs JavaScript. I tested the patched build in Node and the R e2e test still passes. webR's worker is still on the app's origin though, so I think the real fix is moving it to an origin of its own at some point.The rest, roughly by file:
scripts/server.mjs: a path component over 255 characters madestatSyncthrow and the process exit, folder redirects could point at another host (//x//evil.example/..%2fassets), and any client could switch sites withX-Forwarded-Host. Those are fixed, withOPCODE_TRUST_PROXY=onfor proxies that set that header. The app now sendsframe-ancestors 'none', and the preview host page is sandboxed, withOPCODE_APP_ORIGINSlimiting who may embed it.scripts/wisp-server.mjs: under--via-proxy, DNS names went into the CONNECT line unchecked (so a client could write its own request to the proxy), and one client could choose the name another client's connection was sent under. Also no server-side flow control, and reusing a stream id leaked sockets past--max-streams. All fixed. With--via-proxythe proxy still looks names up itself, so it needs its own rules against private addresses, which the docs now say.?machine=links now ask before downloading, skip the toolchain cache, and machine files are size-checked and must unpack to a v86 snapshot before they are saved. The offline machine's fetch adapter could stay live if a relay was saved while it loaded, which is fixed too...\x.bat, the editor mirrors at most 5,000 files and 50 MB, a file name could hang the tab throughnew RegExpin#runJavac.packages: write, and base images and the Alpine build inputs are pinned.Testing:
npm testis 222 passing (155 before),svelte-checkis clean, and 22 of 23 e2e tests pass in Chromium locally. The failing one is "makes a web page that updates as you type", which fails on macOS because the test sends Cmd+F, and passes with Control+F. I couldn't build the Docker image here and the workflow changes haven't run yet, so this PR's CI is the first real test of those.After merging, the preview Worker needs a redeploy to pick up the per-server frames (the command is now in
deploy/preview-host.wrangler.toml). Things people will notice:webr::eval_js()errors,?machine=asks first, uploads stop at 2,000 files or 50 MB, and the first build re-downloads Rust once because the stamp format changed.AI disclosure: Claude did the review and wrote most of these fixes, using several agents. I reproduced the main findings before fixing them, and I read the diffs and ran the tests above myself.
🤖 Generated with Claude Code