Repository navigation
fix(wasm-serve): enforce sandbox file containment, outbound SSRF guard, and 10MiB HTTP body limit - #760
Closed
thinhnx128 wants to merge 2 commits into
Closed
fix(wasm-serve): enforce sandbox file containment, outbound SSRF guard, and 10MiB HTTP body limit#760thinhnx128 wants to merge 2 commits into
thinhnx128 wants to merge 2 commits into
Conversation
…uard, and 10MiB HTTP body limit
Author
|
I have read the Arakoo CLA Document and I hereby sign the CLA |
…webassembly-pr-build.yml
Author
|
Note on CI: |
Author
|
Closing this to reduce review load — it wasn't requested by the maintainers. Thanks for your time; happy to reopen if it's useful. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 of Defensive Security Hardening for EdgeChains WASM Server (
JS/wasm/crates/serve)This PR hardens the WebAssembly host runtime in
JS/wasm/crates/serve/src/binding.rsandJS/wasm/crates/serve/src/lib.rs:1. Enforce Sandbox Path Containment in
Host::read_file(CWE-22)JS/wasm/crates/serve/src/binding.rsHost::read_filepreviously passed guest-supplied paths directly tofs::read_to_string(&path)without canonical path validation.validate_sandbox_file_path()to canonicalize both the configured sandbox root (EDGECHAINS_SANDBOX_DIRor current working directory) and the requested path, rejecting any path traversal outside the sandbox directory.2. Block Internal Loopback, RFC1918 Private, and Cloud Metadata IPs in
Host::send_request(CWE-918)JS/wasm/crates/serve/src/binding.rsHost::send_requestallowed WASM guests to issue outbound HTTP requests to arbitrary internal addresses, including127.0.0.1and cloud metadata endpoints (169.254.169.254).validate_outbound_url()andis_restricted_ip()to restrict schemes tohttp/httpsand reject loopback, link-local, RFC1918 private, and internal hostnames unlessEDGECHAINS_ALLOW_PRIVATE_NETWORK=1is explicitly enabled.3. Enforce 10 MiB Inbound HTTP Request Body Limit & Remove Unchecked
.unwrap()(CWE-400)JS/wasm/crates/serve/src/lib.rsWorkerCtx::handle_requestpreviously calledhyper::body::to_bytes(body).await.unwrap(), allowing unbounded request bodies to exhaust host memory (OOM) and panicking the worker thread on stream disconnects or malformed headers.MAX_REQUEST_BODY_BYTES(10 MiB), checkedContent-Lengthupfront, streamed body chunks with size enforcement (returning413 Payload Too Largeor400 Bad Request), and replaced header parsing.unwrap()calls with safe pattern matching.