Uncontrolled Resource Consumption in kin-openapi deepObject Decoder
An unauthenticated remote attacker can cause a denial-of-service via memory exhaustion by supplying a large integer index in a 'deepObject' style query parameter.
What's new
- 1. added coverage for kin-openapi Aug 22, 01:17 via ghsa
The openapi3filter component within kin-openapi (versions v0.124.0 through v0.141.0) is vulnerable to uncontrolled resource consumption. When the library processes query parameters serialized with style: deepObject, it attempts to reconstruct arrays from bracketed indices (e.g., param[items][50000000]=x). The decoder materializes the full array based on the highest index provided by the client before any schema validation occurs. Consequently, a small, 24-byte HTTP request can force the application to allocate gigabytes of memory, leading to an OOM (Out of Memory) crash. Because validation logic like maxItems runs after this materialization process, it cannot prevent the initial memory exhaustion. This vulnerability affects any service using kin-openapi for request validation that exposes an OpenAPI operation with a deepObject array parameter.
Attack Chain
- Attacker identifies an endpoint utilizing
kin-openapithat processesdeepObjectquery parameters containing an array schema. - Attacker crafts a minimal HTTP GET request containing a
deepObjectquery parameter with a high-value integer index (e.g.,param[items][50000000]=x). - The
kin-openapirouter identifies the route and passes the request toopenapi3filter.ValidateRequest. - The decoder parses the query string and enters
sliceMapToSlice, which identifies the maximum user-supplied index. - The library performs an unbounded loop from 0 to the attacker-supplied maximum index to initialize a
[]anyslice, allocating memory for every index in the range. - The
buildResObjfunction performs a second, equally-sized allocation for the final result array. - The application service crashes due to excessive heap allocation, causing a denial-of-service.
Impact
Successful exploitation allows an unauthenticated remote attacker to cause a denial-of-service by forcing an application crash. The amplification factor is extreme; a 24-byte request can force an allocation of ~6.1 GiB. This vulnerability impacts any service infrastructure relying on kin-openapi for API request validation, potentially leading to widespread service unavailability for affected applications.
Recommendation
- Identify all services utilizing
kin-openapiversions betweenv0.124.0andv0.141.0that exposedeepObjectquery parameters. - Upgrade the
kin-openapidependency to a patched version once available from the maintainers. - Implement a Web Application Firewall (WAF) or upstream proxy to drop requests containing extremely large integer values within bracketed query parameters (e.g.,
\[[0-9]{7,}\]). - Monitor application server logs for frequent crash loops or OOM-related restart events following the deployment of this library.