Skip to main content

oapi-codegen CVE-2026-119028

| EUVDEUVD-2026-112756 HIGH
Code Injection (CWE-94)
2026-10-29 VulnCheck GHSA-qf68-jmvg-6fww
8.7
CVSS 4.0 · Vendor: VulnCheck
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Attacker controls/tampers OpenAPI document
  2. Delivery
    Craft non-literal enum entry closing const block
  3. Exploit
    Inject func init() into generated code
  4. Execution
    Victim builds generated Go package
  5. Persist
    Injected code executes on import
  6. Impact
    Arbitrary code execution in dev/build environment

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Code injection prevention, sandbox exec
MITRE ATT&CK

2 techniques across 2 tactics: Execution, Initial Access

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Exploitation requires that: (1) the attacker controls or can tamper with the OpenAPI document that is fed into code generation; (2) the document contains an enum in a non-string schema (type integer, number, or boolean) whose entry is a non-literal value that closes the const block in constants.tmpl and injects a func init() - per the advisory the schema must be referenced from a path or SkipPrune must be set, under default models output; and (3) the victim then builds and imports the generated package without reviewing the generated diff. Limiting factors: victim interaction is mandatory (UI:P - the victim must generate, build, and import the code), the issue only manifests for non-string enum types, and teams that only process first-party, reviewed specs are effectively not exposed. No fix is partial - updating to oapi-codegen 2.8.1 is the remediation per the referenced release and PR #2626, which rejects non-string enum values that are not number or boolean literals.

Impact

This is a genuine code-execution flaw (CWE-94) but its real-world risk is gated by an unusual precondition rather than being a trivially remote bug. The vendor CVSS 4.0 vector (AV:N/AC:L/AT:N/PR:N/UI:P, score 8.7) correctly captures that the malicious input (an OpenAPI document) can arrive over the network with no attacker privileges, but requires passive victim interaction (UI:P): the victim must run oapi-codegen against the attacker-influenced spec and then build and import the generated package WITHOUT reviewing the generated diff. VC:H/VI:H/VA:H is justified because successful injection yields arbitrary Go code execution in the build/runtime environment. No EPSS score and no KEV listing were provided, so there is no evidence of widespread or active exploitation; the exploitation status is therefore not 'in the wild.' The vuln.today decision label is 'this_week' (not act_now/emergency), consistent with a high-impact but precondition-dependent supply-chain-style issue. The main nuance to flag: the GHSA advisory was prepared against tested version 2.8.0 and states 'fixed in: not yet patched,' while the CVE record, PR #2626, and the v2.8.1 release tag indicate the fix landed in 2.8.1 - the fixed version should be read from the CVE/release data, not the advisory's draft status. Net: a real priority for teams that generate Go code from untrusted or third-party OpenAPI specs, lower urgency for those that only consume first-party, reviewed specs.

Exploit ScenarioDerived

An attacker who controls or tampers with an OpenAPI document (for example a third-party or contributed API spec) adds an integer, number, or boolean schema enum whose entry closes the const block in constants.tmpl and appends a func init(). When a developer runs oapi-codegen (2.0.0 through 2.8.0) with default models output and then builds and imports the generated package without reviewing the diff, the injected Go code executes at import time. A public PoC reference with confirmed execution exists in the GHSA advisory (emitting PWNED-C), though it is not verified as packaged working exploit code.

This Week Schedule remediation this week. Why: HIGH severity (CVSS 7.0-8.9).
Patch available 0.4% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Oct 29, 2026

Code injection in the oapi-codegen Go generator (versions 2.0.0 through 2.8.0) lets an attacker who controls or tampers with the OpenAPI document being generated insert arbitrary Go source through non-literal enum entries in integer, number, or boolean schemas, typically closing the emitted const block and appending a func init(). The injected code runs when the victim builds and imports the generated package, so the CVSS 4.0 vector scores PR:N but UI:P: the victim must generate, build, and import the output without reviewing the diff, and the schema must be reachable from a path or SkipPrune must be enabled. There is no CISA KEV listing; the vendor shipped a fix in 2.8.1 via PR #2626, the reporter's advisory includes working reproduction payloads, and exploitation is practical only for teams that generate from third-party or untrusted specs.

RemediationAI

