Skip to main content

CVE-2024-29034 — Vulnerability in carrierwave — CVE Details

MEDIUM

CarrierWave content-Type allowlist bypass vulnerability which possibly leads to XSS remained

Published March 25, 2024Updated March 27, 2024Source: OSV

What Should I Do?

Address in Next Maintenance Window

Low exploitation probability (0.63%). Schedule for your next planned update.

Does your project use an affected carrierwave version?

Paste your Gemfile.lock to check it for CVE-2024-29034 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.

Check my Gemfile.lock

Summary

Impact

The vulnerability CVE-2023-49090 wasn't fully addressed.

This vulnerability is caused by the fact that when uploading to object storage, including Amazon S3, it is possible to set a Content-Type value that is interpreted by browsers to be different from what's allowed by content_type_allowlist, by providing multiple values separated by commas.

This bypassed value can be used to cause XSS.

Patches

Upgrade to 3.0.7 or 2.2.6.

Workarounds

Use the following monkey patch to let CarrierWave parse the Content-type by using Marcel::MimeType.for.

# For CarrierWave 3.x
CarrierWave::SanitizedFile.class_eval do
  def declared_content_type
    @declared_content_type ||
      if @file.respond_to?(:content_type) && @file.content_type
        Marcel::MimeType.for(declared_type: @file.content_type.to_s.chomp)
      end
  end
end
# For CarrierWave 2.x
CarrierWave::SanitizedFile.class_eval do
  def existing_content_type
    if @file.respond_to?(:content_type) && @file.content_type
      Marcel::MimeType.for(declared_type: @file.content_type.to_s.chomp)
    end
  end
end

References

OWASP - File Upload Cheat Sheet

Advisory Timeline

  • First published March 25, 2024 (976 days ago).
  • Last revised March 27, 2024 — 2 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

Bundler
Update carrierwave to 3.0.7 or later
gem install carrierwave -v 3.0.7
Bundler
Update carrierwave to 2.2.6 or later
gem install carrierwave -v 2.2.6

After upgrading, scan your dependencies again to confirm the vulnerability is resolved.

Affected Packages (2)

Affects 1 ecosystem: RubyGems (1).

PackageFixed In
carrierwave RubyGems · Affected: 3.0.0, 3.0.1, 3.0.2, 3.0.3 (+3 more)3.0.7
carrierwave RubyGems · Affected: 0.1, 0.10.0, 0.11.0, 0.11.1 (+66 more)2.2.6

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 6.8 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
Low
User Interaction
Required
Scope
Changed
Confidentiality
High
Integrity
None
Availability
None

CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:N/A:N

Frequently Asked Questions

What is CVE-2024-29034?
CarrierWave content-Type allowlist bypass vulnerability which possibly leads to XSS remained. This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 6.8/10).
How do I check if my project is affected by CVE-2024-29034?
CVE-2024-29034 affects carrierwave. It has a 0.6% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2024-29034 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
6.8

Exploitation requires specific conditions, or the impact is limited.

EPSS Score (30-day exploit probability)
0.63%
EPSS percentile: 44.8

This is a below-median EPSS score — only 44.8% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.

Also Known As

GHSA-vfmv-jfc5-pjjw

Related CVEs

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my Gemfile.lock