CVE-2024-29034: Carrierwave Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-vfmv-jfc5-pjjw
CVSS 6.8
CWE-436 CWE-79
Published
Advisory Summary

CVE-2024-29034 is a MODERATE (CVSS 6.8) cross-site scripting vulnerability (CWE-436: Interpretation Conflict) affecting Carrierwave libraries in the RubyGems ecosystem. The issue involves carrierwave content-type allowlist bypass vulnerability which possibly leads to xss remained. Remediation is available by upgrading affected packages to version 3.0.7, 2.2.6.

CVE-2024-29034 at a Glance

CVE Identifier CVE-2024-29034
GHSA Identifier GHSA-vfmv-jfc5-pjjw
Severity MODERATE
CVSS v3.1 Base Score 6.8
CWE Classification CWE-436: Interpretation Conflict
Affected Product Carrierwave
Package Ecosystem RubyGems
Published Date
Last Updated

Security Impact

CVSS: 6.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2024-29034

To remediate this vulnerability, upgrade all affected Carrierwave dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

carrierwave fixed: 3.0.7
Upgrade carrierwave to 3.0.7
carrierwave fixed: 2.2.6
Upgrade carrierwave to 2.2.6
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for carrierwave

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-29034, inspect your project dependencies for Carrierwave:

inspect dependencies for carrierwave

Analyze the terminal output to locate any version of Carrierwave in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.7), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-436: Interpretation Conflict, where product a handles inputs or steps differently than product b, which causes a to perform incorrect actions based on its perception of b's state. In Carrierwave, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact The vulnerability [CVE-2023-49090](https://github.com/carrierwaveuploader/carrierwave/security/advisories/GHSA-gxhx-g4fq-49hj) 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](https://rubygems.org/gems/carrierwave/versions/3.0.7) or [2.2.6](https://rubygems.org/gems/carrierwave/versions/2.2.6). ### Workarounds Use the following monkey patch to let CarrierWave parse the Content-type by using `Marcel::MimeType.for`. ```ruby # 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 ``` ```ruby # 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](https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html#content-type-validation)

CVE-2024-29034 Affected Carrierwave Versions

2 component(s)
Fixed Versions:
3.0.72.2.6
Product / Package Ecosystem Affected Versions Fixed Version
carrierwave
RubyGems
≥ 3.0.0
< 3.0.7
3.0.7
carrierwave
RubyGems
< 2.2.6
2.2.6

References

Frequently Asked Questions

What is CVE-2024-29034?
CVE-2024-29034 is a security vulnerability in Carrierwave involving CarrierWave content-Type allowlist bypass vulnerability which possibly leads to XSS remained under CWE-436: Interpretation Conflict.
Which Carrierwave versions are affected?
Affected versions include releases prior to 3.0.7, 2.2.6 across affected packages: carrierwave.
What version fixes CVE-2024-29034?
Upgrading to 3.0.7, 2.2.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is carrierwave affected?
Yes, carrierwave is affected in releases prior to 3.0.7, 2.2.6. Upgrade your dependency to 3.0.7, 2.2.6 or later.
What is the CVSS score of CVE-2024-29034?
CVE-2024-29034 has a CVSS v3.1 base score of 6.8 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2024-29034?
CVE-2024-29034 is classified under CWE-436: Interpretation Conflict (Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.).
How can I check RubyGems dependencies for CVE-2024-29034?
Run the dependency tree command: 'inspect dependencies for carrierwave'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-vfmv-jfc5-pjjw",
  "modified" : "2024-03-27T13:00:01Z",
  "published" : "2024-03-25T19:40:36Z",
  "aliases" : [ "CVE-2024-29034" ],
  "summary" : "CarrierWave content-Type allowlist bypass vulnerability which possibly leads to XSS remained",
  "details" : "### Impact\nThe vulnerability [CVE-2023-49090](https://github.com/carrierwaveuploader/carrierwave/security/advisories/GHSA-gxhx-g4fq-49hj) wasn't fully addressed.\n\nThis 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.\n\nThis bypassed value can be used to cause XSS.\n\n### Patches\nUpgrade to [3.0.7](https://rubygems.org/gems/carrierwave/versions/3.0.7) or [2.2.6](https://rubygems.org/gems/carrierwave/versions/2.2.6).\n\n### Workarounds\nUse the following monkey patch to let CarrierWave parse the Content-type by using `Marcel::MimeType.for`.\n\n```ruby\n# For CarrierWave 3.x\nCarrierWave::SanitizedFile.class_eval do\n  def declared_content_type\n    @declared_content_type ||\n      if @file.respond_to?(:content_type) && @file.content_type\n        Marcel::MimeType.for(declared_type: @file.content_type.to_s.chomp)\n      end\n  end\nend\n```\n\n```ruby\n# For CarrierWave 2.x\nCarrierWave::SanitizedFile.class_eval do\n  def existing_content_type\n    if @file.respond_to?(:content_type) && @file.content_type\n      Marcel::MimeType.for(declared_type: @file.content_type.to_s.chomp)\n    end\n  end\nend\n```\n\n### References\n[OWASP - File Upload Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html#content-type-validation)\n\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "carrierwave"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "3.0.7"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "carrierwave"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.2.6"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/carrierwaveuploader/carrierwave/security/advisories/GHSA-vfmv-jfc5-pjjw"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-29034"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/carrierwaveuploader/carrierwave/commit/25b1c800d45ef8e78dc445ebe3bd8a6e3f0a3477"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/carrierwaveuploader/carrierwave"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/carrierwave/CVE-2024-29034.yml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-436", "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-03-25T19:40:36Z",
    "nvd_published_at" : "2024-03-24T20:15:07Z"
  }
}