Skip to content

Security: PATCH /session response schema declares 200 but handler sends 204 — validation bypass #289

Description

@LucasMaupin

Summary

The PATCH /session/:sessionId route handler calls reply.code(204).send() on success, but the TypeBox response schema only declares 200: Type.String(). This mismatch means Fastify applies the wrong serializer and the 204 response bypasses schema validation.

Location

  • src/api_productions.tsPATCH /session/:sessionId route (schema ~line 754, handler response ~line 827)

Details

Fastify validates and serializes responses according to declared status code schemas. When the actual response code (204) is not declared in the schema, Fastify cannot validate the response. While not directly exploitable today, this undermines the type-safety guarantees of Fastify's schema-driven approach and could mask future security regressions where sensitive data is accidentally included in a response.

Note: Related issue #248 covers the missing body: field in this same route. This 204/200 mismatch is a separate gap.

Recommendation

Add 204: Type.Null() to the response schema and remove the incorrect 200: Type.String() entry:

response: {
  204: Type.Null(),
  400: Type.String(),
  500: Type.String(),
}

Severity

LOW

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

securitySecurity vulnerability or hardening

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions