Model Context Protocol (MCP) Security · Schema, Message, and Input Validation
Reject headers that don't match the body
Verify that MCP servers reject requests where mirrored request headers do not match the corresponding request body values, after decoding any encoded header values.
OWASP AISVS v1.01, requirement 10.4.12
In plain English
Where request details are mirrored into HTTP headers, the MCP server must confirm that the headers match the body and reject the request if they do not. Gateways make decisions from the headers. If the body says something different, the policy was applied to a request that never happened.
What good looks like
- The server decodes any encoded header values and then compares each mirrored header with the matching body value.
- A mismatch causes the request to be rejected.
- The comparison is exact, after decoding.
- Rejections are logged.
How teams usually do it
- Validation middleware that runs before any tool handling, using the SDK's implementation where one is available.
- Tests that cover encoded values, differences in case and duplicated headers.
Suggested evidence
- Server code or configuration.
- Tests with mismatched and encoded headers.
Common mistakes
- Comparing before decoding, so an encoded value slips past.
- Validating at the gateway only, when the server is the component that sees both header and body.
- Taking the first of two duplicate headers while the gateway read the second.
Not sure which requirements apply to your system? Take the assessment, or browse every guide in this chapter.
Requirement text from the OWASP AI Security Verification Standard, licensed under CC BY-SA 4.0. This guidance is shared under the same licence.