CarrierWave Content-Type allowlist bypass vulnerability, possibly leading to XSS
Moderate severity
GitHub Reviewed
Published
Nov 29, 2023
in
carrierwaveuploader/carrierwave
•
Updated Nov 30, 2023
Package
Affected versions
>= 3.0.0, < 3.0.5
< 2.2.5
Patched versions
3.0.5
2.2.5
Description
Published by the National Vulnerability Database
Nov 29, 2023
Published to the GitHub Advisory Database
Nov 29, 2023
Reviewed
Nov 29, 2023
Last updated
Nov 30, 2023
Impact
CarrierWave::Uploader::ContentTypeAllowlist has a Content-Type allowlist bypass vulnerability, possibly leading to XSS.
The validation in
allowlisted_content_type?
determines Content-Type permissions by performing a partial match.If the
content_type
argument ofallowlisted_content_type?
is passed a value crafted by the attacker, Content-Types not included in thecontent_type_allowlist
will be allowed.In addition, by setting the Content-Type configured by the attacker at the time of file delivery, it is possible to cause XSS on the user's browser when the uploaded file is opened.
Patches
Upgrade to 3.0.5 or 2.2.5.
Workarounds
When validating with
allowlisted_content_type?
in CarrierWave::Uploader::ContentTypeAllowlist , forward match(\A
) the Content-Type set incontent_type_allowlist
, preventing unintentional permission oftext/html;image/png
when you want to allow onlyimage/png
incontent_type_allowlist
.References
OWASP - File Upload Cheat Sheet
References