CVE-2026-119028

oapi-codegen 2.0.0 before 2.8.1 Code Injection via Non-String Enum Values

Published Oct 29, 2026 CVSS 4.0 · 8.7 High EPSS < 1% KEV · Not listed
Description
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.

Analysis

AI-generated

Technical impact

oapi-codegen 2.0.0 through 2.8.0 contains a code injection flaw that allows an attacker to embed arbitrary Go code by inserting non-string enum values in integer, number, or boolean schemas. The vulnerability is triggered when a malicious OpenAPI document is processed; the embedded enum closes the Go const block in constants.tmpl and injects a func init(). When the generated package is built or later imported, the injected init function runs, potentially executing attacker‑supplied logic. This flaw maps to CWE‑94 as a classic code injection weakness and can compromise the build or runtime environment of any system that uses the generated code.

Affected Systems

The vulnerability affects users of the open‑source Go code generator oapi-codegen, specifically version 2.0.0 up to and including 2.8.0. Any project that relies on these releases for generating Go client or server code from an OpenAPI specification is at risk if the spec is provided by an untrusted source.

Risk and Exploitability

The flaw has a CVSS score of 8.7, indicating significant impact. The EPSS score is not available, so the current probability of exploitation is uncertain; however, the vulnerability is not listed in CISA KEV, meaning no confirmed public exploitation yet. Attackers must supply a malicious OpenAPI document that the development team processes. If the generated code is compiled or imported within the build environment, the arbitrary code runs with the permissions of that environment, enabling potential data exfiltration, privilege escalation, or further compromise of the host system.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade oapi-codegen to version 2.8.1 or newer, where the injection issue is fixed.
  • Ensure that any OpenAPI specification used by the generator originates from trusted, authenticated sources and impose schema validation that rejects non-string enum values for integer, number, or boolean fields.
  • If upgrading is not immediately possible, isolate the code generation process: generate the code in a sandboxed environment, manually review the generated constants.tmpl output for unexpected init functions, and remove or neutralize them before building or importing the package.

Generated by OpenCVE AI on October 29, 2026 at 12:35 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
First Time appeared Oapi-codegen
Oapi-codegen oapi-codegen
Vendors & Products Oapi-codegen
Oapi-codegen oapi-codegen
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'none', 'Technical Impact': 'total'}, 'version': '2.0.3'}

Type Values Removed Values Added
Description 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.
Title oapi-codegen 2.0.0 before 2.8.1 Code Injection via Non-String Enum Values
Weaknesses CWE-94
References
Metrics cvssV3_1

{'score': 8.8, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H'}

cvssV4_0

{'score': 8.7, 'vector': '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'}

Weaknesses
  • CWE-94

    Improper Control of Generation of Code ('Code Injection')

Sources

Status
PUBLISHED
Assigner
VulnCheck
Published
Updated
Oct 29, 2026, 2:08 PM
Reserved
Oct 29, 2026, 11:32 AM
Status
Awaiting Analysis
Published
Oct 29, 2026, 12:17 PM
Modified
Oct 29, 2026, 4:19 PM
Severity
Important
Public date
Oct 29, 2026, 11:36 AM