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 package | Versions | Reported by |
|---|---|---|
| carrierwaveuploader carrierwave | < 1.3.2, >= 2.0.0, < 2.1.1 | CVE List |
| carrierwave (RubyGems) | before 1.3.2, from 2.0.0 before 2.1.1 | GitHub Advisory Database |
| carrierwave_project carrierwave | before 1.3.2, from 2.0.1 before 2.1.1 | NVD |
All scores
| GitHub_M | 7.4high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:L |
| GitHub | 7.4high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:L |
| NVD | 8.8high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H |
| NVD | 7.5high CVSS:2.0 | AV: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
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
NVD (es)
CarrierWave es un RubyGem de código abierto que proporciona una forma simple y flexible de cargar archivos desde aplicaciones de Ruby. En CarrierWave versiones anteriores a 1.3.2 y 2.1.1, se presenta una vulnerabilidad de inyección de código. 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. 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). Esto se corrigió en las versiones 1.3.2 y 2.1.1
References
| https://github.com/carrierwaveuploader/carrierwave/blob/master/CHANGELOG.md#132---2021-02-08 | release-notes, third-party-advisory, web | |
| https://github.com/carrierwaveuploader/carrierwave/blob/master/CHANGELOG.md#211---2021-02-08 | release-notes, third-party-advisory, web | |
| https://github.com/carrierwaveuploader/carrierwave/security/advisories/GHSA-cf3w-g86h-35x4 | exploit, third-party-advisory, web | |
| https://rubygems.org/gems/carrierwave | product, third-party-advisory, web | |
| https://github.com/carrierwaveuploader/carrierwave/commit/387116f5c72efa42bc3938d946b4c8d2f22181b7 | patch, third-party-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2021-21305 | advisory | |
| https://github.com/carrierwaveuploader/carrierwave | package | |
| https://github.com/rubysec/ruby-advisory-db/blob/master/gems/carrierwave/CVE-2021-21305.yml | web | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-21305 changed 2024-08-03 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-cf3w-g86h-35x4 changed 2026-07-08 | CC-BY-4.0 |
| NVD | CVE-2021-21305 changed 2026-06-17 | Public domain |