CVE-2026-44587: CarrierWave Content-Type Denylist Regex Bypass (Stored XSS)
CarrierWave, a popular Ruby file-upload framework, contains a flaw in its content-type blocking mechanism that silently fails to prevent dangerous uploads. When developers configure a denylist to block file types—most commonly SVG files to prevent stored cross-site scripting (XSS)—the framework inadvertently allows those exact files through due to improper handling of special characters in the filter rules. An attacker can exploit this to upload malicious SVG files containing embedded JavaScript that executes in users' browsers when served by the application, resulting in account compromise or data theft.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 4.7 MEDIUM · CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:N/A:N
- Weaknesses (CWE)
- CWE-184, CWE-625, CWE-79
- Affected products
- 1 configuration(s)
- Published / Modified
- 2026-06-17 / 2026-06-18
NVD description (verbatim)
CarrierWave is a framework to upload files from Ruby applications. In versions prior to 2.2.7 and 3.1.3, the 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. In lib/carrierwave/uploader/content_type_denylist.rb:57, denylist entries are interpolated directly into a regex without Regexp.quote or anchoring, so an entry such as image/svg+xml becomes the pattern /image\/svg+xml/, in which + is treated as a quantifier rather than a literal character and therefore never matches the real MIME type image/svg+xml. This is inconsistent with the allowlist implementation, which correctly applies both Regexp.quote and a \A anchor. Other content types containing regex metacharacters, such as application/xhtml+xml, are affected as well. As a result, any application that relies on content_type_denylist to block image/svg+xml, most commonly to prevent stored XSS, is silently unprotected. An attacker can upload an SVG file containing arbitrary JavaScript; if the application serves that SVG inline from its own origin, the script executes in the victim's browser, resulting in stored XSS. This issue has been fixed in versions 2.2.7 and 3.1.3.
4 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
The vulnerability stems from improper regex construction in CarrierWave's content_type_denylist implementation (lib/carrierwave/uploader/content_type_denylist.rb:57). When denylist entries are interpolated directly into a regex pattern without escaping via Regexp.quote or anchoring with \A, MIME types containing regex metacharacters are misinterpreted. For example, the intended denylist entry 'image/svg+xml' becomes the unanchored pattern /image\/svg+xml/, where the '+' quantifier matches one or more 'l' characters instead of a literal '+' sign, causing the pattern to never match the actual MIME type 'image/svg+xml'. The allowlist mechanism correctly applies both Regexp.quote and anchoring, highlighting the inconsistency. Any MIME type with regex special characters—including application/xhtml+xml, application/vnd.openxmlformats-officedocument.wordprocessingml.document, and others—suffers the same flaw. This results in silently ineffective filtering, not an error condition that would alert developers.
Business impact
Organizations relying on CarrierWave's content_type_denylist to enforce upload security policies face silent bypass of those controls. The primary risk is stored XSS via SVG uploads, which can lead to session hijacking, credential theft, malware distribution, or unauthorized actions performed on behalf of compromised users. For SaaS platforms or multi-tenant applications, a single malicious upload can affect all users who view the content. Incident response and remediation may require identifying and removing previously uploaded malicious files and notifying affected users. The silent nature of the failure—no warnings or exceptions are raised—means many deployments may already be compromised without detection.
Affected systems
CarrierWave versions prior to 2.2.7 (in the 2.2.x line) and prior to 3.1.3 (in the 3.x line) are vulnerable. Any Ruby application using CarrierWave with a configured content_type_denylist is at risk, particularly those that rely on this mechanism to block SVG or other MIME types with regex metacharacters. Applications that serve uploaded files inline from their own origin (rather than as attachments or from a separate domain) face the highest risk of XSS impact.
Exploitability
Exploitation requires no special privileges or authentication (if the application permits anonymous uploads) and minimal technical sophistication—an attacker simply uploads a .svg file containing malicious JavaScript. The success of the attack depends on two conditions: (1) the application must use content_type_denylist to block the file type, and (2) the application must serve the SVG inline from its own origin (not as an attachment download or from a CDN). User interaction is required for the XSS payload to execute (the victim must view a page serving the malicious SVG). The attack succeeds silently, with no indication to developers that the filter has failed.
Remediation
Upgrade CarrierWave to version 2.2.7 or later (if on the 2.2.x branch) or version 3.1.3 or later (if on the 3.x branch). These versions correct the regex construction to properly escape metacharacters and anchor patterns, ensuring denylist entries function as intended. As a defense-in-depth measure, applications should also enforce Content-Security-Policy headers to restrict script execution, serve uploaded content from a separate domain to prevent same-origin XSS, or validate file content (magic bytes) in addition to MIME-type checks.
Patch guidance
Verify the exact version of CarrierWave currently in use by checking your Gemfile.lock or running 'bundle show carrierwave'. Upgrade via bundler by updating your Gemfile to specify carrierwave >= 2.2.7 (for 2.2.x users) or >= 3.1.3 (for 3.x users), then run 'bundle update carrierwave'. Test the upgrade in a staging environment to confirm compatibility with your application's upload workflows and any custom carrierwave configurations. Consult the vendor advisory for any breaking changes or migration notes between your current version and the patched version.
Detection guidance
Review application logs for SVG or MIME-type uploads that should have been blocked by your content_type_denylist configuration. Inspect the public/uploaded-files directory (or equivalent storage) for any .svg files that were not explicitly allowed. If your application logs MIME types of rejected uploads, check for patterns suggesting attackers tested the denylist (e.g., repeated image/svg+xml uploads). Implement or enhance logging to record the MIME type and filename of all uploaded files, including those rejected. Consider scanning previously uploaded SVG files for embedded JavaScript or suspicious script tags.
Why prioritize this
While the CVSS score of 4.7 is moderate, the severity is significantly amplified by the silent failure mode and the prevalence of stored XSS as a high-impact attack vector. Organizations using CarrierWave should prioritize this patch if they (1) use content_type_denylist to block SVG or other risky MIME types, and (2) serve uploaded files inline from their own origin. Those with strict content-security-policy headers or separate-domain serving of uploads face lower practical risk but should still upgrade. The fix is low-complexity and low-risk, making it suitable for rapid rollout.
Risk score, explained
CVSS 4.7 (MEDIUM) reflects a network-accessible vulnerability with low attack complexity and low privileges required, but the impact is limited to confidentiality (C:L) and user interaction is required (UI:R). However, the silent bypass of security controls and the prevalence of stored XSS as a path to account compromise justify close attention. The true business risk depends on your specific deployment model (inline vs. attachment serving) and security posture (CSP headers, domain isolation).
Frequently asked questions
If I use a content_type_denylist in my CarrierWave configuration, am I definitely vulnerable?
Not necessarily. You are vulnerable only if (1) your denylist includes MIME types with regex metacharacters (e.g., image/svg+xml, application/xhtml+xml) and (2) your application serves uploaded files inline from the same origin. If you serve uploads as downloadable attachments, from a separate domain, or with strict Content-Security-Policy headers that prevent inline script execution, the practical risk is reduced. However, upgrading is still recommended to ensure the denylist functions as intended.
What MIME types are affected by this bug?
Any MIME type containing regex metacharacters is affected. Common examples include image/svg+xml, application/xhtml+xml, and various OOXML types (e.g., application/vnd.openxmlformats-officedocument.wordprocessingml.document). The + character is the most common culprit. To audit your denylist, review your CarrierWave configuration and check for entries with +, *, ., ?, [, ], (, ), {, }, ^, $, |, or \ characters.
Do I need to do anything other than upgrade CarrierWave?
Upgrading is the primary fix. As defense-in-depth, implement or strengthen Content-Security-Policy headers to prevent inline script execution, consider serving uploads from a separate domain or subdomain, and validate file content by checking magic bytes in addition to MIME types. If you suspect malicious SVG files were uploaded before patching, scan and remove them.
Does the allowlist feature have the same problem?
No. The content_type_allowlist implementation correctly applies Regexp.quote and anchoring, so it does not suffer from this bug. The vulnerability is specific to the denylist path.
This analysis is provided for informational purposes to support vulnerability assessment and patch prioritization. It does not constitute legal or professional security advice. Organizations should verify all vendor advisories, patch versions, and compatibility testing in their own environment before deploying updates. The presence of a vulnerability in your infrastructure should be confirmed through your own vulnerability scanning and asset inventory tools. SEC.co makes no warranty regarding the accuracy or completeness of this information. Source: NVD (public-domain), retrieved 2026-07-26. Analysis generated by SEC.co (claude-haiku-4-5).
Affected vendors
Related vulnerabilities
- CVE-2016-20070MEDIUMPrivilege Escalation & Stored XSS in WordPress Booking Calendar Contact Form 1.0.23
- CVE-2018-25384MEDIUMStored XSS in Wikidforum 2.20 Allows Authenticated Attackers to Inject Malicious Scripts
- CVE-2019-25731MEDIUMStored XSS in Zuz Music 2.1 Contact Form
- CVE-2019-25737MEDIUMStored XSS in Live Chat Unlimited 2.8.3 – Admin Session Compromise
- CVE-2019-25739MEDIUMGigToDo 1.3 Stored XSS Vulnerability in Proposal Descriptions
- CVE-2019-25742MEDIUMStored XSS in Zoner Real Estate WordPress Theme 4.1.1 – Admin Account Compromise Risk
- CVE-2019-25743MEDIUMWordPress Soliloquy Lite 2.5.6 Stored XSS Vulnerability
- CVE-2019-25744MEDIUMWordPress Popup Builder 3.49 Stored XSS Vulnerability – Exploit Prevention & Patch Guide