RustWarp loads Scratch projects from the public Scratch site, from URLs, and from the user's own disk. A project file is untrusted input: it is JSON and a ZIP archive the author controls, and nothing stops it from declaring a million blocks, ten thousand nested C-blocks, a hundred megabyte costume, or a ZIP entry that expands past four gigabytes.
The rule is simple:
Loading a malicious or huge project must never freeze RustWarp. It opens normally, or it shows TurboWarp's load-error UI — within a bounded time.
This section documents how that requirement is tested. The limits themselves live in the loader
(web/fast-sb3.js, web/host.js, crates/rw-host-core/src/sb3.rs, crates/rw-native-runtime);
this page describes the gate that proves they exist and keeps existing.
tools/e2e/malicious/gen.mjs generates every fixture at CI time — nothing huge is committed.
The generator is deterministic (fixed DOS timestamps, seeded filler), so two runs produce
byte-identical archives and a measurement can be compared with a later one.
| Fixture | Shape | Why it is in the suite |
|---|---|---|
huge-blocks-one-script |
1 000 000 blocks in one next chain |
JSON parse, VM block graph, one enormous workspace stack |
huge-blocks-many-scripts |
1 000 000 blocks over 500 top-level scripts | the toolbox / many-hats path instead of one stack |
deep-c-blocks |
10 000 nested control_if C-blocks via SUBSTACK |
recursive block layout and a 10 000-deep stack visitor |
deep-reporters |
10 000 nested operator_add reporters |
recursive reporter rendering and evaluation |
deep-json |
a list value nested 10 000 JSON arrays | the JSON parser itself, before any Scratch code sees it |
zip-bomb |
three 1 GiB zero entries (≈3 GiB expanded) in a ~3 MB .sb3 |
ZIP decompression amplification |
zip-ratio-entry |
one 512 MiB zero entry (≈1000:1 ratio) | the per-entry ratio guard |
huge-list |
one 10 000 000-item list | list UI and monitor layout at 10M rows |
huge-svg |
1 000 000 × 1 000 000 px SVG with 1 000 000 <path> nodes |
SVG rasterization and DOM size |
many-targets |
10 000 sprites | sprite pane, per-target workspace bookkeeping |
many-costumes |
50 000 costumes on one sprite | asset list, thumbnail queue, skin cache |
oversized-asset |
a 200 MB costume asset inside the .sb3 |
whole-archive buffering and asset decoding |
real-700594743 |
Scratch project #700594743 (the real ~1.4k-block community project) |
end-to-end control fetched live through the Scratch API |
The real project is fetched at generation time through api.scratch.mit.edu (falling back to the
TurboWarp trampoline for the token) and then projects.scratch.mit.edu; if the network or the API
fails, the fixture records a skipped entry in manifest.json and the run continues — a Scratch
outage must not gate a RustWarp change.
Every generated project.json is a valid Scratch 3 file: the fixtures are accepted by the pinned
scratch-parser validator (web/fast-sb3.js's gate) and therefore reach vm.deserializeProject.
The suite tests the editor staying responsive, not the schema rejecting input.
.github/workflows/malicious-projects.yml has three
jobs:
-
Generate fixtures (
ubuntu-latest) — runsgen.mjsonce and uploadstools/e2e/malicious/out/fixtures(including the fetched real project) asmalicious-fixtures. -
Web (
ubuntu-latest) — buildsweb/dist, thentools/e2e/malicious/web.mjsloads every fixture in a fresh browser context per case:file— the realFile > Loadpath:loadProjectFileraises the hidden#project-filechooser and Playwright sets the generated.sb3on it, soweb/host.jsreads it witharrayBuffer()and callsloadProject, exactly as a user picking a file does;url—?project_url=<fixture>on the harness server, exercisingloadProjectUrl(fetch → arrayBuffer → VM) without exposing fixtures publicly;id— only for the real project, the production/#700594743route.
For each load it records: time to a terminal state, the longest main-thread task (
PerformanceObserver({type: 'longtask'})), the longest frame gap (arequestAnimationFramerecorder sampled from Node), stalls where the page could not answer a probe within 1.5 s, and peak JS heap (CDPRuntime.getHeapUsage, sampled from Node so a frozen main thread cannot hide the growth). -
Native (
macos-latest, because the desktop binary only compiles there) — buildsrustwarpand runsrustwarp --smoke-sb3 <fixture>for every fixture: the same headless loadDesktopRuntimeStateperforms (rw-host-coreZIP reader → embedded V8scratch-vm→rw-stage-render). It records the outcome (loaded/load-error/timeout/crash), the wall time, and peak RSS sampled from/proc/<pid>/status(Linux) orps -o rss=(macOS).
Both jobs append their markdown table to the job summary and upload JSON + markdown artifacts.
Every teardown step is raced against a deadline (MALICIOUS_TEARDOWN_EVAL_MS,
MALICIOUS_TEARDOWN_CLOSE_MS). This matters: in the first full run, closing one wedged page took
891 s, which alone turned a 14-minute load sweep into a 74-minute job. A page that cannot be
read or closed is simply reported from its last successful probe.
Terminal states, identical across both runners:
| State | Web | Native |
|---|---|---|
loaded |
PROJECT_LOADED and targets in the VM |
exit 0 |
load-error |
projectLoadError → TurboWarp error UI / sb3fix dialog |
exit 1 |
load-aborted |
load ended with no targets (a precheck declined it) | — |
crash-screen |
.rw-crash-wrapper visible |
— |
crash |
page error / panic / target crash | killed by a signal |
timeout |
no terminal state within the budget | still running at the budget |
The workflow's hard gate is deliberately narrow, because the loader limits are being implemented in parallel and this suite must be able to land first:
- Web: the browser tab stays alive — Playwright's target
crashevent never fires. This is the one assertion that always fails the job, because a dead tab can never be a legitimate outcome. A live tab that shows the crash overlay (or logs a wasmunreachable/ Rustpanicked at) is recorded and named in the table, but is advisory untilMALICIOUS_ENFORCE_PANIC=1: those are real P0 defects owned by the loader limits. - Native: a process abort (a signal death such as
SIGTRAPfrom V8 heap exhaustion, or an OOMSIGKILL) is recorded as an advisory miss untilMALICIOUS_ENFORCE_CRASH=1. It is a real defect, and the measured table names it, but the fix belongs to the loader-limit work. - Every fixture reaches a terminal state within the budget. Measured and published for every
run, but advisory until
MALICIOUS_ENFORCE_TERMINAL=1: a freeze is a known bug at this point, not a regression. In advisory mode the budget is a flat 30 s (MALICIOUS_ADVISORY_BUDGET_MS), so a hung fixture cannot eat two full minutes per load path and the sweep finishes in minutes; with enforcement on, each fixture's ownterminalStateMstarget (10 s) is the budget, so the target really means what it says. Measured on this suite: 37 s for the healthy sweep, ~7 min replaying the 2026-11-29 baseline, and 12 min in the pathological case where every one of the 24 loads burns its full budget.
The stricter goals live in tools/e2e/malicious/targets.json
as {enforce: false} per fixture:
terminalStateMs: 10000— a hostile project is rejected or opened within ten seconds;longestFrameGapMs: 200— the UI never blocks for more than a fifth of a second while loading;maxExpandedBytes/maxAssetBytes(documentation, not yet asserted) — the intended limits.
With enforce: false the measured value is printed as an advisory WARN row, so a run records the
current behaviour without failing. When the loader limits land, the implementing agent flips
enforce to true for the fixtures it covers (and sets MALICIOUS_ENFORCE_CRASH=1 /
MALICIOUS_ENFORCE_TERMINAL=1 in the workflow); the gate then fails a regression in that limit
instead of only reporting it. That is deliberately per fixture: the limits arrive in parallel, and
a fixture without its limit yet should not block the ones that have theirs.
Recorded on 2026-11-29 from run 46207552417 on test/p0-malicious-projects-e2e, before any
loader limit landed — this is the baseline the implementing agents work against. Artifacts:
malicious-web-results and malicious-native-results on that run.
Native (rustwarp --smoke-sb3; the message column is the binary's own stderr):
| Fixture | Outcome | Exit | Time | Peak RSS | Message |
|---|---|---|---|---|---|
huge-blocks-one-script |
load-error | 1 | 38.3 s | 3.18 GB | Maximum call stack size exceeded |
huge-blocks-many-scripts |
crash | SIGTRAP |
49.2 s | 3.08 GB | V8 abort (JS stack overflow) |
deep-c-blocks |
load-error | 1 | 1.0 s | 262 MB | Maximum call stack size exceeded |
deep-reporters |
load-error | 1 | 0.5 s | 155 MB | Maximum call stack size exceeded |
deep-json |
load-error | 1 | 0.1 s | — | recursion limit exceeded |
zip-bomb |
load-error | 1 | 38.6 s | 4.14 GB | Timed out waiting for scratch-vm loadProject |
zip-ratio-entry |
loaded | 0 | 11.0 s | 3.14 GB | — |
huge-list |
loaded | 0 | 13.5 s | 1.23 GB | — |
huge-svg |
loaded | 0 | 2.7 s | 469 MB | — |
many-targets |
loaded | 0 | 21.6 s | 851 MB | — |
many-costumes |
loaded | 0 | 51.8 s | 1.76 GB | — |
oversized-asset |
loaded | 0 | 10.4 s | 1.77 GB | — |
real-700594743 |
load-error | 1 | 0.1 s | — | Unknown extension: ev3 |
Web (1280×720 Chromium, SwiftShader; "tab" and "page" are the two independent crash
observations — a live tab can still show a panic):
| Fixture | Path | Terminal | Time | Longest task | Longest frame gap | Peak heap | Tab | Page |
|---|---|---|---|---|---|---|---|---|
huge-blocks-one-script |
file | load-error | 15.7 s | 11.9 s | 13.7 s | 1.34 GB | alive | ok |
huge-blocks-one-script |
url | load-error | 14.3 s | 11.3 s | 12.7 s | 1.35 GB | alive | ok |
huge-blocks-many-scripts |
file | crash | 23.1 s | — | — | 1.09 GB | alive | panic |
huge-blocks-many-scripts |
url | crash | 23.1 s | — | — | 1.09 GB | alive | panic |
deep-c-blocks |
file / url | load-error | 1.8 / 1.8 s | 0.44 / 0.23 s | 0.50 / 0.68 s | 60 / 8 MB | alive | ok |
deep-reporters |
file / url | load-error | 1.6 / 1.2 s | 0.44 / 0.22 s | 0.47 / 0.38 s | 35 / 7 MB | alive | ok |
deep-json |
file / url | loaded | 1.5 / 0.8 s | 0.60 / 0.21 s | 0.45 / 0.28 s | 10 / 8 MB | alive | ok |
zip-bomb |
file / url | loaded | 28.8 / 30.1 s | 16.2 / 16.1 s | 16.2 / 16.3 s | 13 / 12 MB | alive | ok |
zip-ratio-entry |
file / url | loaded | 11.3 / 10.8 s | 2.83 / 2.79 s | 2.65 / 2.80 s | 12 / 10 MB | alive | ok |
huge-list |
file / url | loaded | 2.2 / 1.9 s | 0.44 / 0.99 s | 1.00 / 1.04 s | 10 / 83 MB | alive | ok |
huge-svg |
file / url | loaded | 21.0 / 22.9 s | 6.87 / 8.54 s | 6.83 / 7.95 s | 13 / 27 MB | alive | ok |
many-targets |
file / url | timeout | 121.2 / 120.6 s | 0.44 / 0.23 s | 0.45 / 0.22 s | 66 / 64 MB | alive | ok |
many-costumes |
file / url | loaded | 20.8 / 21.5 s | 19.7 / 19.8 s | 19.7 / 20.0 s | 82 / 76 MB | alive | ok |
oversized-asset |
file | loaded | 8.8 s | 1.02 s | 0.79 s | 12 MB | alive | ok |
real-700594743 |
file / url / id | timeout | 121.2 / 120.6 / 120.5 s | 0.44 / 0.24 / 0.29 s | 0.43 / 0.25 / 0.28 s | 10 / 7 / 8 MB | alive | crash screen |
What the baseline says, in priority order:
huge-blocks-many-scriptsis the worst case on both stacks — the native process dies withSIGTRAP(V8 JS stack overflow, ~3.08 GB RSS, 49 s), and the web build reachespanicked at alloc/src/raw_vec/mod.rs(capacity overflow) followed byRuntimeError: unreachable. The tab survives, so it is recorded as a page panic, but the editor is gone. An uncaught stack overflow must become a load error, never a panic.- Deep nesting is caught, but far too late —
deep-c-blocks/deep-reportersand the 1M-block single stack all end inMaximum call stack size exceeded, which is the right outcome reached by the wrong route: 1M blocks still costs 38 s / 3.18 GB natively and 15.7 s / 13.7 s of blocked main thread on the web before V8 runs out of stack. zip-bombnever terminates on its own — the native loader expands until its own 30 sloadProjecttimeout fires at 4.14 GB RSS. A size/ratio cap must reject it up front.many-targetsnever terminates on the web — 120 s on both paths while the heap stays at ~65 MB and the longest task at 0.44 s. The main thread is idle, so this is a load that never completes rather than a freeze; it still violates the deadline.- The real project
#700594743does not load on either stack — nativelyUnknown extension: ev3; on the web a wasmunreachableending in the crash overlay on all three paths. The project's blocks areev3_beep, soev3is the blocker, independent of hostile input. Until that is available, the "legitimate-but-huge control" cannot pass, and every fixture row that needs a control should be read with that in mind. - The web
zip-bombrow measures a block, not amplification — it "loads" in ~29 s with a 16 s longest task, but the heap stays at ~13 MB because the referenced.pngcostumes are fetched lazily; the native path, which extracts every entry, is the one that shows the 4.14 GB cost. Treat the two rows as complementary, not contradictory. - Everything else loads, but
many-costumes(51.8 s native / 19.7 s blocked web),zip-ratio-entry(11.0 s, 3.14 GB native),huge-list(13.5 s, 1.23 GB native) andoversized-asset(10.4 s, 1.77 GB native) all sit past the 10 s strict target.
The first run of the suite on test/p0-malicious-projects-e2e records the pre-limit behaviour of
every fixture. Rows that end loaded show the loader coped; rows that end load-error show it was
refused; timeout/crash rows are the bugs the implementing agents fix. The measured table is in
the workflow run's job summary and in tools/e2e/malicious/out/malicious-web.md /
malicious-native.md artifacts.
Per repository policy, do not run Playwright or heavy builds on a development machine. Push the branch and use the workflow:
gh workflow run malicious-projects.yml --ref <branch>
gh run view --logThe fixture generator alone is cheap and can be run locally when changing it:
node tools/e2e/malicious/gen.mjs --out /tmp/malicious-fixtures --no-real--only <id,id> builds a subset; --list prints the fixture ids.
- Add a
build(dir)entry to thefixturesarray ingen.mjs; returnwriteFixture(dir, id, {projectJson, assets})so the archive lands atout/fixtures/<id>/<id>.sb3. - Add the id to
targets.jsonwithenforce: falseand the goal the fix should meet. - If the fixture is small enough for the URL path (below
MALICIOUS_URL_MAX_BYTES, 64 MiB by default) it gets both loads automatically; larger archives run the file path only. - Keep it deterministic: no
Date.now(), noMath.random(), fixed asset ids.
This suite is a regression gate, not the implementation. The actual caps belong in:
web/fast-sb3.js/web/host.js— archive entry count, per-entry and total expanded bytes, compression ratio,project.jsonbyte size, block count, nesting depth, target/costume counts;crates/rw-host-core/src/sb3.rs— the same checks before the native loader allocates;crates/rw-native-runtime— the V8-side load, so the native path fails the same way as the web path.
When a cap rejects a project it must emit a load error (the InvalidProject dialog or
projectLoadError), never a panic and never a frozen tab.