CVE-2022-21831: Activestorage Possible Code Injection Vulnerability Vulnerability
CRITICALCVE-2022-21831 is a CRITICAL (CVSS 9.8) possible code injection vulnerability vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Activestorage libraries in the RubyGems ecosystem. The issue involves possible code injection vulnerability in rails / active storage. Remediation is available by upgrading affected packages to version 5.2.6.3, 6.0.4.7, 6.1.4.7, 7.0.2.3.
CVE-2022-21831 at a Glance
Security Impact
CVSS: 9.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2022-21831
To remediate this vulnerability, upgrade all affected Activestorage dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade activestorage to 5.2.6.3
Upgrade activestorage to 6.0.4.7
Upgrade activestorage to 6.1.4.7
Upgrade activestorage to 7.0.2.3
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for activestorage
How to Check if You Are Affected
To determine whether your application is affected by CVE-2022-21831, inspect your project dependencies for Activestorage:
inspect dependencies for activestorage
Analyze the terminal output to locate any version of Activestorage in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.2.6.3), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Activestorage, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2022-21831 Affected Activestorage Versions
4 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
activestorage
|
RubyGems |
≥ 5.2.0
< 5.2.6.3
|
5.2.6.3
|
|
activestorage
|
RubyGems |
≥ 6.0.0
< 6.0.4.7
|
6.0.4.7
|
|
activestorage
|
RubyGems |
≥ 6.1.0
< 6.1.4.7
|
6.1.4.7
|
|
activestorage
|
RubyGems |
≥ 7.0.0
< 7.0.2.3
|
7.0.2.3
|
References
Frequently Asked Questions
What is CVE-2022-21831?
Which Activestorage versions are affected?
What version fixes CVE-2022-21831?
Is activestorage affected?
What is the CVSS score of CVE-2022-21831?
What CWE is associated with CVE-2022-21831?
How can I check RubyGems dependencies for CVE-2022-21831?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-w749-p3v6-hccq",
"modified" : "2022-06-21T15:59:23Z",
"published" : "2022-03-08T21:25:54Z",
"aliases" : [ "CVE-2022-21831" ],
"summary" : "Possible code injection vulnerability in Rails / Active Storage",
"details" : "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.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "RubyGems",
"name" : "activestorage"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "5.2.0"
}, {
"fixed" : "5.2.6.3"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 5.2.6.2"
}
}, {
"package" : {
"ecosystem" : "RubyGems",
"name" : "activestorage"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "6.0.0"
}, {
"fixed" : "6.0.4.7"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 6.0.4.6"
}
}, {
"package" : {
"ecosystem" : "RubyGems",
"name" : "activestorage"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "6.1.0"
}, {
"fixed" : "6.1.4.7"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 6.1.4.6"
}
}, {
"package" : {
"ecosystem" : "RubyGems",
"name" : "activestorage"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "7.0.0"
}, {
"fixed" : "7.0.2.3"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 7.0.2.2"
}
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-21831"
}, {
"type" : "WEB",
"url" : "https://github.com/rails/rails/commit/0a72f7d670e9aa77a0bb8584cb1411ddabb7546e"
}, {
"type" : "ADVISORY",
"url" : "https://github.com/advisories/GHSA-w749-p3v6-hccq"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/rails/rails"
}, {
"type" : "WEB",
"url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/activestorage/CVE-2022-21831.yml"
}, {
"type" : "WEB",
"url" : "https://groups.google.com/g/rubyonrails-security/c/n-p-W1yxatI"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2022/09/msg00002.html"
}, {
"type" : "WEB",
"url" : "https://rubysec.com/advisories/CVE-2022-21831"
}, {
"type" : "WEB",
"url" : "https://security.netapp.com/advisory/ntap-20221118-0001"
}, {
"type" : "WEB",
"url" : "https://www.debian.org/security/2023/dsa-5372"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-94" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2022-03-08T21:25:54Z",
"nvd_published_at" : "2022-05-26T17:15:00Z"
}
}