Skip to content

GHSA-486f-hjj9-9vhh CVE-2022-23514

Inefficient Regular Expression Complexity in Loofah

High RubyGems
Severity
7.5 / 10
High · CVSS 3.1
Exploit chance (EPSS)
1.83%
Chance of exploitation in the next 30 days. Higher than 78.86% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-1333 Inefficient Regular Expression Complexity
Fix
2.19.1
Upgrade loofah to this version or later

Description

Summary

Loofah < 2.19.1 contains an inefficient regular expression that is susceptible to excessive backtracking when attempting to sanitize certain SVG attributes. This may lead to a denial of service through CPU resource consumption.

Mitigation

Upgrade to Loofah >= 2.19.1.

Severity

The Loofah maintainers have evaluated this as High Severity 7.5 (CVSS3.1).

References

Credit

This vulnerability was responsibly reported by @ooooooo-q (https://github.com/ooooooo-q).

Affected versions

RubyGems

PackageVulnerableFixed in
loofah
< 2.19.1
2.19.1

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

loofah RubyGems → 2.19.1

bundler
bundle update loofah # Gemfile: gem "loofah", ">= 2.19.1"

Severity breakdown

CVSS 3.1 7.5

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High

Weakness

CWE-1333: Inefficient Regular Expression Complexity

The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.

How to prevent it
  • Architecture and Design: Use regular expressions that do not support backtracking, e.g. by removing nested quantifiers.
  • System Configuration: Set backtracking limits in the configuration of the regular expression implementation, such as PHP's pcre.backtrack_limit. Also consider limits on execution time for the process.
  • Implementation: Do not use regular expressions with untrusted input. If regular expressions must be used, avoid using backtracking in the expression.
  • Implementation: Limit the length of the input that the regular expression will process.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-5qhf-9phg-95m2
Loofah `allowed_uri?` does not detect `javascript:` URIs split by numeric character references without semicolons
Low Also affects loofah
GHSA-9wjq-cp2p-hrgf
Loofah: SVG `href` attribute bypasses local-reference restriction
Medium Also affects loofah
GHSA-8whx-365g-h9vv
Loofah `allowed_uri?` does not detect `javascript:` URIs split by named whitespace character references
Low Also affects loofah
GHSA-2j22-pr5w-6gq8
Loofah has improper detection of disallowed URIs via `allowed_uri?`
Low Also affects loofah
GHSA-46fp-8f5p-pf2m
Improper detection of disallowed URIs by Loofah `allowed_uri?`
Low Also affects loofah
GHSA-3x8r-x6xp-q4vm
Uncontrolled Recursion in Loofah
High Also affects loofah
GHSA-228g-948r-83gx
Improper neutralization of data URIs may allow XSS in Loofah
Medium Also affects loofah
GHSA-c3gv-9cxf-6f57
Loofah Allows Cross-site Scripting
Medium Also affects loofah
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor