HighGHSA-cf3w-g86h-35x4CVE-2021-21305

Code Injection vulnerability in CarrierWave::RMagick

Published 8 Feb 2021 · Updated 8 Jul 2026

Is your project on an affected carrierwave?

Private repo? Upload its lockfile instead, or connect GitHub to check every repo.

Look after several Rails or Ruby apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

Affected packages

carrierwaveRubyGems
Affected
<1.3.2
Fixed in
1.3.2
Update to the fixed version for your release line, for example:bundle update --conservative carrierwave # Gemfile: '>= 1.3.2'
carrierwaveRubyGems
Affected
>=2.0.0 <2.1.1
Fixed in
2.1.1
Update to the fixed version for your release line, for example:bundle update --conservative carrierwave # Gemfile: '>= 2.1.1'

Details

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:

  • Open an issue in CarrierWave repo
  • Email me at [mit.shibuya@gmail.com](mailto:mit.shibuya@gmail.com)

Is GHSA-cf3w-g86h-35x4 in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected carrierwave, and gives you the command that fixes it.

More advisories for carrierwave

  • MediumCVE-2026-44587CarrierWave has a denylisted_content_type bypass via Unescaped Regex Metacharacters · 27 May 2026
  • MediumCVE-2024-29034CarrierWave content-Type allowlist bypass vulnerability which possibly leads to XSS remained · 25 Mar 2024
  • MediumCVE-2023-49090CarrierWave Content-Type allowlist bypass vulnerability, possibly leading to XSS · 29 Nov 2023
  • MediumCVE-2021-21288Server-side request forgery in CarrierWave · 8 Feb 2021
carrierwave security overview

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.