CVE-2021-21305
JSON

7.4high

Code Injection vulnerability in CarrierWave

Severity
7.4high CVSS:3.1 by GitHub_M
Exploit likelihood
13.2% (higher than 96% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-cf3w-g86h-35x4

Description

CarrierWave is an open-source RubyGem which provides a simple and flexible way to upload files from Ruby applications. In CarrierWave before versions 1.3.2 and 2.1.1, there is a code injection vulnerability. The "#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). This is fixed in versions 1.3.2 and 2.1.1.

Affected

Product or packageVersionsReported by
carrierwaveuploader carrierwave< 1.3.2, >= 2.0.0, < 2.1.1CVE List
carrierwave (RubyGems)before 1.3.2, from 2.0.0 before 2.1.1GitHub Advisory Database
carrierwave_project carrierwavebefore 1.3.2, from 2.0.1 before 2.1.1NVD

All scores

GitHub_M7.4high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:L
GitHub7.4high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:L
NVD8.8high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
NVD7.5high CVSS:2.0AV:N/AC:L/Au:N/C:P/I:P/A:P

Classification

What each source says

CVE List

CarrierWave is an open-source RubyGem which provides a simple and flexible way to upload files from Ruby applications. In CarrierWave before versions 1.3.2 and 2.1.1, there is a code injection vulnerability. The "#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). This is fixed in versions 1.3.2 and 2.1.1.

GitHub Advisory Database
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:

NVD (es)

CarrierWave es un RubyGem de código abierto que proporciona una forma simple y flexible de cargar archivos desde aplicaciones de Ruby.&#xa0;En CarrierWave versiones anteriores a 1.3.2 y 2.1.1, se presenta una vulnerabilidad de inyección de código.&#xa0;El método "#manipulate!" evalúa inapropiadamente el contenido de la opción de mutación option(:read/:write), lo que permite a atacantes crear una cadena que se pueda ejecutar como código de Ruby.&#xa0;Si un desarrollador de aplicaciones proporciona entradas que no son de confianza para la opción, conllevará a una ejecución de código remota (RCE).&#xa0;Esto se corrigió en las versiones 1.3.2 y 2.1.1

References

Sources

SourceRecordLicence
CVE ListCVE-2021-21305 changed 2024-08-03CVE Terms of Use
GitHub Advisory DatabaseGHSA-cf3w-g86h-35x4 changed 2026-07-08CC-BY-4.0
NVDCVE-2021-21305 changed 2026-06-17Public domain