CVE-2022-23516: Loofah Uncontrolled Recursion Vulnerability
HIGHCVE-2022-23516 is a HIGH (CVSS 7.5) uncontrolled recursion vulnerability (CWE-674: Uncontrolled Recursion) affecting Loofah libraries in the RubyGems ecosystem. The issue involves uncontrolled recursion in loofah. Remediation is available by upgrading affected packages to version 2.19.1.
CVE-2022-23516 at a Glance
Security Impact
CVSS: 7.5
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:N/I:N/A:H).
How to Fix CVE-2022-23516
To remediate this vulnerability, upgrade all affected Loofah 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 loofah to 2.19.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for loofah
How to Check if You Are Affected
To determine whether your application is affected by CVE-2022-23516, inspect your project dependencies for Loofah:
inspect dependencies for loofah
Analyze the terminal output to locate any version of Loofah in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.19.1), 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-674: Uncontrolled Recursion, where the product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack. In Loofah, 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-23516 Affected Loofah Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
loofah
|
RubyGems |
≥ 2.2.0
< 2.19.1
|
2.19.1
|
References
Frequently Asked Questions
What is CVE-2022-23516?
Which Loofah versions are affected?
What version fixes CVE-2022-23516?
Is loofah affected?
What is the CVSS score of CVE-2022-23516?
What CWE is associated with CVE-2022-23516?
How can I check RubyGems dependencies for CVE-2022-23516?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-3x8r-x6xp-q4vm",
"modified" : "2025-11-04T16:41:06Z",
"published" : "2022-12-13T17:40:50Z",
"aliases" : [ "CVE-2022-23516" ],
"summary" : "Uncontrolled Recursion in Loofah",
"details" : "## Summary\n\nLoofah `>= 2.2.0, < 2.19.1` uses recursion for sanitizing `CDATA` sections, making it susceptible to stack exhaustion and raising a `SystemStackError` exception. This may lead to a denial of service through CPU resource consumption.\n\n\n## Mitigation\n\nUpgrade to Loofah `>= 2.19.1`.\n\nUsers who are unable to upgrade may be able to mitigate this vulnerability by limiting the length of the strings that are sanitized.\n\n\n## Severity\n\nThe Loofah maintainers have evaluated this as [High Severity 7.5 (CVSS3.1)](https://www.first.org/cvss/calculator/3.1#CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).\n\n\n## References\n\n- [CWE - CWE-674: Uncontrolled Recursion (4.9)](https://cwe.mitre.org/data/definitions/674.html)",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "RubyGems",
"name" : "loofah"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.2.0"
}, {
"fixed" : "2.19.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/flavorjones/loofah/security/advisories/GHSA-3x8r-x6xp-q4vm"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-23516"
}, {
"type" : "WEB",
"url" : "https://github.com/flavorjones/loofah/commit/86f7f6364491b0099d215db858ecdc0c89ded040"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/flavorjones/loofah"
}, {
"type" : "WEB",
"url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/loofah/CVE-2022-23516.yml"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2023/09/msg00011.html"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2024/09/msg00044.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-674" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-12-13T17:40:50Z",
"nvd_published_at" : "2022-12-14T14:15:00Z"
}
}