A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Add required info for Anthropic's OSS Scanner program (#14628)
Till Schneidereit0072becdb34d
diff --git a/.oss-scanner/Dockerfile b/.oss-scanner/Dockerfilenew file mode 100644index 0000000000..b845580ace--- /dev/null+++ b/.oss-scanner/Dockerfile@@ -0,0 +1,77 @@+# Build environment for Anthropic's OSS Scanner (https://red.anthropic.com/oss-scanner).+#+# The scanner builds this image with network access, using a checkout of this+# repository as the build context, and then analyzes Wasmtime inside it with no+# network access. Everything needed to build, test, and fuzz Wasmtime therefore+# has to be fetched here. See `threat_model.md` next to this file for what the+# scanner should focus on.+# Ubuntu 24.04 for its OCaml 4.14: the spec interpreter used by the+# `differential` fuzz target doesn't build against OCaml 5.+FROM ubuntu:24.04++ENV DEBIAN_FRONTEND=noninteractive+RUN apt-get update && apt-get install -y --no-install-recommends \+ ca-certificates curl git build-essential clang lld cmake pkg-config \+ libssl-dev python3 gdb \+ ocaml-nox ocamlbuild ocaml-findlib libzarith-ocaml-dev \+ && rm -rf /var/lib/apt/lists/*++COPY . /src+WORKDIR /src++# The spec, WASI, and component-model test suites are git submodules.+RUN git submodule update --init --recursive++# Like CI, turn off incremental compilation to reduce image size. Line tables still+# give file and line numbers in backtraces and gdb. These stay set in the final+# image so that later `cargo` invocations reuse the prebuilt artifacts.+ENV RUSTUP_HOME=/usr/local/rustup \+ CARGO_HOME=/usr/local/cargo \+ PATH=/usr/local/cargo/bin:$PATH \+ CARGO_INCREMENTAL=0 \+ CARGO_PROFILE_DEV_DEBUG=line-tables-only \+ CARGO_PROFILE_TEST_DEBUG=line-tables-only++# Use the nightly that CI pins to match OSS-Fuzz (`wasmtime-ci-oss-fuzz-pin`+# in `.github/actions/install-rust/action.yml`) for everything: the fuzz+# targets need a nightly, and a single toolchain keeps things simple.+RUN toolchain=$(sed -n '/wasmtime-ci-oss-fuzz-pin/,/version=/s/.*version=\(nightly-[0-9-]*\).*/\1/p' \+ .github/actions/install-rust/action.yml) \+ && test -n "$toolchain" \+ && curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path \+ --profile minimal --default-toolchain "$toolchain" \+ && rustup target add wasm32-wasip1 wasm32-wasip2 wasm32-unknown-unknown \+ && cargo install cargo-fuzz --version 0.13.2 \+ && cargo install wasm-tools++# Download every crate the workspace (including the fuzz targets and the test+# programs compiled to wasm) could need, so offline builds work later.+RUN cargo fetch++# Everything below is built in the dev profile, so debug assertions are on.+#+# Cargo rebuilds crates whenever the set of enabled features changes, so build+# the configurations that are most likely to be used later:+#+# 1. The `wasmtime` CLI at `target/debug/wasmtime`, and the tests at the+# repository root (`tests/all`, `tests/wast.rs`, `tests/disas.rs`, ...) with+# default features, as used by `cargo run` and `cargo test`.+RUN cargo build && cargo test --no-run+# 2. `clif-util` at `target/debug/clif-util`, for Cranelift's `.clif` tests.+RUN cargo build -p cranelift-tools+# 3. The full test suite as CI runs it, with all features enabled.+RUN ./ci/run-tests.py --no-run++# A release build of the CLI at `target/release/wasmtime`, to check whether a+# bug also reproduces without debug assertions.+RUN cargo build --release++# Build the fuzz targets the same way OSS-Fuzz does: optimized, with+# AddressSanitizer and debug assertions. They end up in+# `target/x86_64-unknown-linux-gnu/release/`.+RUN cargo fuzz build --debug-assertions++# Smoke-test the build: run the spec test suite on the CLI's test harness. A+# failure here should be visible in the build log, but not abort the build.+RUN cargo test --locked --test wast -- --quiet \+ || echo "WARNING: wast tests reported failures"diff --git a/.oss-scanner/threat_model.md b/.oss-scanner/threat_model.mdnew file mode 100644index 0000000000..eff2ec73cd--- /dev/null+++ b/.oss-scanner/threat_model.md@@ -0,0 +1,153 @@+# Wasmtime threat model++This document is for Anthropic's OSS Scanner. Wasmtime's security policy is+documented in `docs/`; read these first, they take precedence over anything+here, unless otherwise stated explicitly in this document:++* `docs/security-what-is-considered-a-security-vulnerability.md`: what is and+ isn't a vulnerability.+* `docs/stability-tiers.md` and `docs/stability-wasm-proposals.md`: which+ platforms and features are Tier 1. Only Tier 1 can have vulnerabilities.+* `docs/security.md`: sandboxing and defense-in-depth mechanisms.++This file only adds what those don't cover: trust boundaries, priorities,+severity ratings, and how to work in this image.++## What this project does and where untrusted input enters++Wasmtime runs WebAssembly modules and components, embedded via the `wasmtime`+crate or the C API, or through the `wasmtime` CLI.++**Untrusted**: the Wasm module or component (binary or text), across+validation, compilation, instantiation, and execution; everything the guest+does at run time, including values it passes to imports (WASI included) and+how it uses component-model resources and async features; and data reaching+the guest through WASI (files, sockets, HTTP in `wasmtime serve`).++**Trusted**: the embedder (host code, host functions, `Config`, CLI flags);+precompiled artifacts and cache contents (`Module::deserialize` and+`--allow-precompiled` are `unsafe` for untrusted input); and the host+environment, including which directories are preopened for WASI.++Bugs must be reachable through the public API (`wasmtime` crate, C API, CLI)+without violating the contract of any `unsafe` API.++## Components that matter most / least++The scanner runs on `x86_64-unknown-linux-gnu`, a Tier 1 target. Highest+value:++* **Cranelift's x86-64 backend and Wasm-to-CLIF translation**+ (`cranelift/codegen`, `crates/cranelift`, `crates/environ`), and **Winch**+ (`winch/`). Miscompilations that break memory isolation or control-flow+ integrity are sandbox escapes. See `.claude/skills/cranelift-auditor`.+* **Cranelift's aarch64 backend.** While the aarch64 backend isn't officially+ tier 1, it's approaching it, so we want to treat issues in it with high+ priority, with the same concerns as the x86-64 backend. Note that this+ overrides the policy in the docs.+* **The runtime** (`crates/wasmtime/src/runtime`): memories, tables, GC heap+ and collectors, libcalls, traps, stack-overflow handling, fuel/epochs, and+ the pooling allocator (including data leaking between reused slots).+* **The component model** (`crates/wasmtime/src/runtime/component`,+ `crates/environ/src/fact`): canonical ABI lifting/lowering, string+ transcoding, and resource handles.+* **Component model async support**+ (`crates/wasmtime/src/runtime/component/concurrent.rs` and+ `crates/wasmtime/src/runtime/component/concurrent`): everything part of the+ async runtime is high value, but in particular anything that can cause panics+ or deadlocks.+* **WASI** (`crates/wasi`, `crates/wasi-http`, `crates/wasi-io`):+ capability enforcement and guest-driven host resource consumption.+* **The C API** (`crates/c-api`).++Lower value, and not security vulnerabilities: everything below Tier 1 in the+tier documents (aarch64 above being the exception for prioritization), plus+off-by-default component-model features, test code, fuzzing infrastructure+(`crates/fuzzing`, `fuzz/`), examples, benches, `ci/`, `scripts/`, and+`cranelift/isle/veri`. Report Tier 2 bugs only if they are serious, rated Low,+and clearly marked as Tier 2. Do not report Tier 3 issues.++Any `Config` that `Engine::new` accepts is in scope if the features involved+are Tier 1. A bug that needs an unusual configuration is less severe than one+that triggers with the defaults.++## How to exercise it++General guidance on building, testing, and the CLI is in+`docs/contributing-testing.md`, `docs/contributing-fuzzing.md`,+`docs/contributing-reducing-test-cases.md`, `docs/cli-options.md`, and the+skills in `.claude/skills/` (`wasmtime-auditor`, `cranelift-auditor`,+`reduce-test-cases`; ignore their instructions about where to write reports).++Specific to this image: the following targets are prebuilt.+Other invocations (e.g. `cargo test -p <crate>`) use different feature sets+and can trigger long rebuilds on the small agent machine, so prefer putting+repros in `tests/misc_testsuite/` or `tests/all/`.++* `target/debug/wasmtime` (debug assertions) and `target/release/wasmtime`.+* The repository root's tests with default features (`cargo test`, e.g.+ `cargo test --test wast` or `--test all`).+* `target/debug/clif-util`.+* The whole workspace's tests as CI runs them: `./ci/run-tests.py`.+* The fuzz targets, built with ASan and debug assertions in+ `target/x86_64-unknown-linux-gnu/release/`; run with+ `cargo fuzz run --debug-assertions <target>`.+* `wasm-tools`.++Reproducers you write as `*.wast` files should be run with+`./target/debug/wasmtime wast *.wast`.++## How you rate severity++The impact on an embedder running an untrusted guest is what counts. A bug+that only shows up with debug assertions has no impact unless a release-mode+consequence is shown.++* **Critical**: a guest-controlled sandbox escape with the default+ configuration or a commonly used one (pooling allocator, async with+ fuel/epochs, Winch): arbitrary read/write of host memory, control of host+ execution, or a guest-triggerable use-after-free.+* **High**: a sandbox escape that needs a less common but supported+ configuration; a guest reading host memory or another instance's data; WASI+ capability bypasses; host memory unsafety reachable from safe embedder code+ driven by guest-controlled values.+* **Medium**: run-time denial of service against the host (see the+ vulnerability document), including resource exhaustion that escapes+ configured limits (`ResourceLimiter`, `StoreLimits`, pooling limits) or+ grows without bound in host code such as WASI. Memory unsafety that needs+ unusual but safe embedder API use, with no guest control.+* **Low**: unlikely configurations or embedder behavior with limited impact;+ defense-in-depth weaknesses with no demonstrated exploit; serious bugs in+ Tier 2 features (marked as such).++**Not vulnerabilities** but worth reporting as normal bugs: compile-time+denial of service, and divergence from Wasm semantics that stays inside the+sandbox (see the vulnerability document).++**Not vulnerabilities** and not worth reporting at all:++* Behavior allowed to differ between engines (see "Divergent WebAssembly+ behavior across runtimes" in `docs/contributing-fuzzing.md`).+* Resource use by a guest within the limits the embedder configured, or+ unlimited because the embedder set none.+* Anything that needs untrusted precompiled artifacts, cache contents, CLI+ flags, or `Config`, or bugs in embedder-written host functions.+* Spectre-style side channels beyond the mitigations in `docs/security.md`.++## How reports and patches should look++Follow "Making a bug report" in `.claude/skills/wasmtime-auditor/SKILL.md`+(or `cranelift-auditor` for Cranelift; a `.clif` repro should come with a Wasm+repro showing the bug is reachable from Wasm), and "Write Good Bug Reports" in+`docs/contributing-fuzzing.md`. Also state whether the bug reproduces in+release mode, and deduplicate by root cause.++Patches should be minimal, fix the root cause rather than the symptom, and add+a regression test (usually a `.wast` file in `tests/misc_testsuite/` or a test+in `tests/all/`).++## Anything to leave alone++Code specific to the other Tier 1 platforms (macOS and Windows on x86-64) is+in scope but cannot be run here: report such issues only with a strong,+concrete argument from the code.