GHSA-rjwr-m7qx-3fjr: oapi-codegen: OpenAPI Server Description Escapes Generated Go Comment and Injects Executable Code
The vulnerability in oapi-codegen seems to be similar with CVE-2026-22785, which is a generated-code injection issue where untrusted OpenAPI summary text is embedded into generated TypeScript MCP server source without proper escaping. oapi-codegen has a similar vulnerability in its server URL generator: untrusted OpenAPI servers[].description text is inserted into a generated Go line comment without normalizing embedded newlines. A crafted description can break out of the comment, add imports through goimports, and emit executable Go declarations into the generated package.
[!NOTE] A vulnerability like this requires that it is missed in code review and that you then call the malicious method.
Using an
init()function could be enough to not require a direct call to the code, and instead rely on you importing the package, but either way, code review should be performed before anyoapi-codegengenerated code is executed.We strongly recommend all users to be reviewing changes to their generated code before they execute anything within it, to protect against supply chain attacks or malicious injected code.
This is also why we recommend
oapi-codegengenerated code is committed to source control.
References
Code Behaviors & Features
Detect and mitigate GHSA-rjwr-m7qx-3fjr with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →