The vulnerability exists in how Hono's AWS Lambda adapters handle incoming requests. The bodyLimit middleware relies on the Content-Length header to determine if a request body exceeds the configured size limit. However, on AWS Lambda platforms (including API Gateway, ALB, and Lambda@Edge), the entire request body is buffered and passed to the handler regardless of the client-declared Content-Length.
The analysis of the patch commits between the vulnerable version 4.12.24 and the patched version 4.12.25 revealed that the core issue was in the request creation logic within the Lambda adapters. Specifically, commit fa5f9bfcc25d65e08af85211cc2e5ecd0e0ea24b addresses the problem.
The vulnerable functions, EventProcessor.createRequest in src/adapter/aws-lambda/handler.ts and createRequest in src/adapter/lambda-edge/handler.ts, were responsible for constructing a standard Request object from the platform-specific Lambda event. Before the patch, these functions did not calculate the actual size of the received request body and overwrite the Content-Length header. This meant that a mismatched (and smaller) Content-Length sent by a client would be passed to the Hono application and its middleware.
The patch rectifies this by introducing logic in both functions to encode the body, calculate its actual byte length, and use this value to explicitly set the Content-Length header on the new Request object. This ensures that the bodyLimit middleware receives the correct size and can effectively enforce the limit, mitigating the bypass vulnerability.