CVE-2022-21831: Code Injection

Published Mar 8, 2022
·
Updated

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.

Other sources

A code injection vulnerability exists in the Active Storage >= v5.2.0 that could allow an attacker to execute code via imageprocessing arguments.

— NVD

Affected Software

14 affected componentsFixes available
debian/rails<=2:5.2.2.1+dfsg-1, <=2:6.1.4.6+dfsg-2, <=2:6.0.3.7+dfsg-2, <=2:5.2.2.1+dfsg-1+deb10u3
rubyonrails Active Storage Ruby>=5.2.0<5.2.6.3
rubyonrails Active Storage Ruby>=6.0.0<6.0.4.7
rubyonrails Active Storage Ruby>=6.1.0<6.1.4.7
rubyonrails Active Storage Ruby>=7.0.0<7.0.2.3
Debian Debian Linux=10.0
rubygems/activestorage>=7.0.0<=7.0.2.2
7.0.2.3
rubygems/activestorage>=6.1.0<=6.1.4.6
6.1.4.7
rubygems/activestorage>=6.0.0<=6.0.4.6
6.0.4.7
rubygems/activestorage>=5.2.0<=5.2.6.2
5.2.6.3
debian/rails<2:6.1.4.7+dfsg-1
2:6.1.4.7+dfsg-1
debian/rails<2:6.1.4.7+dfsg-1
2:6.1.4.7+dfsg-1
debian/rails<2:6.1.4.7+dfsg-1
2:6.1.4.7+dfsg-1
debian/rails
2:6.1.7.10+dfsg-1~deb12u22:6.1.7.10+dfsg-1~deb12u32:7.2.2.2+dfsg-2~deb13u12:7.2.2.2+dfsg-2~deb13u22:7.2.4+dfsg-2

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade rubygems/activestorage to a version that resolves this vulnerability.

    Fixed in 7.0.2.3
  2. Upgrade

    Upgrade rubygems/activestorage to a version that resolves this vulnerability.

    Fixed in 6.1.4.7
  3. Upgrade

    Upgrade rubygems/activestorage to a version that resolves this vulnerability.

    Fixed in 6.0.4.7
  4. Upgrade

    Upgrade rubygems/activestorage to a version that resolves this vulnerability.

    Fixed in 5.2.6.3
  5. Upgrade

    Upgrade debian/rails to a version that resolves this vulnerability.

    Fixed in 2:6.1.4.7+dfsg-1
  6. Upgrade

    Upgrade debian/rails to a version that resolves this vulnerability.

    Fixed in 2:6.1.7.10+dfsg-1~deb12u2Fixed in 2:6.1.7.10+dfsg-1~deb12u3Fixed in 2:7.2.2.2+dfsg-2~deb13u1Fixed in 2:7.2.2.2+dfsg-2~deb13u2Fixed in 2:7.2.4+dfsg-2
  7. Upgrade

    Upgrade Rails Active Storage to a version that resolves this vulnerability.

    Fixed in 5.2.6.3
  8. Upgrade

    Upgrade Rails Active Storage to a version that resolves this vulnerability.

    Fixed in 6.0.4.7
  9. Upgrade

    Upgrade Rails Active Storage to a version that resolves this vulnerability.

    Fixed in 6.1.4.7
  10. Upgrade

    Upgrade Rails Active Storage to a version that resolves this vulnerability.

    Fixed in 7.0.2.3
  11. Configuration

    Implement a strict allow-list for accepted transformation methods or arguments.

    Application image transformation handling accepted transformation methods or arguments = strict allow-list
  12. Compensating control

    Implement a strict ImageMagick security policy to mitigate the code injection issue.

Event History

Apr 5, 2020
Exploit Published
via GitHub·08:17 AM
Mar 8, 2022
Advisory Published
via GitHub·09:25 PM
Data Sourced
via GitHub·09:25 PM
DescriptionSeverityWeaknessAffected Software
May 26, 2022
CVE Published
via MITRE·12:00 AM
Data Sourced
via MITRE·12:00 AM
DescriptionWeakness
Data Sourced
via NVD·05:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Data Sourced
via OSV·05:15 PM
DescriptionAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Peer vulnerabilities

Found alongside the following vulnerabilities.

Frequently Asked Questions

1

What is the severity of CVE-2022-21831?

The severity of CVE-2022-21831 is critical with a CVSS score of 9.8.

2

Which versions of Rails are affected by CVE-2022-21831?

Versions 5.2.0 to 5.2.6.2, 6.0.0 to 6.0.4.6, 6.1.0 to 6.1.4.6, and 7.0.0 to 7.0.2.2 of Rails are affected by CVE-2022-21831.

3

How can I mitigate the code injection vulnerability in Active Storage?

To mitigate the code injection vulnerability in Active Storage, update to versions 5.2.6.3, 6.0.4.7, 6.1.4.7, or 7.0.2.3 of Rails.

4

Is there a workaround for CVE-2022-21831?

Implementing a strict allow-list on accepted transformation methods or arguments can serve as a workaround for CVE-2022-21831.

5

Where can I find more information about CVE-2022-21831?

More information about CVE-2022-21831 can be found at the following references: [NVD](https://nvd.nist.gov/vuln/detail/CVE-2022-21831), [Github Commit](https://github.com/rails/rails/commit/0a72f7d670e9aa77a0bb8584cb1411ddabb7546e), [Google Groups](https://groups.google.com/g/rubyonrails-security/c/n-p-W1yxatI).

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203