GitHub Advisoryadvisory · RubyGems
GHSA-gxhx-g4fq-49hj CarrierWave Content-Type allowlist bypass vulnerability, possibly leading to XSS
MEDIUM
Official page ↗
- Aliases
- CVE-2023-49090
- Ecosystem
- RubyGems
- Packages
- carrierwave
- Severity
- Moderate
- CVSS vector
- CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:N/A:N
- Weaknesses
- CWE-79
- Reviewed
- 2023-11-29
Affected packages
• RubyGems carrierwave: >= 3.0.0, < 3.0.5 → fixed in 3.0.5
• RubyGems carrierwave: < 2.2.5 → fixed in 2.2.5
Description
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 of `allowlisted_content_type?` is passed a value crafted by the attacker, Content-Types not included in the `content_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 in `content_type_allowlist`, preventing unintentional permission of `text/html;image/png` when you want to allow only `image/png` in `content_type_allowlist`.
References
OWASP - File Upload Cheat Sheet
Related
Alias · CVE (1)
- CVE-2023-49090 CarrierWave is a solution for file uploads for Rails, Sinatra and other Ruby web frameworks. vulnerability
Weakness · CWE (1)
- CWE-79 Improper Neutralization of Input During Web Page Generation weakness
References
- https://github.com/carrierwaveuploader/carrierwave/security/advisories/GHSA-gxhx-g4fq-49hj web
- https://nvd.nist.gov/vuln/detail/CVE-2023-49090 advisory
- https://github.com/carrierwaveuploader/carrierwave/commit/39b282db5c1303899b3d3381ce8a837840f983b5 web
- https://github.com/carrierwaveuploader/carrierwave/commit/863d425c76eba12c3294227b39018f6b2dccbbf3 web
- https://github.com/carrierwaveuploader/carrierwave package
- https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/uploader/content_type_allowlist.rb web
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/carrierwave/CVE-2023-49090.yml web
- https://rubygems.org/gems/carrierwave/versions/2.2.5 web
- https://rubygems.org/gems/carrierwave/versions/3.0.5 web