oapi-codegen: Code injection via crafted servers[].x-go-name value
Summary
oapi-codegen, a Go tool that generates Go code from OpenAPI specifications, does not escape the servers[].x-go-name value in its server-urls template. An attacker who controls an OpenAPI document can inject Go code, including a func init() that runs when a victim builds or imports the generated package. The attack requires that a developer or CI/CD pipeline generates code from the malicious document.
Affected
- oapi-codegen 2.5.0 up to, but not including, 2.8.1
Fixed in
- Fixed in oapi-codegen 2.8.1 and later
Workaround
Unknown.
- No official workaround is published. Upgrading to 2.8.1 or later is required.
Exploitation
- No known exploitation according to OffSeq.
- Not listed in CISA's Known Exploited Vulnerabilities catalogue.
- EPSS: 0.39 % (percentile 34).
- CISA SSVC: exploitation none, automatable no.
- No public proof of concept found.
Our recommendation
- Check go.mod, tools.go and CI configuration for oapi-codegen and confirm version 2.8.1 or later. Check vendored or distribution packages too.
- Until upgraded, do not generate code from OpenAPI documents you do not control.
- Review changes to generated code in code review.
- Priority: medium if you build Go services from externally supplied API specifications, otherwise low.
Public exploits
PoC-in-GitHub, Metasploit and Exploit-DB list nothing for this CVE.
Research sources
- VulnCheck advisory www.vulncheck.com
- GitHub Security Advisory GHSA-g2vv-83pm-v2hc github.com
- oapi-codegen release v2.8.1 github.com
- Fix pull request #2626 github.com
- Patch commit 068f1bcd github.com
- Template server-urls.tmpl at v2.5.0 github.com
- Strix CVE record CVE-2026-119027 www.strix.ai
- NixOS packaging issue github.com
Researched and written up in English and German by an AI (Claude by Anthropic) based on NVD, CISA, EPSS and the sources listed. The vendor information is authoritative. Researched on 2 Nov 2026, 07:42.
Original description (NVD)
oapi-codegen 2.5.0 before 2.8.1 contains a code injection vulnerability that allows attackers to inject Go code by supplying a crafted servers[].x-go-name value emitted unescaped by the server-urls template. Attackers who control an OpenAPI document can define an injected func init() that executes when the victim builds and imports the generated package.
NVD references (8)
- https://github.com/oapi-codegen/oapi-codegen/blob/v2.5.0/pkg/codegen/templates/server-urls.tmpl#L4-L5
- https://github.com/oapi-codegen/oapi-codegen/blob/v2.8.0/pkg/codegen/templates/server-urls.tmpl#L5-L7
- https://github.com/oapi-codegen/oapi-codegen/commit/068f1bcd16e4724c72d78d6774008a877b8297b1
- https://github.com/oapi-codegen/oapi-codegen/pull/2626
- https://github.com/oapi-codegen/oapi-codegen/releases/tag/v2.8.1
- https://github.com/oapi-codegen/oapi-codegen/security/advisories/GHSA-g2vv-83pm-v2hc
- https://github.com/oapi-codegen/oapi-codegen/security/advisories/GHSA-rjwr-m7qx-3fjr
- https://www.vulncheck.com/advisories/oapi-codegen-2.5.0-before-2.8.1-code-injection-via-servers-x-go-name-ext…
Sources
The tracker combines official, freely usable data sources – updated continuously:
- NVD (NIST) – CVEs, rating (CVSS), affected products
- CISA KEV – vulnerabilities confirmed by CISA as actively exploited
- CISA Vulnrichment – CISA assessment (SSVC) in the official CVE record
- FIRST EPSS – probability of exploitation
- Microsoft MSRC – Patch Tuesday: vulnerabilities, severity, updates
- PoC-in-GitHub – public proof-of-concept repositories
- Metasploit (Rapid7) – modules of the Metasploit Framework
- Exploit-DB (OffSec) – archive of public exploits (links only)
- Patch days: official vendor pages (linked per vendor) (Vendor patch days)
This product uses data from the NVD API but is not endorsed or certified by the NVD. EPSS data © FIRST.org.
Affected? We can help.
We check whether your systems are affected, install updates and close the gap – continuously with the System Health Checker if you wish.
