The vulnerability lies in the improper handling of the Content-Type HTTP header. Attackers could bypass request body validation by appending a tab character (\t) to a valid content type (e.g., Content-Type: application/json\tfoo).
The root cause was in the ContentTypeParser.getParser function, which incorrectly considered a tab character as a valid separator when matching a content type to a registered parser. This caused Fastify to select the correct parser (e.g., for application/json) and process the request body accordingly. However, the validation step would use the full, malformed content type string (application/json\tfoo) to look up a validation schema. Since no schema existed for this invalid type, validation was completely bypassed, while the application logic still received the parsed body, trusting it to have been validated.
The entry point for this vulnerability was the handleRequest function, which took the raw Content-Type header from the request and passed it down to the parsing and validation logic without initial sanitization.
The patch addresses this by introducing a new ContentType class that strictly parses and validates the header value against RFC specifications. The handleRequest function now uses this class to reject requests with invalid Content-Type headers upfront. Furthermore, all methods within the ContentTypeParser class, including getParser and add, were updated to use this new class to ensure that only valid and normalized content types are processed, effectively eliminating the parsing ambiguity that led to the bypass.