Skip to main content
Menu
Advisories

Micronaut Netty server leaks pooled buffers when a streaming JSON request body contains a malformed element or is cancelled

GHSA-54GP-563G-92F3Published Updated GitHub

Description

Impact

What kind of vulnerability is it? Who is impacted?

Denial of service through memory exhaustion (CWE-401)..

When a JSON request body is bound as Publisher<T> or Flux<T> the server tokenises the incoming bytes into one retained slice per JSON element. A slice whose element fails to decode (a type mismatch such as a string where an integer is expected) is never released. Slices queued for the consumer are also dropped without release when the consumer cancels, for example with take(n), or when the consumer errors. A client sends an array whose first element is valid and whose second is malformed, and repeats; each request leaks one pooled buffer. The related application/x-json-stream List<T> binding double-releases the body on a parse error, replacing the intended 400 with a 500 (no leak).

Impacted: applications with a route that binds a JSON body as Publisher<T>, Flux<T> or another reactive type, which is the documented way to process large JSON arrays incrementally.

Patches

Has the problem been patched? What versions should users upgrade to?

Patched in 4.10.33 and 5.2.17. Message body readers now release the buffer on failure as well as on success, the tokeniser registers discard hooks so cancelled or queued elements are released, and the x-json-stream list path reads synchronously and reports malformed input as a 400.

Workarounds

Is there a way for users to fix or remediate the vulnerability without upgrading?

  • Bind the body as List<T> (or a single object) instead of Publisher<T>; the buffered path releases correctly on failure.
  • Validate the raw payload in a filter before binding if incremental processing must be kept.

References

Are there any links users can visit to find out more?

Affected versions

References

GitHub · micronaut-projects/micronaut-core