CVE-2024-29034: Carrierwave Cross-Site Scripting Vulnerability
MODERATECVE-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
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).
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.
Upgrade carrierwave to 3.0.7
Upgrade carrierwave to 2.2.6
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
CVE-2024-29034 Affected Carrierwave Versions
2 component(s)| 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?
Which Carrierwave versions are affected?
What version fixes CVE-2024-29034?
Is carrierwave affected?
What is the CVSS score of CVE-2024-29034?
What CWE is associated with CVE-2024-29034?
How can I check RubyGems dependencies for CVE-2024-29034?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}