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.