Skip to content

2.3.0

Latest

Choose a tag to compare

@rcambien rcambien released this 05 Nov 15:15
abec534

Security

  • Fix a denial of service with crafted multipart content (GHSA-wvq4-f5wr-7hj4). Adjacent boundaries copied the rest of the stream for each of them, and the number of parts, the nesting depth and the cost of header parsing were not bounded: a few KB of input could use hundreds of MB of memory and seconds of CPU. Upgrading is recommended for any application parsing untrusted multipart content.
  • New limits: 1000 parts per content, nested parts included, and 16 nesting levels, configurable with StreamedPart::setMaxParts() and StreamedPart::setMaxDepth() (null for no limit). Above them, a LimitExceededException (a \LogicException) is thrown. At most 100 options are parsed per header.

Fixes

  • Raw UTF-8 in headers, such as non-ASCII field and file names sent by browsers, is no longer replaced with ? (#62)
  • Binary parts with a base64 or quoted-printable encoding and no charset are no longer corrupted by charset detection
  • An unsupported charset no longer throws a ValueError on PHP 8
  • Semicolons inside quoted header options no longer split them (#64)
  • Header option names are looked up case-insensitively, filename* takes precedence over filename, and RFC 2231 continuations are supported
  • Underscores in Q encoded-words are decoded as spaces on PHP < 8.3

Behaviour changes

  • Header values are always returned as valid UTF-8
  • Non-text parts without a declared charset are returned as is, without charset detection
  • \" is unescaped in quoted header options
  • getHeaderValue() and getMimeType() are trimmed
  • Malformed headers, common in emails, are parsed as before

Credits

Thanks to @aran112000 for #62, #64 and for reporting GHSA-wvq4-f5wr-7hj4.