Skip to main content

CVE-2022-21831 — Possible code injection vulnerability in...

CRITICAL

Possible code injection vulnerability in Rails / Active Storage

Published March 8, 2022Updated March 13, 2026Source: OSV

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.

Check my Gemfile.lock

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.

Bundler
Update activestorage to 5.2.6.3 or later
gem install activestorage -v 5.2.6.3
Bundler
Update activestorage to 6.0.4.7 or later
gem install activestorage -v 6.0.4.7
Bundler
Update activestorage to 7.0.2.3 or later
gem install activestorage -v 7.0.2.3
Bundler
Update activestorage to 6.1.4.7 or later
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).

PackageFixed 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.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 9.8 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

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

CVSS Score
9.8

Maximum impact if exploited, often with little effort or access required.

EPSS Score (30-day exploit probability)
3.17%
EPSS percentile: 88.8

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

GHSA-w749-p3v6-hccq

Related CVEs

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my Gemfile.lock