You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: escape spec-controlled strings in generated template literals and object keys (#3692)
* fix(core,zod): escape spec-controlled strings in generated template literals
Unescaped spec values (servers[].url, path segments, schema defaults)
were baked into generated template literals, allowing code injection via
backtick or ${ in an attacker-controlled OpenAPI spec.
Uses jsesc with quotes: 'backtick' to escape at three boundaries:
- getRoute(): raw OpenAPI path before param processing
- getFullRoute(): resolved server URL after variable substitution
- formatDefaultValue(): schema default values in zod generation
Addresses: GHSA-88f2-fpv8-89q2, GHSA-w727-8j6c-2rj4,
GHSA-3575-w9fc-c2j6, GHSA-2h9g-j24r-h63g, GHSA-8j6p-r8jg-mxqh,
GHSA-p4cg-3328-rvfg
* fix(zod): escape object keys via JSON.stringify in zod.object generation
Unescaped schema property and parameter names were emitted as
double-quoted keys in zod.object({...}), allowing computed property key
injection via " in the name.
Replaces "${key}" with JSON.stringify(key) at all 5 render sites.
Addresses: GHSA-6437-gxhq-pqv8, GHSA-653q-5476-x79g, GHSA-6mr6-jvcr-2f25
* fix(core): escape single-quoted object keys in getKey via jsStringLiteralEscape
Unescaped schema property names were wrapped in single quotes by getKey(),
allowing computed property key injection via ' in the name in MSW mock output.
Wraps the key body with jsStringLiteralEscape before quoting.
Addresses: GHSA-2w86-xfrc-g85r
* fix(query,zod): escape raw route prefix and prove backtick-in-key safety
mutation-generator.ts passed a raw spec path prefix to getFullRoute,
bypassing getRoute's escaping. Wrap with getRoute to close the gap.
Add test proving JSON.stringify-wrapped object keys are safe against
backtick injection (backtick is harmless inside double-quoted strings).
* fix: escape object-default keys and add ${} path test
- Escape object-default keys with JSON.stringify in zod schema defaults
(same fix as zod.object keys)
- Add test verifying ${globalThis.X} in path segments is not
re-interpreted as interpolation
- Update existing test expectations for quoted object keys
* fix(core): prevent ${} re-interpretation in getRoutePath and escape single quotes in getRouteAsArray
getRoutePath: after jsesc escapes ${ to \${, the remaining {evil} was
mistaken for an OpenAPI path param and re-converted to ${evil}. Add
early-return when { is preceded by $.
getRouteAsArray: segments wrapped in single-quoted strings without
escaping '. A spec path containing ' would break out. Now escapes
single quotes at both wrap sites.
* fix(core): handle ${} in getRoutePath and escaped tags in getRouteAsArray
getRoutePath: skip past ${...} block and continue processing remaining
suffix so later {param} segments are still converted.
getRouteAsArray: add (?<!\) to split/match regexes so jsesc-escaped
${...} is treated as literal text, preventing standalone backslash
from breaking single-quote wrapping.
* fix(core): escape per-segment in getRoute to preserve params after ${...}
0 commit comments