Skip to main content

CVE-2021-21305 — Code Injection vulnerability in carrierwave

HIGH

Code Injection vulnerability in CarrierWave::RMagick

Published February 8, 2021Updated July 8, 2026Source: OSV

What Should I Do?

Low-to-Moderate Risk

Exploitation probability is 13.21% in 30 days. Address in your next planned sprint.

Does your project use an affected carrierwave version?

Paste your Gemfile.lock to check it for CVE-2021-21305 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.

Check my Gemfile.lock

Summary

Impact

CarrierWave::RMagick has a Code Injection vulnerability. Its #manipulate! method inappropriately evals the content of mutation option(:read/:write), allowing attackers to craft a string that can be executed as a Ruby code. If an application developer supplies untrusted inputs to the option, it will lead to remote code execution(RCE).

(But supplying untrusted input to the option itself is dangerous even in absence of this vulnerability, since is prone to DoS vulnerability - attackers can try to consume massive amounts of memory by resizing to a very large dimension)

Proof of Concept

class MyUploader < CarrierWave::Uploader::Base
  include CarrierWave::RMagick
end

MyUploader.new.manipulate!({ read: { density: "1 }; p 'Hacked'; {" }}) # => shows "Hacked"

Patches

Upgrade to 2.1.1 or 1.3.2.

Workarounds

Stop supplying untrusted input to #manipulate!'s mutation option.

References

Code Injection Software Attack

For more information

If you have any questions or comments about this advisory:

Advisory Timeline

  • First published February 8, 2021 (2117 days ago).
  • Last revised July 8, 2026 — 1975 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

Bundler
Update carrierwave to 1.3.2 or later
gem install carrierwave -v 1.3.2
Bundler
Update carrierwave to 2.1.1 or later
gem install carrierwave -v 2.1.1

After upgrading, scan your dependencies again to confirm the vulnerability is resolved.

Affected Packages (2)

Affects 1 ecosystem: RubyGems (1).

PackageFixed In
carrierwave RubyGems · Affected: 0.1, 0.10.0, 0.11.0, 0.11.1 (+51 more)1.3.2
carrierwave RubyGems · Affected: 2.0.0, 2.0.1, 2.0.2, 2.1.02.1.1

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 7.4 score means for each attack dimension.

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

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:L

Frequently Asked Questions

What is CVE-2021-21305?
Code Injection vulnerability in CarrierWave::RMagick. This vulnerability has been assigned a severity rating of HIGH (CVSS score: 7.4/10).
How do I check if my project is affected by CVE-2021-21305?
CVE-2021-21305 affects carrierwave. It has a 13.2% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2021-21305 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
7.4

Significant impact if exploited, or exploitable with modest effort.

EPSS Score (30-day exploit probability)
13.21%
EPSS percentile: 97.1

This places it in the top 5% of EPSS-scored vulnerabilities — 97.1% of tracked vulnerabilities score at or below it, so it is far more likely to be exploited than nearly all other tracked vulnerabilities.

Also Known As

GHSA-cf3w-g86h-35x4

Related CVEs

  • CVE-2026-126366
    HIGH

    msgpack-ruby JRuby decoder makes uncapped header-count allocations; a 5-byte message forces multi-GiB OOM

  • CVE-2026-126081
    HIGH

    Action Pack: Possible Strong Parameters Bypass in Parameters#each_key

  • CVE-2026-44587
    MEDIUM

    CarrierWave has a denylisted_content_type bypass via Unescaped Regex Metacharacters

  • CVE-2023-49090
    MEDIUM

    CarrierWave Content-Type allowlist bypass vulnerability, possibly leading to XSS

  • CVE-2024-29034
    MEDIUM

    CarrierWave content-Type allowlist bypass vulnerability which possibly leads to XSS remained

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my Gemfile.lock