CVE-2024-29034: CarrierWave content-Type allowlist bypass vulnerability leading to XSS

carrierwave Updated 02 Oct 2025

Summary

25/03/2024
Yes i
Moderate
6.8

CVE-2024-29034: CarrierWave content-Type allowlist bypass vulnerability which possibly leads to XSS remained. Affects carrierwave across 2 version ranges.

< 2.2.6 >= 3.0.0, < 3.0.7

Fixed in 2.2.6 or 3.0.7, depending on the release line you run. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

CarrierWave is a RubyGem that provides a simple and efficient way to upload files from web applications to various storage services, including Amazon S3. It is widely used in Ruby on Rails applications to handle file uploads. The vulnerability in CarrierWave allows an attacker to bypass the content type allowlist and potentially execute cross-site scripting (XSS) attacks. This can lead to the injection of malicious code into web pages and compromise the security of the application.

Vulnerability Detail

The vulnerability arises from the ability to set a Content-Type value during file uploads that is different from what is allowed by the content_type_allowlist configuration. By providing multiple values separated by commas, an attacker can bypass the allowlist and upload files with malicious content types. This can be exploited to execute XSS attacks, where the injected code is executed by the victim's browser. This vulnerability has a CVSS score of 6.8, indicating a moderate level of severity.

How To Fix

Latest published version: 3.1.4 as of 23 Oct 2026

gem install carrierwave -v 3.1.4

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 2.2.6 2.2.6
    gem install carrierwave -v 2.2.6
  • >= 3.0.0, < 3.0.7 3.0.7
    gem install carrierwave -v 3.0.7

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If upgrading to the patched versions is not immediately feasible, a temporary workaround can be implemented using a monkey patch. The following code can be added to the application to parse the Content-Type 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

This workaround ensures that the Content-Type is correctly parsed and validated, mitigating the risk of the vulnerability.

Conclusion

The CarrierWave content-Type allowlist bypass vulnerability poses a risk of XSS attacks and compromise of web application security. It is crucial to upgrade to the patched versions or apply the provided workaround to mitigate this vulnerability. For further assistance and support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for carrierwave →

Share this vulnerability

FAQ

CarrierWave is a RubyGem that provides file upload functionality for web applications, particularly in Ruby on Rails. It simplifies the process of handling file uploads to various storage services.

The vulnerability allows an attacker to bypass the content type allowlist and potentially execute cross-site scripting (XSS) attacks. This can lead to the injection of malicious code into web pages and compromise the security of the application.

To fix this vulnerability, it is recommended to upgrade to CarrierWave version 3.0.7 or 2.2.6. These versions include patches that address the content-Type allowlist bypass.

Yes, a temporary workaround can be implemented using a monkey patch. The provided code snippet demonstrates how to parse the Content-Type using Marcel::MimeType.for.

The CVSS score of this vulnerability is 6.8, indicating a moderate level of severity.

Related vulnerabilities

Recent vulnerabilities recorded for carrierwave.

How To Fix

Latest published version: 3.1.4 as of 23 Oct 2026

gem install carrierwave -v 3.1.4

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 2.2.6 2.2.6
    gem install carrierwave -v 2.2.6
  • >= 3.0.0, < 3.0.7 3.0.7
    gem install carrierwave -v 3.0.7

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback