Skip to content

fix(wasi-http): validate ports in p2 set_authority like p3 - #14123

Merged
dicej merged 2 commits into
bytecodealliance:mainfrom
SashaMIT:fix/wasi-http-p2-authority-port-validation
Aug 12, 2026
Merged

fix(wasi-http): validate ports in p2 set_authority like p3#14123
dicej merged 2 commits into
bytecodealliance:mainfrom
SashaMIT:fix/wasi-http-p2-authority-port-validation

Conversation

@SashaMIT

Copy link
Copy Markdown
Contributor

Summary

  • Align WASIp2 OutgoingRequest::set_authority with the existing WASIp3 parse_authority check so empty, non-numeric, and out-of-range ports are rejected.
  • Share that helper at crate scope (authority.rs) so p2 and p3 cannot drift.
  • Extend unit coverage (example.com:65536, [::1]:abc).

http::uri::Authority accepts authorities such as example.com: and example.com:abc. p3 already rejects those (#13739 class). p2 did not. With a bad authority, default_send_request sees no numeric port and appends the scheme default, producing broken connect targets such as example.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'
  • Revert-tested: removing the port_u16 reject makes the new cases fail

Made with Cursor

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.
@SashaMIT
SashaMIT requested a review from a team as a code owner August 12, 2026 02:22
@SashaMIT
SashaMIT requested review from dicej and removed request for a team August 12, 2026 02:22
@SashaMIT

Copy link
Copy Markdown
Contributor Author

Fixed Rustfmt (trailing blank line after moving the authority tests).

@dicej dicej left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dicej
dicej added this pull request to the merge queue Aug 12, 2026
Merged via the queue into bytecodealliance:main with commit 43b3052 Aug 12, 2026
53 checks passed
SashaMIT added a commit to SashaMIT/oss-contributions that referenced this pull request Aug 12, 2026
@SashaMIT

Copy link
Copy Markdown
Contributor Author

Glad it landed, thanks for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants