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

11 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
debian/rails<=2:5.2.2.1+dfsg-1+deb10u3
2:5.2.2.1+dfsg-1+deb10u52:6.0.3.7+dfsg-2+deb11u22:6.1.7.3+dfsg-12:6.1.7.3+dfsg-2
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
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

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

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

    Fixed in 2:5.2.2.1+dfsg-1+deb10u5Fixed in 2:6.0.3.7+dfsg-2+deb11u2Fixed in 2:6.1.7.3+dfsg-1Fixed in 2:6.1.7.3+dfsg-2
  2. Upgrade

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

    Fixed in 7.0.2.3
  3. Upgrade

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

    Fixed in 6.1.4.7
  4. Upgrade

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

    Fixed in 6.0.4.7
  5. Upgrade

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

    Fixed in 5.2.6.3
  6. Upgrade

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

    Fixed in 2:5.2.2.1+dfsg-1+deb10u5
  7. Upgrade

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

    Fixed in 2:6.0.3.7+dfsg-2+deb11u2
  8. Upgrade

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

    Fixed in 2:6.1.7.3+dfsg-1
  9. Upgrade

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

    Fixed in 2:6.1.7.3+dfsg-2
  10. Configuration

    Implement a strict allow-list on accepted transformation methods or arguments in your application to prevent untrusted image_processing arguments from enabling code injection.

    Active Storage (Rails) accepted_transformation_methods / allowed image_processing arguments = strict allow-list
  11. Configuration

    Configure a strict ImageMagick security policy (e.g., policy.xml) to restrict potentially unsafe operations and mitigate exploitation via image processing.

    ImageMagick security policy (policy.xml) = strict security policy

Event History

Mar 8, 2022
Advisory Published
via GitHub·09:25 PM
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
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

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