CVE-2026-119027

oapi-codegen 2.5.0 before 2.8.1 Code Injection via servers[].x-go-name Extension

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

Analysis

AI-generated

Technical impact

The vulnerability arises because oapi-codegen’s server‑urls template emits the servers[].x-go-name extension without escaping it. An attacker who can supply or tamper with an OpenAPI document can embed arbitrary Go code, such as a func init, that is compiled and executed when the victim builds and imports the generated package. This results in the ability to run attacker‑supplied code with the privileges of the build environment, potentially compromising confidentiality, integrity, or availability of built applications.

Affected Systems

The affected product is the Go OpenAPI generator, oapi-codegen, for all releases from 2.5.0 up to but excluding 2.8.1. Developers using these versions to generate client or server code from any OpenAPI specification that may contain a servers[].x-go-name field are at risk.

Risk and Exploitability

With a CVSS score of 7.7 the vulnerability is classified as high severity. The EPSS score is not available and the issue is not recorded in the CISA KEV list. The likely attack vector involves an attacker providing or manipulating the OpenAPI specification that the build pipeline consumes. Once the victim’s build system runs oapi-codegen against the malicious spec, the injected Go code is compiled and executed, giving the attacker arbitrary code execution on the build host.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade oapi-codegen to version 2.8.1 or later, which escapes the x-go-name value in the template.
  • Validate or whitelist the servers[].x-go-name extension in the specification before code generation to ensure only approved identifiers are used.
  • Limit the source of OpenAPI documents to trusted, signed repositories and run the code generation in an isolated, read‑only build environment.

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.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.
Title oapi-codegen 2.5.0 before 2.8.1 Code Injection via servers[].x-go-name Extension
Weaknesses CWE-94
References
Metrics cvssV3_1

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

cvssV4_0

{'score': 7.7, 'vector': 'CVSS:4.0/AV:N/AC:L/AT:P/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, 5:20 PM
Reserved
Oct 29, 2026, 11:32 AM
Status
Awaiting Analysis
Published
Oct 29, 2026, 12:17 PM
Modified
Oct 29, 2026, 6:17 PM
Severity
Important
Public date
Oct 29, 2026, 11:36 AM