Upgrade to oapi-codegen v2.8.1 (vendor-released patch: v2.8.1), which applies PR #2626 (commit 068f1bcd16e4724c72d78d6774008a877b8297b1) and makes GenerateEnums reject any non-string enum value that is not a Go number or boolean literal, returning an error before any template output is produced; see https://github.com/oapi-codegen/oapi-codegen/security/advisories/GHSA-g2vv-83pm-v2hc and the release notes at https://github.com/oapi-codegen/oapi-codegen/releases/tag/v2.8.1. Because the project already requires reviewing generated code before execution, the practical compensating control on unfixed versions is to treat every generated diff as untrusted input: inspect generated const blocks and func init() bodies before building, and refuse to generate from OpenAPI documents you do not control. A stricter option is to pre-validate specs and reject non-string (integer, number, boolean) schemas whose enum entries are not bare numeric or boolean literals, since ValidateSpec in affected versions only filters control characters; the trade-off is that this duplicates the upstream fix and may reject specs that were previously accepted. Teams that only generate from first-party, reviewed specifications are effectively not exposed and can schedule the upgrade normally.

Affected VersionsENISA

oapi-codegen 2.0.0 <2.8.1

Affected Packages

euvd oapi_codegen fix: 2.8.1

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in euvd

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

oapi-codegen renders Go bindings from an OpenAPI document using text/template; the enum template (pkg/codegen/templates/constants.tmpl, line 16 in v2.8.0) writes each enum value into a const block via {{$value}}. When a schema's Go type is not a string, ValueWrapper is empty and the value is emitted unquoted as Go source, so a spec-authored string such as '2 + 0; func init() { ... }; const _ = 3' terminates the const declaration and splices in attacker-chosen code. ValidateSpec does not walk enum values for this shape and only rejects control characters, and the payloads need no newlines, so gofmt and the import formatter accept the output as syntactically valid Go. This is CWE-94 (improper control of generation of code), the same class as the earlier server-description advisory GHSA-rjwr-m7qx-3fjr fixed in 2.7.1, which did not cover this field; the accompanying GHSA-g2vv-83pm-v2hc report also covers server-urls x-go-name and echo operationId middleware keys. The trigger here is confirmed as an unquoted enum value in a non-string schema; execution occurs at package import time for the enum variant.

Know when Oapi Codegen gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (VulnCheck) PRIMARY 8.7 HIGH
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
vuln.today AI 8.8 HIGH

The malicious spec is network-deliverable with no attacker privileges (AV:N/PR:N) but the victim must generate, build and import without review (UI:R), yielding full code execution (C/I/A:H); scope unchanged as code runs in the generated package's own process.

3.1 AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
4.0 AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
Red Hat 7.8 HIGH

Primary rating from Vendor (VulnCheck).

CVSS VectorVendor: VulnCheck

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
None
Privileges Required
None
User Interaction
Passive
Vulnerable system: Confidentiality
High
Vulnerable system: Integrity
High
Vulnerable system: Availability
High
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

DescriptionCVE.org

oapi-codegen 2.0.0 before 2.8.1 contains a code injection vulnerability that allows attackers to inject Go code by supplying non-literal enum entries in integer, number, or boolean schemas. Attackers controlling an OpenAPI document can craft an enum entry that closes the const block in constants.tmpl and injects a func init(), executing code when the generated package is built and imported.

Technical POC Analysis

CWE-94 (Improper Control of Generation of Code).

Full technical POC analysis - root cause, step-by-step exploitation and patch breakdown - is part of the Pro and Business plans.

Executive ViewAI

Why It Matters

A high-severity code injection vulnerability in the oapi-codegen Go generator (CVSS 8.7) allows attackers who control or tamper with an OpenAPI document to insert malicious Go source code into generated packages, which executes when developers build and import the code. Teams that generate from third-party or untrusted specs-especially those with default configurations enabling SkipPrune-are at risk of arbitrary code execution in their development and build environments. Leadership should prioritize remediation because this could compromise CI/CD pipelines and internal tooling if exploited.

Business Impact: High
Compensating Controls

Apply vendor patch (upgrade to oapi-codegen 2.8.1). Until patched, restrict generation to trusted specs, disable SkipPrune where possible, and implement manual review of generated code diffs.

Threat Intelligence Overview

EPSS Score
0.4%
Top 63% exploitable
Prevalence
Medium
popular Go OpenAPI code generator, build-time developer tooling not universal
Data Quality
5 sources
Confidence: Medium
EUVD NVD CVE.org EPSS Vulnrichment Vendor GitHub

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity HIGH
CISA KEV No
Public POC No
EPSS 0.4%
Patch available Yes
Active threat No
Deciding rule
HIGH severity (CVSS 7.0-8.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision
Scheduled
Exploitation
None
System Exposure· derived
Open
Automatable
No
Human Impact
High
Technical Impact
Total

Priority Score

44
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +44
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Code Injection CRITICAL

Code injection occurs when an application accepts user input and passes it directly into a language interpreter or evaluator without proper sanitization.

Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.

Vendor StatusVendor

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy