CVE-2022-21831: Code Injection
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
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/railsto 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 - Upgrade
Upgrade
rubygems/activestorageto a version that resolves this vulnerability.Fixed in 7.0.2.3 - Upgrade
Upgrade
rubygems/activestorageto a version that resolves this vulnerability.Fixed in 6.1.4.7 - Upgrade
Upgrade
rubygems/activestorageto a version that resolves this vulnerability.Fixed in 6.0.4.7 - Upgrade
Upgrade
rubygems/activestorageto a version that resolves this vulnerability.Fixed in 5.2.6.3 - Upgrade
Upgrade
debian/railsto a version that resolves this vulnerability.Fixed in 2:5.2.2.1+dfsg-1+deb10u5 - Upgrade
Upgrade
debian/railsto a version that resolves this vulnerability.Fixed in 2:6.0.3.7+dfsg-2+deb11u2 - Upgrade
Upgrade
debian/railsto a version that resolves this vulnerability.Fixed in 2:6.1.7.3+dfsg-1 - Upgrade
Upgrade
debian/railsto a version that resolves this vulnerability.Fixed in 2:6.1.7.3+dfsg-2 - 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 - 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
Frequently Asked Questions
What is the severity of CVE-2022-21831?
The severity of CVE-2022-21831 is critical with a CVSS score of 9.8.
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.
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.
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.
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).