REDHAT-BUG-2521204: High severity go/github.com/getkin/kin-openapi vulnerability
kin-openapi is a Go project for handling OpenAPI files. From 0.124.0 until 0.142.0, openapi3filter.sliceMapToSlice in openapi3filter/reqrespdecoder.go converts attacker-controlled sparse indexes from a deepObject query parameter into a dense slice by allocating entries from zero through the largest supplied index, after which buildResObj creates another slice of the same length. This allocation occurs before schema validation, so maxItems does not prevent it. An unauthenticated client can send a small query such as param[items][50000000]=x to an endpoint whose deepObject schema contains an array, forcing multi-gigabyte heap allocation and causing an OOM kill or restart loop. Other request-body encodings and styled parameters that do not produce bracketed integer indexes are not affected. This issue is fixed in version 0.142.0.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
kin-openapito a version that resolves this vulnerability.Fixed in 0.142.0
Event History
Frequently Asked Questions
Which endpoints are exposed to this issue?
Endpoints are exposed when they use a deepObject query-parameter schema containing an array. The affected parsing path is triggered by bracketed integer indexes in the query parameter.
Does an attacker need authentication or a large request to trigger the problem?
No authentication is required. A small request with a sparse, very large array index can force large heap allocations.
Will a maxItems constraint prevent the allocation?
No. The allocation occurs before schema validation, so maxItems does not prevent the memory consumption.
Are all request parameter and body encodings affected?
No. Other request-body encodings and styled parameters that do not produce bracketed integer indexes are not affected.
What version resolves the issue?
The issue is fixed in version 0.142.0. Versions from 0.124.0 until 0.142.0 are affected.