Skip to content

Commit e1d8ce3

Browse files
jasnowRubySec CI
authored andcommitted
Updated advisory posts against rubysec/ruby-advisory-db@840f21a
1 parent 17a6349 commit e1d8ce3

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
layout: advisory
3+
title: 'CVE-2024-29034 (carrierwave): CarrierWave content-Type allowlist bypass vulnerability
4+
which possibly leads to XSS remained'
5+
comments: false
6+
categories:
7+
- carrierwave
8+
advisory:
9+
gem: carrierwave
10+
cve: 2024-29034
11+
ghsa: vfmv-jfc5-pjjw
12+
url: https://github.com/carrierwaveuploader/carrierwave/security/advisories/GHSA-vfmv-jfc5-pjjw
13+
title: CarrierWave content-Type allowlist bypass vulnerability which possibly leads
14+
to XSS remained
15+
date: 2024-03-25
16+
description: |
17+
### Impact
18+
19+
The vulnerability [CVE-2023-49090](https://github.com/carrierwaveuploader/carrierwave/security/advisories/GHSA-gxhx-g4fq-49hj)
20+
wasn't fully addressed.
21+
22+
This vulnerability is caused by the fact that when uploading to
23+
object storage, including Amazon S3, it is possible to set a
24+
Content-Type value that is interpreted by browsers to be different
25+
from what's allowed by `content_type_allowlist`, by providing
26+
multiple values separated by commas.
27+
28+
This bypassed value can be used to cause XSS.
29+
30+
### Patches
31+
32+
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).
33+
34+
### Workarounds
35+
Use the following monkey patch to let CarrierWave parse the
36+
Content-type by using `Marcel::MimeType.for`.
37+
38+
```ruby
39+
# For CarrierWave 3.x
40+
CarrierWave::SanitizedFile.class_eval do
41+
def declared_content_type
42+
@declared_content_type ||
43+
if @file.respond_to?(:content_type) && @file.content_type
44+
Marcel::MimeType.for(declared_type: @file.content_type.to_s.chomp)
45+
end
46+
end
47+
end
48+
```
49+
50+
```ruby
51+
# For CarrierWave 2.x
52+
CarrierWave::SanitizedFile.class_eval do
53+
def existing_content_type
54+
if @file.respond_to?(:content_type) && @file.content_type
55+
Marcel::MimeType.for(declared_type: @file.content_type.to_s.chomp)
56+
end
57+
end
58+
end
59+
```
60+
61+
### References
62+
63+
[OWASP - File Upload Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html#content-type-validation)
64+
cvss_v3: 6.8
65+
patched_versions:
66+
- "~> 2.2.6"
67+
- ">= 3.0.7"
68+
related:
69+
url:
70+
- https://nvd.nist.gov/vuln/detail/CVE-2024-29034
71+
- https://github.com/carrierwaveuploader/carrierwave/security/advisories/GHSA-vfmv-jfc5-pjjw
72+
- https://github.com/carrierwaveuploader/carrierwave/commit/25b1c800d45ef8e78dc445ebe3bd8a6e3f0a3477
73+
- https://github.com/advisories/GHSA-vfmv-jfc5-pjjw
74+
---

0 commit comments

Comments
 (0)