Skip to content

Conversation

@majiayu000
Copy link

Summary

  • Added NulByteValidationMiddleware to validate incoming requests
  • Returns 400 Bad Request when NUL bytes (%00) detected in URL path or query
  • Prevents PostgreSQL encoding errors from being exposed as 500 errors

Before

GET /v0.1/servers?cursor=%00
→ 500 Internal Server Error
→ "invalid byte sequence for encoding UTF8: 0x00"

After

GET /v0.1/servers?cursor=%00
→ 400 Bad Request
→ "Invalid request: query parameters contain null bytes"

Fixes #862

Added NulByteValidationMiddleware to validate incoming requests and
return 400 Bad Request when NUL bytes are detected in the URL path
or query parameters. This prevents PostgreSQL encoding errors and
properly rejects malformed input.

Fixes modelcontextprotocol#862

Signed-off-by: majiayu000 <1835304752@qq.com>
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.

Unhandled NUL Bytes in API Requests

1 participant