Escape single quotes in generated route literals (GHSA-g4mf-q5hw-f9j9)

fix: escape single quotes in generated route literals (GHSA-g4mf-q5hw-f9j9) (#4006)
Escape single quotes in generated route literals (GHSA-g4mf-q5hw-f9j9)155a5b-fix-escape-single-quotes-in-generated-route-cve-2026-96754fixescape single quotes generated route literals

Committed by melloware

commit message
fix: escape single quotes in generated route literals (GHSA-g4mf-q5hw-f9j9) (#4006)

getRoute() rewrites {param} placeholders but passes static path text through
unchanged. Two sites embedded that result in single-quoted literals without
escaping, so a single quote in a static path segment terminated the literal --
producing broken TypeScript or, with a crafted path, an injected top-level type
declaration in the generated *.context.ts file.
 
- @orval/hono getContext: escape the path in the Context<E, '...'> type literal.
  generateHonoRoute was already fixed in source; a test now locks that in.
- @orval/mock getRouteMSW: escape the spec path and base URL for the
  http.get('...') literal in generated msw handlers. The escape happens inside
  getRouteMSW, before the intentional source-level colon escape is spliced in,
  so the emitted \: is not doubled.
 
getContext is exported so it can be tested directly, matching the existing
generateHandlerFile / resolveDefaultSchemaModule test exports.
 
The advisory named the hono sites; the msw handler is the same class of bug
reached through the same untrusted input.
 
Reported-by: SnailSploit
 
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>

Editor assessment

This commit patches CVE-2026-96754. Excellent body. It explains the getRoute rewrite, the two sites that embedded the result in single-quoted literals without escaping, the consequence (broken TypeScript or an injected top-level type declaration in *.context.ts), and the hono/msw fixes. It even notes why the source-level colon escape is not doubled. The header is clean; GHSA and PR noise in parentheses is the only flaw. Style-wise the body is well structured and the header is clean; the GHSA and PR references in parentheses are the only noise.

Browse categories

More fix examples · Back to search