Résumé

http4s: Set-Cookie rendering does not escape attribute delimiters

Détails de l’avis

Summary

ResponseCookie.render writes the cookie name, content, domain, path, and extension fields verbatim, with no sanitization of ; or control characters. An application that places attacker-controlled data into any of these fields lets the attacker inject additional cookie attributes (Domain=, Path=, SameSite=None, etc.) by embedding ; , widening a cookie's scope or downgrading its protections.

Impact

Cookie attribute injection: scope widening (Domain), SameSite downgrade, or overriding security-relevant attributes for applications that render attacker-influenced data in a ResponseCookie field. CR/LF in a field also threatens header splitting on backends that do not strip them.

Preconditions

  • Application constructs a ResponseCookie with attacker-influenced content, name, path, domain, or extension.
  • The application does not independently validate the value.

Workarounds

Validate cookie field values against the RFC6265 grammar before constructing ResponseCookie, rejecting ; and control characters.

Patch

  • Control characters are stripped from content, name, path, domain, and extension.
  • Semi-colons are stripped from content, name, path, and domain. Because extension is a single value, the semi-colon must be allowed as a delimiter, and sanitizing untrusted values remains the caller's responsibility.

Resources

Références