Repository navigation
Stabilize middleware contracts on wasip3 0.9 and Spin 4.2.5 - #1
Open
codeitlikemiley wants to merge 4 commits into
Open
codeitlikemiley wants to merge 4 commits into
codeitlikemiley wants to merge 4 commits into
Conversation
Pin wasip3 0.9.0 and wit-bindgen 0.62.0, and spawn guest tasks with spawn_local. Raise the library MSRV to 1.94 and the quality-gate compiler to 1.99.0. Share request-ID, CORS, security-header, and broker-decision behavior between the native and portable paths, and record this repository as the canonical middleware source. Wasmtime 50.0.0 and official Spin 4.2.5 pass the HTTP contract for the composed handler and native middleware. Spin still omits HTTP/1.1 response trailers; HTTP/2 writes them. Co-authored-by: Uriah Galang <[email protected]>
Hyper 1.11 writes chunked trailers when the request includes TE: trailers and the response declares those names. The echo service now sends Trailer: x-echo-trailer. The shared contract expects the field with that request header and expects it to be omitted without one. Spin 4.2.5 still writes the same field on HTTP/2. Wasmtime 50 serve rejects the HTTP/2 preface with hyper::Error(Parse(VersionH2)). Co-authored-by: Uriah Galang <[email protected]>
Baseline nosniff and Referrer-Policy are written only when that field is absent, and Access-Control-* fields are left untouched when a downstream policy is already present. Vary is still merged. Native HeaderMap and portable field lists share that decision. Co-authored-by: Uriah Galang <[email protected]>
The Actions workflow is disabled for inactivity, and push only matched main, so pull requests on this branch produced no checks. Keep every existing job, add this branch to push, and pin cargo-semver-checks 0.51.0 so the semver job can read Rust 1.99 rustdoc format v61. Require the 1.99.0 compiler explicitly, and stamp the fuzz lockfile path crates to 0.2.0-alpha.3. Co-authored-by: Uriah Galang <[email protected]>
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.
CI
GitHub reported no checks on this pull request because workflow
CI(id 311190778) isdisabled_inactivity(updated 2026-09-10T08:59:42Z). A disabled workflow does not start onpull_requestorpush.on.pull_requestwas already present with no branch filter.on.pushlisted onlymain, so a push of this branch would not match even after the workflow is enabled. Commitf23c7d6keeps every existing job and addsgol/stabilize-middleware-contracts-894atopush.PUT /repos/codeitlikemiley/wasi-http-middleware/actions/workflows/311190778/enablereturned 403 (actions=writerequired). After pushingf23c7d6, the workflow state was stilldisabled_inactivity, the commit had 0 check runs, and this pull request'sstatusCheckRollupwas empty. That push was not queued. Enabling the workflow in the Actions tab, then pushing another commit or running the workflow on this ref, is what will create the jobs. There are no GitHub job conclusions forf23c7d6.The last main schedule run, https://github.com/codeitlikemiley/wasi-http-middleware/actions/runs/34458171742 (2026-09-10, head
61b4199), failed only in Semver and package structure: https://github.com/codeitlikemiley/wasi-http-middleware/actions/runs/34458171742/job/102809391692. That job installed Rust 1.93.0 andcargo-semver-checks0.48.0. The script exited 1 and printed none of the tool log, because a failinggrep -Fqunderset -ediscarded the captured output. Replaying that commit today with Rust 1.93.0 andcargo-semver-checks0.48.0 exits 0, so that retained log does not identify a still-reproducing tool error.This branch's semver job uses Rust 1.99.0.
cargo-semver-checks0.48.0 rejects that compiler's rustdoc JSON (unsupported rustdoc format v61).0.51.0reads v61, and the existing expected summaries still match. The script now prints the tool log when a summary does not match.scripts/require-rust-1.99.shfails a 1.99.0 job if Cargo would use current stable (1.99.1) instead.cargo +1.99.0 fmt --all -- --checkandcargo +1.99.1 fmt --all -- --checkare both clean, so no source was reformatted.cargo audit --deny warningsexits 0 onCargo.lock(65 crates) andfuzz/Cargo.lock(29 crates) against 1352 advisories. Neither lockfile containsrustls,rustls-webpki,webpki-roots,quinn-proto,ctutils,tokio, orcrypto-bigint. RUSTSEC-2026-0387 did not appear and is not ignored.cargo deny checkexits 0; the duplicatesyn2.0.118 / 3.0.9 warning stays a warning (multiple-versions = "warn").wasip3stays=0.9.0andwit-bindgenstays=0.62.0. The rootCargo.lockis unchanged.f23c7d69e645b3363ba17935c12d179cfb025683changes CI, the semver-report tool line, the semver script's failure output, and the fuzz lockfile's path-package versions (wasi-http-metadataandwasi-http-policy-corefrom0.2.0-alpha.1to0.2.0-alpha.3). It does not change middleware Rust, the public API, or behavior. Downstream repos that pin behavior can stay on3df96c21a7906b885e67229e9a7c8c01b6497109. Repos that track this branch tip should move tof23c7d6.Problem / repro
Portable and native middleware duplicated request-ID, CORS,
Vary, security-header, and broker-decision logic. Cross-origin requests whose method was outside the allowlist still reflectedAccess-Control-Allow-Origin, including simple browser GETs.accept_trusted_ingressaccepted a superset of the configured audiences. The unsignedAuthContextV1envelope was easy to confuse withwasi-auth's HMAC trusted context.wasi-authalso vendors this tree atlegacy/wasi-http-middleware. Two copies will diverge.The guest pins were behind the coordinated target:
wasip30.7.0 andwit-bindgen0.59.0.wasip30.8+ renamedspawntospawn_local. The July Spin fork does not serve finalwasi:http/[email protected]plus nativedependencies.middleware.HTTP/1.1 responses that carry WASI trailers were first treated as a host bug. They are not. Hyper 1.11 (
src/proto/h1/conn.rswrite_trailers) sends HTTP/1.1 trailers only when the request hasTE: trailers(RFC 9110 §6.5.1) and only for names listed in the responseTrailerheader. The echo fixture declared noTrailername, and the contract client did not sendTE.apply_security_headersand the portable CORS merge inserted unconditionally. If this middleware runs afterwasi-authon the same response, it replacedReferrer-Policy: same-originandX-Content-Type-Optionswhile leaving CSP and HSTS. That is an inconsistent policy.wasi-authcodeitlikemiley/wasi-auth#15 stops its own writer from clobbering a foreign policy. This repository still overwrote.Root cause
Policy decisions lived in both
wasi-http-policy-coreand the component crates, so the portable path could accept a request the native path would reject. CORS applied the method allowlist only to preflight. Audience checks compared the service id and then treated any overlapping audience as sufficient. HMAC dotted envelopes are not valid base64urlAuthContextV1, but that rejection was not tested as a boundary.The legacy tree was a byte copy of this repo, pinned in
wasi-authmetadata at an older SHA (006352a) than the bytes actually checked in.The trailer fixture omitted
Trailer: x-echo-trailer. Without that declaration, and withoutTE: trailerson the request, Hyper correctly ends the HTTP/1.1 body at the zero chunk.HeaderMap::insertand portableset_headerreplace the named field. CORS merge deleted every non-Varydecision name and wrote this middleware's values, including onto an existingAccess-Control-*policy.Upstream status
wasi:[email protected].wasip30.9.0 still embeds that package. The binding crate andwit-bindgenpin are what changed.wasip30.9.0 pinswit-bindgen0.62.0 exactly. Do not move the generator to 0.63.0.codeitlikemiley/spin-rust-sdkrevision3cf30012b50a1afb750dac3d28aa6da4a32c3468(Align spin-sdk with wasip3 0.9 and Wasmtime 50 spin-rust-sdk#1, branchgol/wasi-dep-stabilization-1365). This workspace does not depend on thespin-sdkcrate.spinframework/spinv4.2.5 linux-amd64 (e09d7d5, 2026-10-23). Thecodeitlikemiley/spinfork is not a host.TE: trailersand the response declares the name. Spin 4.2.5 also writesx-echo-traileron HTTP/2 prior knowledge.wasmtime serve50.0.0 (ebe5e8df1, 2026-10-20) does not accept HTTP/2 prior knowledge. Both-W component-model-async=y -S p3=y -S cli=y -S http=yand-S cli,http,p3 -W component-model-async,component-model-error-contextloghyper::Error(Parse(VersionH2)). Curl exits 56. Wasmtime HTTP/2 trailers are unverified becauseserverejects the preface. Those flags were not changed for the header guard, and the HTTP/2 probe was not repeated on3df96c2.Implementation
wasip3 = "=0.9.0"(http-compat),wit-bindgen = "=0.62.0"(async-spawn).package.rust-versionis1.94.rust-toolchain.tomland CI pin1.99.0, notstable.wasip3::spawniswasip3::spawn_localin the echo service and mock broker.wasi-http-policy-coreowns request-ID canonicalization, the security-header table,Varymerging, CORS evaluation (including simple cross-origin methods), andaccepted_claims. Nativewasi-http-authnand the portable components call those functions.Referrer-Policy: same-originand a non-baselineX-Content-Type-Options. CSP and HSTS are still never written.Access-Control-*fields are copied only when the downstream response has none, so a foreign CORS policy is not replaced and sibling fields such asAccess-Control-Allow-Credentialsare not mixed in.Varyis still merged and*is not narrowed.absent_security_header_fieldsandcors_field_editsare the shared decision;apply_security_headers/apply_cors_headersand the portable*_to_fieldsforms both use them.security-headers,cors, andsecure-defaultscall those functions. Request IDs are still replaced.accept_trusted_ingressrequires exact audience-list equality. Dotted HMAC envelopes are rejected and stripped./trailersresponse setsTrailer: x-echo-trailer. The shared contract reads the raw HTTP/1.1 message: withTE: trailersit requiresx-echo-trailer: preserved; withoutTEit requires that field to be absent and the body to remain.docs/CANONICAL.mdis the ownership decision and the removal plan for Agent 4. Crate version stays0.2.0-alpha.3. The next operator tag isv0.2.0-alpha.4; this commit is not a release.wasm32-wasip2links the WASI 0.2.12 reactor adapter. The exact-import gate records that adapter separately from policy imports. Filesystem, sockets, and Spin storage imports stay forbidden.Tests / evidence
Commands were run on 2026-10-24. Header non-overwrite and the E2E re-run are commit
3df96c2.rustc +1.99.0 --version1.99.0 (b940084d7 2026-09-28)cargo +1.99.0 --version1.99.0 (5f94df478 2026-08-27)cargo +1.99.0 test --workspace --locked --all-featuresnative_and_portable_response_policy_preserves_downstream_headersHeaderMapand portable field-list result: keepssame-origin, nosniff, CSP, HSTS, and a foreignAccess-Control-Allow-Origin; does not add credentials; mergesVarytoAccept-Encoding, Origin; fills absent baseline fieldscargo +1.99.0 clippy --workspace --locked --all-targets --all-features -- -D warningscargo +1.99.0 fmt --all -- --checkcargo +1.94.0 check --workspace --locked --all-targets --all-featuresrustc 1.94.0 (4a4ef493e 2026-03-02))cargo +1.94.0 check --workspace --locked --target wasm32-wasip2 --all-featuresSTREAM_FAILURE_REPEATS=50 bash scripts/run-wasmtime-e2e.shTE: trailerspresent and no-TEomitted. Log assertion is116 + 50 + 25terminal invocations (IMMEDIATE_FAILURE_REPEATSleft at the script default 25)STREAM_FAILURE_REPEATS=50 bash scripts/run-wasmtime-secure-defaults-e2e.shSPIN_COMPAT_PROFILE=release-composedandrelease-native,STREAM_FAILURE_REPEATS=50,SPIN_BIN=/tmp/wasi-tools/spin-v4.2.5/spinx-echo-trailer: preserved3df96c2. On4cc129f:hyper::Error(Parse(VersionH2)), curl exit 56, on both flag setsComponents were rebuilt for
wasm32-wasip2before the E2E (scripts/build-components.sh), so the composed and native hosts ran this commit's policy.Resolved lock: one
[email protected]+wasi-0.3.0, one[email protected],[email protected]. Nowasip30.4 or 0.6. No second guestwit-bindgen.spin --versionobserved:spin 4.2.5 (e09d7d5 2026-10-23).wasmtime --versionobserved:wasmtime 50.0.0 (ebe5e8df1 2026-10-20).Compatibility and security
Vary: Originand does not reflectAccess-Control-Allow-Origin.*when this middleware is the CORS policy. Header*is literal.Access-Control-*policy is left as written. This middleware does not addAccess-Control-Allow-Credentialsonto a foreignAccess-Control-Allow-Origin.Referrer-PolicyorX-Content-Type-Optionsis left as written. Absent baseline fields are still filled. CSP and HSTS stay with the application orwasi-auth.AuthContextV1. This crate does not verifywasi-authMACs.wasm32-wasip2reactor, not new middleware capabilities.TE: trailers. Clients that do not must not see the trailer fields. HTTP/2 on Spin 4.2.5 writes the field withoutTE.Dependent PRs
3cf30012b50a1afb750dac3d28aa6da4a32c3468. After that PR merges, consumers should repin to the merge commit ifmainis not that SHA.wasi-authnon-overwrite guard: Fail closed on forged and unsigned trusted context wasi-auth#15. This PR is the matching guard on the shared policy core.docs/CANONICAL.mdincodeitlikemiley/wasi-auth: deletelegacy/wasi-http-middlewareand depend on this repository's stabilization commit. Also apply the matrix A4 pins (wasip3=0.9.0,wit-bindgen=0.62.0,spawn_local).Intended targets
package.rust-versionwasip3=0.9.0(0.9.0+wasi-0.3.0)wit-bindgen=0.62.0wasi:[email protected]spin-sdk(consumers only)3cf30012b50a1afb750dac3d28aa6da4a32c34680.2.0-alpha.3