CVE-2022-21831 — Possible code injection vulnerability in...
Possible code injection vulnerability in Rails / Active Storage
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (3.17%). Schedule for your next planned update.
Does your project use an affected activestorage version?
Paste your Gemfile.lock to check it for CVE-2022-21831 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
The Active Storage module of Rails starting with version 5.2.0 is possibly vulnerable to code injection. This issue was patched in versions 5.2.6.3, 6.0.4.7, 6.1.4.7, and 7.0.2.3. To work around this issue, applications should implement a strict allow-list on accepted transformation methods or arguments. Additionally, a strict ImageMagick security policy will help mitigate this issue.
Advisory Timeline
- First published March 8, 2022 (1724 days ago).
- Last revised March 13, 2026 — 1466 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
gem install activestorage -v 5.2.6.3
gem install activestorage -v 6.0.4.7
gem install activestorage -v 7.0.2.3
gem install activestorage -v 6.1.4.7
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (4)
Affects 1 ecosystem: RubyGems (1).
| Package | Fixed In |
|---|---|
| activestorage RubyGems · Affected: 5.2.0, 5.2.1, 5.2.1.1, 5.2.1.rc1 (+17 more) | 5.2.6.3 |
| activestorage RubyGems · Affected: 6.0.0, 6.0.1, 6.0.1.rc1, 6.0.2 (+20 more) | 6.0.4.7 |
| activestorage RubyGems · Affected: 7.0.0, 7.0.1, 7.0.2, 7.0.2.1 (+1 more) | 7.0.2.3 |
| activestorage RubyGems · Affected: 6.1.0, 6.1.1, 6.1.2, 6.1.2.1 (+10 more) | 6.1.4.7 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-94Code InjectionMITRE
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 9.8 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
References
- https://nvd.nist.gov/vuln/detail/CVE-2022-21831ADVISORY
- https://github.com/rails/rails/commit/0a72f7d670e9aa77a0bb8584cb1411ddabb7546eWEB
- https://github.com/advisories/GHSA-w749-p3v6-hccqADVISORY
- https://github.com/rails/railsPACKAGE
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/activestorage/CVE-2022-21831.ymlWEB
- https://groups.google.com/g/rubyonrails-security/c/n-p-W1yxatIWEB
- https://lists.debian.org/debian-lts-announce/2022/09/msg00002.htmlWEB
- https://rubysec.com/advisories/CVE-2022-21831WEB
- https://security.netapp.com/advisory/ntap-20221118-0001WEB
- https://www.debian.org/security/2023/dsa-5372WEB
Frequently Asked Questions
- What is CVE-2022-21831?
- Possible code injection vulnerability in Rails / Active Storage. This vulnerability has been assigned a severity rating of CRITICAL (CVSS score: 9.8/10).
- How do I check if my project is affected by CVE-2022-21831?
- CVE-2022-21831 affects activestorage. It has a 3.2% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2022-21831 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Maximum impact if exploited, often with little effort or access required.
This places it in the top quartile of EPSS-scored vulnerabilities — 88.8% of tracked vulnerabilities score at or below it, so it is more likely to be exploited than most of the tracked corpus.
Also Known As
Related CVEs
- CVE-2026-122006CRITICAL
Active Storage: Possible arbitrary file write and read in image analysis
- CVE-2026-33195HIGH
Rails Active Storage has possible Path Traversal in DiskService
- CVE-2026-126084MEDIUM
Active Storage: Unsigned Content-Type in GCS direct uploads with cache_control
- CVE-2026-126071MEDIUM
Active Storage: Possible DoS vulnerability in Active Storage proxy mode via storage errors during streaming
- CVE-2026-33202MEDIUM
Rails Active Storage has possible glob injection in its DiskService
- CVE-2018-16477MEDIUM
Exposure of Sensitive Information to an Unauthorized Actor in activestorage
- CVE-2024-26144MEDIUM
Rails has possible Sensitive Session Information Leak in Active Storage
- CVE-2026-126085MEDIUM
Active Storage: Possible circumvention of file size limits in Active Storage direct uploads to Google Cloud Storage