fix(wasi-http): validate ports in p2 set_authority like p3 - #14123
Merged
dicej merged 2 commits intoAug 12, 2026
Merged
Conversation
p3 already rejects empty, non-numeric, and out-of-range ports via parse_authority. p2 only called http::uri::Authority::from_str, which accepts values such as example.com: and example.com:abc. With those authorities, default_send_request appends the scheme default port and builds broken connect targets (example.com::443 / example.com:abc:443). Share parse_authority for p2 and p3, and extend the unit coverage.
Contributor
Author
|
Fixed Rustfmt (trailing blank line after moving the authority tests). |
SashaMIT
added a commit
to SashaMIT/oss-contributions
that referenced
this pull request
Aug 12, 2026
Contributor
Author
|
Glad it landed, thanks for the review. |
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.
Summary
OutgoingRequest::set_authoritywith the existing WASIp3parse_authoritycheck so empty, non-numeric, and out-of-range ports are rejected.authority.rs) so p2 and p3 cannot drift.example.com:65536,[::1]:abc).http::uri::Authorityaccepts authorities such asexample.com:andexample.com:abc. p3 already rejects those (#13739 class). p2 did not. With a bad authority,default_send_requestsees no numeric port and appends the scheme default, producing broken connect targets such asexample.com::443/example.com:abc:443.Threat model: guest-controlled wasi-http authority string on the host outbound connect / TLS path. Fail closed before host I/O, matching p3.
Test plan
cargo test -p wasmtime-wasi-http --lib authority_accepts --features 'p2,p3'port_u16reject makes the new cases failMade with Cursor