Repository navigation
Fail closed on forged and unsigned trusted context - #15
Open
codeitlikemiley wants to merge 7 commits into
Open
codeitlikemiley wants to merge 7 commits into
codeitlikemiley wants to merge 7 commits into
Conversation
The guest had no HMAC acceptor, so a portable middleware context or a client-supplied x-wasi-auth-* header could be confused with the signed ingress envelope. Accept only the HMAC envelope, strip credentials and reserved identity headers before the guest, and refuse a second CORS or security-header policy on the same response. Co-authored-by: Uriah Galang <[email protected]>
Debug of SessionId printed the raw identifier, so any Debug of a containing session leaked it into logs. Display and as_str still return the identifier for storage and the signed envelope. The host-probe test seals a now-relative envelope only when SPIN_ENVELOPE_OUT is set. Co-authored-by: Uriah Galang <[email protected]>
accept_signed_trusted_context now consumes each HMAC signature once in the guest process. The codec still only checks freshness, audience, method, path, and request ID. A second instance that shares the key can accept the same envelope until that window ends. Co-authored-by: Uriah Galang <[email protected]>
Parallel tests share the process-local seen-set. A later fixture clock pruned an entry another test still needed, so the second presentation looked accepted. The tests now take one lock for the consume sequence. Co-authored-by: Uriah Galang <[email protected]>
Move the exact rustls pin to 0.23.46 and cargo-update rustls-webpki 0.103.16, webpki-roots 1.0.11, quinn-proto 0.11.19, ctutils 0.4.5, and tokio 1.54.1. Refresh the SBOMs those crates appear in. crypto-bigint stays at 0.5.5. The advisory is fixed only in 0.7.6, and jsonwebtoken 10/11 plus passkey-auth 0.1.3 still require the elliptic-curve 0.13 stack. Co-authored-by: Uriah Galang <[email protected]>
…ry-5bda Co-authored-by: Uriah Galang <[email protected]>
Regenerate the ingress CycloneDX document so bytes, http-body, and http-body-util stay on the component dependsOn list. 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.
Problem / repro
Native ingress seals an HMAC-SHA-256 envelope into
x-wasi-auth-context, and the guest did not consume it.signed_context_accepts_once_and_fails_closed_on_expiry_rebind_and_replayrejected a different request ID (BindingMismatch) and a presentation after max-age (Expired). It then asserted thatTrustedContextCodec::openstill returnsOkfor the same binding through the freshness window. A direct Spin 4.2.5 guest therefore accepted an immediate replay of a valid envelope. The PRD requires that replay to fail closed.Ingress strips every client
x-wasi-auth-*header, including a correctly signed one, so the public listener does not honor a captured envelope. The replay that succeeded was a second request to the guest itself. Loopback is the deployment rule. This change does not assume the guest is unreachable.Root cause
The MAC binds audience, method, path, and request ID. That stops use on a different request. It does not stop a second presentation of the same bytes inside the freshness window (default 5s, maximum 30s). There was no per-process seen-set.
openis a pure check and stays that way.A shared nonce store is not available to a stateless multi-instance WASI guest. The defense that fails closed for the observed attack is a process-local set of accepted HMAC signatures, kept until that envelope can no longer pass
open.Implementation
accept_signed_trusted_contextrecords the signature afteropensucceeds. A second presentation in the same process returnsTrustedContextError::Replayed(trusted-context envelope was already accepted) and installs nothing. Headers are still stripped.Residual risk, stated on purpose: another process that shares the HMAC key has its own set and can accept the envelope until the freshness window ends. Ingress still strips client envelopes. Query and body stay outside the MAC.
SessionIdDebugprintsSessionId([REDACTED]).Displayandas_strstill return the identifier. This branch's lock remainswasip3 0.7.0+wasi-0.3.0.CI
Merges PR 18 (
83596f2987217fe6dd7ef7fbc42ac8f18b00bbb2) so rustls 0.23.46, rustls-webpki 0.103.16, webpki-roots 1.0.11, quinn-proto 0.11.19, ctutils 0.4.5, and tokio 1.54.1 are in this lock. No audit ignore was added.scripts/generate-sbom.shwas run after that merge. The ingress SBOM keeps[email protected],[email protected], and[email protected]on the componentdependsOnlist. That was the Final-WASI failure unique to this PR.crypto-bigint0.5.5 remains. RUSTSEC-2026-0387 is patched only in>=0.7.6, andjsonwebtoken10/11 pluspasskey-auth0.1.3 still requireelliptic-curve0.13 (crypto-bigint^0.5).cargo update -p crypto-bigintdoes not move it. Dependency policy and unpublished-package audit stay red on that one advisory.Tests / evidence
Toolchain: Rust 1.93.0. Head includes
0918bce(replay rejection) and636a1a4(the two consuming tests take one lock so a later synthetic clock cannot prune another test's entry). Tip is8a01142948f4174d6a6ef192ddb361bb132c9191.cargo test -p wasi-auth --features http --lib --offline -- http::tests --test-threads=16— 16 passed. That includes the immediate second request assertingReplayed, and a different seal still being accepted afterward.openat the end of the window still returnsOk; it does not consume.cargo +1.93.0 check --lockedofwasi-auth(postgres-native,outbox-worker),wasi-auth-ingress, andwasi-auth-migratepassed on the advisory lock.Spin 4.2.5 (
e09d7d5 2026-10-23), archive sha2568b26a8afd98874a0ce6c5c66ab9924ac2aba77de8abfd3f206dd37f313b58a56matchingchecksums-v4.2.5.txt. Guestboundary_probe.wasm(453557 bytes),wasm-tools1.253.0validateOK, exportwasi:http/[email protected].200, anonymous. Response still carriedauthorization,x-wasi-auth-subject, andcookie.x-wasi-auth-subject200, anonymous.200,accepted user=user-one.200,rejected trusted-context envelope was already accepted.200, expired.200, invalid.200, credentials without a signed trusted context.eyJ2ZXJzaW9uIjoxfQ200, invalid.POST /read200,bytes=10. No trap lines.GET /guest, and the same with forged, expired, or valid client envelopes200, guest saw onlyx-request-id, anonymous. Response had no identity or credential headers.client-secret, and__Host-session=session-secret401.Content-Length: 400000, and chunked 300 KiB413.504at 1.00s.POST /read200,bytes=10.200{"allowed":true,"reason":"cedar.allow","policy_revision":"embedded-v1",...}.organization_idorganization-two403Authorization request was rejected.The seeded rows are user
11111111-1111-4111-8111-111111111111, organization22222222-2222-4222-8222-222222222222, session33333333-3333-4333-8333-333333333333, roleowner, permissiondocument.read, plus an activeauth_signing_keysrow for the development kid. Native Cedar runs whenAuthorizationis present. A cookie alone is forwarded to the guest, which returned404for/api/authorization/check.Dependent PRs
Merge PR 18 first, then this PR, then PR 16. The overlap in
spin_grpc.rskeeps these security notes and usesspawn_local.PR 17 is the merge downstream can pin now:
4eff8edf8d3010b81d8fa30da576f9f11970e2f6. It has this boundary,wasip3 0.9.0+wasi-0.3.0, and the advisory bumps. No tag was published.