Code Injection vulnerability in CarrierWave::RMagick
Published 8 Feb 2021 · Updated 8 Jul 2026
Is your project on an affected carrierwave?
Look after several Rails or Ruby apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected packages
- Affected
- <1.3.2
- Fixed in
- 1.3.2
bundle update --conservative carrierwave # Gemfile: '>= 1.3.2'- Affected
- >=2.0.0 <2.1.1
- Fixed in
- 2.1.1
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
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
References
- Linkgithub.com/carrierwaveuploader/carrierwave/security/advisories/GHSA-cf3w-g86h-35x4
- Advisorynvd.nist.gov/vuln/detail/CVE-2021-21305
- Linkgithub.com/carrierwaveuploader/carrierwave/commit/387116f5c72efa42bc3938d946b4c8d2f22181b7
- Packagegithub.com/carrierwaveuploader/carrierwave
- Linkgithub.com/carrierwaveuploader/carrierwave/blob/master/CHANGELOG.md#132---2021-02-08
- Linkgithub.com/carrierwaveuploader/carrierwave/blob/master/CHANGELOG.md#211---2021-02-08
- Linkgithub.com/rubysec/ruby-advisory-db/blob/master/gems/carrierwave/CVE-2021-21305.yml
- Linkrubygems.org/gems/carrierwave
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.