You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Duplicated standard MCP headers: only the first value is checked #1321
HttpServletMcpTransport.validateHeaders reads Mcp-Method, Mcp-Name and MCP-Protocol-Version with HttpServletRequest#getHeader, which returns only the first value. Any further values of the same header are ignored.
Impact
SEP-2243 headers exist so intermediaries (gateways, load balancers, WAFs) can route and apply policy without parsing the body. Intermediaries disagree on which copy of a duplicated header counts: some take the first, some the last, some join them with , . A request such as:
Mcp-Method: tools/list
Mcp-Method: tools/call
with a tools/call body can be routed or authorized by a last-value proxy as tools/list, then accepted by the server, which only looks at the first value. The same applies to Mcp-Name (e.g. a policy of the form "allow tool X").
Expected behaviour
A standard header with more than one value is malformed. The server should reject the request with -32020 (HeaderMismatch) and HTTP 400. This applies to repeated header lines and to a single comma-joined value alike.
RFC 9110 §5.3: repeated header lines are equivalent to one comma-joined value. These headers hold a single value, not a list, so a joined value is invalid.
The spec lists "a header value contains invalid characters" as a validation failure.
This is already how Mcp-Param-{Name} headers are handled (McpHeaderDecoder.paramHeaders).
Proposed fix
Read the headers with getHeaders(name) and require exactly one value for Mcp-Method, Mcp-Name and MCP-Protocol-Version. Add tests for duplicated values of each.
Activity
Reject Mcp-* headers with more than one value