CVE-2022-21831
Critical · 9.8CVSS
9.8
EPSS
3.1%
Published
May 26, 2022
CISA due date
—
Cloudanix analysis
A flaw in how web applications handle uploaded images can let attackers run their own programs on the server without any login, potentially stealing data or taking over the system.
- Exploitation
- Remote Unauthenticated
- Attacker needs
- None
- Complexity
- Low
- Impact
- Remote Code Execution
- Component
- Web Framework
- Class
- RCE
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Remote attacker can inject and execute arbitrary code by supplying malicious arguments to the image_processing library through Active Storage uploads.
Why it matters to the business
Successful exploitation grants full control over the affected application server, enabling theft of sensitive data, deployment of persistent malware, or disruption of operations; the vulnerability has remained unpatched in listed distributions for over four years, increasing long-term exposure risk for dependent applications.
How an attack unfolds
An attacker crafts a malicious image upload request that includes specially formatted image_processing parameters; when the server processes the upload, the injected arguments are passed directly to the underlying image library, resulting in code execution within the application context.
How to fix it
Upgrade Active Storage to a version that sanitizes image_processing arguments; apply vendor-supplied patches or migrate away from the vulnerable component if no fixed package version is available; restrict or disable image processing features until patched.
How to confirm the fix worked
Review application dependencies for Active Storage versions >= 5.2.0, test upload endpoints with known-safe processing arguments, and confirm that malicious parameter injection no longer results in code execution.
Typical attack path
- Identify an endpoint accepting file uploads that uses Active Storage image processing
- Craft a request containing an image file accompanied by malicious image_processing arguments
- Submit the request to trigger server-side processing
- Achieve arbitrary code execution on the host
How to detect it
Inspect web server and application logs for image upload requests containing unusual or command-like values in processing parameters; correlate with process execution logs showing unexpected commands spawned during image handling.
- image_processing arguments containing shell metacharacters or system commands
- unexpected child processes spawned by the Rails application during upload handling
What your security team should do
- Prioritize patching or replacing Active Storage in all internet-facing applications
- Implement input validation and sandboxing around image processing calls
- Monitor dependency graphs for downstream usage of the affected gem
- Conduct targeted scans for unpatched Debian packages containing the vulnerable code
The record
A code injection vulnerability exists in the Active Storage >= v5.2.0 that could allow an attacker to execute code via image_processing arguments.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| RubyGems | activestorage | 5.2.0 | 5.2.6.3 |
| RubyGems | activestorage | 6.0.0 | 6.0.4.7 |
| RubyGems | activestorage | 6.1.0 | 6.1.4.7 |
| RubyGems | activestorage | 7.0.0 | 7.0.2.3 |
| Debian:10 | rails | 0 | 2:5.2.2.1+dfsg-1+deb10u4 |
| Debian:11 | rails | 0 | 2:6.0.3.7+dfsg-2+deb11u1 |
| Debian:12 | rails | 0 | 2:6.1.4.7+dfsg-1 |
| Debian:13 | rails | 0 | 2:6.1.4.7+dfsg-1 |
| Ubuntu:20.04:LTS | rails | 0 | No fix |
| Ubuntu:22.04:LTS | rails | 0 | No fix |
| Ubuntu:24.04:LTS | rails | 0 | No fix |
| Ubuntu:24.10 | rails | 0 | No fix |
| Ubuntu:25.04 | rails | 0 | No fix |
| Ubuntu:25.10 | rails | 0 | No fix |
| Ubuntu:Pro:16.04:LTS | rails | 0 | No fix |
| Ubuntu:Pro:18.04:LTS | rails | 0 | No fix |
| Ubuntu:Pro:20.04:LTS | rails | 0 | No fix |
| Ubuntu:Pro:22.04:LTS | rails | 0 | No fix |
| gem | activestorage | 5.2.0 | 5.2.6.3 |
| gem | activestorage | 6.0.0 | 6.0.4.7 |
| gem | activestorage | 6.1.0 | 6.1.4.7 |
| gem | activestorage | 7.0.0 | 7.0.2.3 |
| openSUSE:Tumbleweed | ruby3.2-rubygem-activestorage-7.0 | 0 | 7.0.4.3-1.1 |
| openSUSE:Tumbleweed | rubygem-activestorage-7.0 | 0 | 7.0.2.3-1.1 |
| openSUSE:Tumbleweed | rubygem-activestorage-7.0 | 0 | 7.0.8.4-1.1 |
| openSUSE:Tumbleweed | rubygem-activestorage-7.0 | 0 | 7.0.8.6-1.3 |
Related vulnerabilities
- CVE-2025-24293 # Active Storage allowed transformation methods potentially unsafe Active Storage… Also affects activestorage
- CVE-2022-22577 An XSS Vulnerability in Action Pack >= 5.2.0 and < 5.2.0 that could allow an attacker to… Also affects rails
- CVE-2022-27777 A XSS Vulnerability in Action View tag helpers >= 5.2.0 and < 5.2.0 which would allow an… Also affects rails
- CVE-2020-8166 A CSRF forgery vulnerability exists in rails < 5.2.5, rails < 6.0.4 that makes it… Also affects rails
- CVE-2013-0156 active_support/core_ext/hash/conversions.rb in Ruby on Rails before 2.3.15, 3.0.x before… Also affects rails
- CVE-2025-55193 Active Record connects classes to relational database tables. Also affects rails
- CVE-2023-28120 There is a vulnerability in ActiveSupport if the new bytesplice method is called on a… Also affects rails
- CVE-2023-23913 There is a potential DOM based cross-site scripting issue in rails-ujs which leverages… Also affects rails