Skip to content

Hardcoded Wildcard CORS (Access-Control-Allow-Origin: *) #280

Description

@srikanthramu

Describe the bug
Hardcoded Wildcard CORS (Access-Control-Allow-Origin: * ) is the default CORS headers to every response via withCorsHeaders().

Details
Here is the code -
https://github.com/modelcontextprotocol/php-sdk/blob/main/src/Server/Transport/StreamableHttpTransport.php#L74

The CORS override can happen at https://github.com/modelcontextprotocol/php-sdk/blob/main/src/Server/Transport/StreamableHttpTransport.php#L64, but I believe the SDK should follow the secure by default principle and allow the deployers to explicitly set insecure values if they need.

Recommendation
In the SDK, the transport layer should not own CORS policy. Server implementors who need cross-origin access can add a CORS filter at the servlet filter or Spring Security layer.

Activity

  1. chr-hertel commented on Apr 11, 2026

    @chr-hertel
    Member

    Thanks @srikanthramu, will be addressed in #277 and released with v0.6.0

  2. added
    ServerIssues & PRs related to the Server component
    on Apr 11, 2026
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

    ServerIssues & PRs related to the Server componentbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions