Skip to content

Wildcard-port patterns in DefaultServerTransportSecurityValidator accept non-numeric ports #1192

Closed

Description

@anzal1

Servers that bind to a runtime-chosen localhost port use allowedHost("127.0.0.1:*") / allowedOrigin("http://localhost:*") in DefaultServerTransportSecurityValidator as their DNS-rebinding defense. The wildcard check is a bare prefix match (startsWith(base + ":")), so Host: 127.0.0.1:evil.com, 127.0.0.1:80.evil.com, Origin: http://localhost:evil.com and http://localhost:3000.evil.com all pass.

Browsers can't send these, so it's hardening, not an exploitable bypass. I found it comparing the SDKs: python-sdk has the same open issue (modelcontextprotocol/python-sdk#3364) and the Swift SDK already requires a digits-only port.

Proposal: require a non-empty digits-only port after the prefix. Patch and tests ready if wanted.

Activity

  1. added this to the 2.2.0-M2 milestone on Oct 20, 2026
  2. added a commit that references this issue on Oct 20, 2026
    7fc1c32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to haves, rare edge casesarea/serverenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions