oapi-codegen: OpenAPI Server Description Escapes Generated Go Comment and Injects Executable Code
What to do
Vendor fix available. Upgrade each affected package to the fixed version on its release line (github.com/oapi-codegen/oapi-codegen/v2 2.7.1), redeploy, then verify what is actually installed.
This page has no inventory attached, so it cannot say whether you are affected. A vendor fix is not proof that your deployment is fixed.
Affected packages
Go github.com/oapi-codegen/oapi-codegen/v2
- Affected
- < 2.7.1
- Fixed in
- 2.7.1
Sources
- GitHub Advisory Database and maintainer security advisories on GitHub
GitHub-reviewed advisory GHSA-rjwr-m7qx-3fjr lists affected ranges: Go github.com/oapi-codegen/oapi-codegen/v2 >=0 <=2.7.0
VerifiedObserved Structured GitHub Advisory Database record (type=reviewed) from the GitHub REST API.
- Open Source Vulnerabilities (OSV.dev), including the GitHub Advisory Database
OSV record GHSA-rjwr-m7qx-3fjr lists affected ranges: Go github.com/oapi-codegen/oapi-codegen/v2 >=0 <2.7.1 (fixed)
VerifiedObserved Structured OSV record; GitHub-reviewed advisory.
Severity and exploitation
- Exploitation
- No confirmed exploitation recorded. Patch Next marks exploitation only from CISA KEV.
- CVSS
- 0.0 · CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N
- EPSS
- No dated EPSS signal available.
Source description
As published by the source; long descriptions are shortened.
Summary 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 any `oapi-codegen` generated code is executed. > > We strongly recommend…
Dates and revisions
- Published by the source
- Last modified by the source
- Source last checked
- Revision 2 · amended ·
Amended from osv record GHSA-rjwr-m7qx-3fjr
- Revision 1 · created ·
Published from ghsa record GHSA-rjwr-m7qx-3fjr
Agent brief
Preview the exact text before you copy it. Commands are read-only suggestions; review them before running anything.
# Patch Next advisory brief: GHSA-rjwr-m7qx-3fjr Advisory: oapi-codegen: OpenAPI Server Description Escapes Generated Go Comment and Injects Executable Code IDs: GHSA-rjwr-m7qx-3fjr Record: https://patchnext.com/advisories/ghsa-rjwr-m7qx-3fjr (revision 2, source checked 30 Oct 2026, 07:05 UTC) Inventory: none attached. This brief comes from a public page and does not say whether any deployment is affected. Severity: Unrated (CVSS 0.0) Exploitation: no confirmed exploitation recorded. Patch Next confirms exploitation only from CISA KEV. Vendor response: Vendor fix available; fixed versions by package: github.com/oapi-codegen/oapi-codegen/v2 2.7.1. A vendor fix does not mean a deployment is fixed. ## Affected components - Go github.com/oapi-codegen/oapi-codegen/v2: affected < 2.7.1; fixed in 2.7.1 ## Suggested inspection (read-only) - Go github.com/oapi-codegen/oapi-codegen/v2: check the installed version with your package manager. ## Supported action Upgrade each affected component to a fixed version on its release line. For a transitive dependency, upgrade the parent package or add an override or constraint, then regenerate the lockfile. Redeploy every environment that ran an affected version. ## Required regression checks - Run the test suite and a production build. - Exercise the features that depend on github.com/oapi-codegen/oapi-codegen/v2. - Repeat the inspection and confirm that only fixed versions remain installed. ## Rollback considerations - Keep the previous lockfile and deployment artifact. Rolling back reinstates the vulnerable version, so apply any documented mitigation while you fix forward. ## Unresolved questions - Which deployments run an affected version? - Exploitation status can change. Check again before lowering the priority. - Mark the work resolved only after the fixed version is verified in production. ## Sources - Verified: https://github.com/advisories/GHSA-rjwr-m7qx-3fjr (GitHub-reviewed advisory GHSA-rjwr-m7qx-3fjr lists affected ranges: Go github.com/oapi-codegen/oapi-codegen/v2 >=0 <=2.7.0) - Verified: https://osv.dev/vulnerability/GHSA-rjwr-m7qx-3fjr (OSV record GHSA-rjwr-m7qx-3fjr lists affected ranges: Go github.com/oapi-codegen/oapi-codegen/v2 >=0 <2.7.1 (fixed)) Commands are suggestions: review each one before running it.
Loading voting…