Code Injection vulnerability in CarrierWave::RMagick

Description

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 [email protected]

Basic information

Type
reviewed
Severity
high
Advisory on GitHub
Open advisory ↗
Repository advisory
Open repository advisory ↗
Source code
Browse source ↗
Published (advisory)
2021-02-08 19:16:39 UTC
Updated
2023-05-04 19:34:57 UTC
GitHub reviewed
2021-02-08 18:51:46 UTC
NVD published
2021-02-08

EPSS Score

Score Percentile
2.82% 85.65%

CVSS Scores

Base score Version Severity Vector
7.4 3.1
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:L Click to expand
Attack vector (AV:N)
Could be attacked over the internet or any normal routed network—not just someone sitting at the machine.
Attack complexity (AC:L)
Once they can reach the bug, pulling it off is straightforward—no weird race conditions or rare setup.
Privileges required (PR:L)
A normal user session is enough; they don’t have to be admin.
User interaction (UI:N)
Nobody has to click “OK” or open a trap file; it can work without a victim helping.
Scope (S:C)
Breaking this can reach past the original component and bite other resources—bigger blast radius.
Confidentiality (C:L)
Some sensitive info could get out, but not a total data dump.
Integrity (I:L)
Attackers could change some data, but it’s limited—not everything goes.
Availability (A:L)
Might cause slowdowns, glitches, or partial disruption—not a full brick.

Identifiers

CWEs

CWE id Name
CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
CWE-94 Improper Control of Generation of Code ('Code Injection')

Credits

  • wonda-tea-coffee (analyst)

Affected packages (2)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
rubygems carrierwave < 1.3.2 1.3.2
rubygems carrierwave >= 2.0.0, < 2.1.1 2.1.1

References

cvelogic Threat Intelligence