---
id: "CVE-2026-119027"
kind: "vulnerability"
aliases: ["CVE-2026-119027"]
title: "oapi-codegen: crafted OpenAPI document injects Go code into generated packages"
severity: "high"
cvss: 7.7
epss: null
exploited: false
status: "open"
category: "package"
products: []
ecosystems: []
tags: ["code-generation", "go", "oapi-codegen", "package"]
not_affected_if: ["trusted-specs-only", "version-2.8.1-or-later"]
published_at: "2026-10-29T12:17:12+00:00"
first_seen_at: "2026-10-29T12:24:38+00:00"
updated_at: "2026-10-29T12:25:31+00:00"
sources: [{"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-119027", "first_seen_at": "2026-10-29T12:24:38+00:00"}]
---

# oapi-codegen: crafted OpenAPI document injects Go code into generated packages

oapi-codegen versions 2.5.0 through 2.8.0 emit a server URL name from the x-go-name field without escaping it, so a crafted OpenAPI document can inject Go code. An attacker who controls the spec gets code that runs when the generated package is built and imported.

_Summary, check and fix written by a model from the sources; labelled as such._

## How to check

- Run `oapi-codegen --version` or check the pinned `github.com/oapi-codegen/oapi-codegen/v2` version in `go.mod`
- Look for `servers[].x-go-name` in OpenAPI documents fed to the generator, especially ones from third parties

## Fix

- Upgrade oapi-codegen to `2.8.1` or later

## Timeline

- 2026-10-29T12:24:38+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-119027

## From the sources

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.

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
