CWE-1333
AllowedInefficient Regular Expression Complexity
Abstraction: Base · Status: Draft
The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.
1000 vulnerabilities reference this CWE, most recent first.
GHSA-XFFM-G5W8-QVG7
Vulnerability from github – Published: 2025-07-18 20:39 – Updated: 2025-07-28 17:34Summary
The ConfigCommentParser#parseJSONLikeConfig API is vulnerable to a Regular Expression Denial of Service (ReDoS) attack in its only argument.
Details
The regular expression at packages/plugin-kit/src/config-comment-parser.js:158 is vulnerable to a quadratic runtime attack because the grouped expression is not anchored. This can be solved by prepending the regular expression with [^-a-zA-Z0-9/].
PoC
const { ConfigCommentParser } = require("@eslint/plugin-kit");
const str = `${"A".repeat(1000000)}?: 1 B: 2`;
console.log("start")
var parser = new ConfigCommentParser();
console.log(parser.parseJSONLikeConfig(str));
console.log("end")
// run `npm i @eslint/plugin-kit@0.3.3` and `node attack.js`
// then the program will stuck forever with high CPU usage
Impact
This is a Regular Expression Denial of Service attack which may lead to blocking execution and high CPU usage.
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "@eslint/plugin-kit"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.3.4"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [],
"database_specific": {
"cwe_ids": [
"CWE-1333"
],
"github_reviewed": true,
"github_reviewed_at": "2025-07-18T20:39:12Z",
"nvd_published_at": null,
"severity": "LOW"
},
"details": "### Summary\n\nThe `ConfigCommentParser#parseJSONLikeConfig` API is vulnerable to a Regular Expression Denial of Service (ReDoS) attack in its only argument.\n\n### Details\n\nThe regular expression at [packages/plugin-kit/src/config-comment-parser.js:158](https://github.com/eslint/rewrite/blob/bd4bf23c59f0e4886df671cdebd5abaeb1e0d916/packages/plugin-kit/src/config-comment-parser.js#L158) is vulnerable to a quadratic runtime attack because the grouped expression is not anchored. This can be solved by prepending the regular expression with `[^-a-zA-Z0-9/]`.\n\n### PoC\n\n```javascript\nconst { ConfigCommentParser } = require(\"@eslint/plugin-kit\");\n\nconst str = `${\"A\".repeat(1000000)}?: 1 B: 2`;\n\nconsole.log(\"start\")\nvar parser = new ConfigCommentParser();\nconsole.log(parser.parseJSONLikeConfig(str));\nconsole.log(\"end\")\n\n// run `npm i @eslint/plugin-kit@0.3.3` and `node attack.js`\n// then the program will stuck forever with high CPU usage\n```\n\n### Impact\n\nThis is a Regular Expression Denial of Service attack which may lead to blocking execution and high CPU usage.",
"id": "GHSA-xffm-g5w8-qvg7",
"modified": "2025-07-28T17:34:44Z",
"published": "2025-07-18T20:39:12Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/eslint/rewrite/security/advisories/GHSA-xffm-g5w8-qvg7"
},
{
"type": "WEB",
"url": "https://github.com/eslint/rewrite/commit/b283f64099ad6c6b5043387c091691d21b387805"
},
{
"type": "PACKAGE",
"url": "https://github.com/eslint/rewrite"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N",
"type": "CVSS_V4"
}
],
"summary": "@eslint/plugin-kit is vulnerable to Regular Expression Denial of Service attacks through ConfigCommentParser"
}
GHSA-XGH8-JP6Q-P5X8
Vulnerability from github – Published: 2026-10-21 20:45 – Updated: 2026-10-21 20:45============================================================================
ReDoS in XbmImagePlugin: 512-byte file stalls Image.open() for minutes
Location: src/PIL/XbmImagePlugin.py:58 in XbmImageFile._open()
Commit: a707c6b21c313880d0771e54965d142dd42358b6
============================================================================
A crafted 512-byte file makes Pillow's Image.open() spend about six minutes of processor time on one core before it gives up with UnidentifiedImageError. Anyone who can hand bytes to an application that opens images with Pillow's default settings can trigger this, for example through an upload form, a thumbnailer, or a service that checks whether a blob is an image. A few such files sent at once can tie up a typical pool of worker processes.
The cause is the xbm_head regular expression in src/PIL/XbmImagePlugin.py:32-40, which XbmImageFile._open() (line 58) runs over the first 512 bytes of any stream whose prefix starts with #define. Several adjacent parts of the pattern can match the same characters. [ \t]+ overlaps with .* in the width and height lines and with [^_]* in the optional hotspot lines, and [\r\n]+ closing the hotspot group overlaps with the following [\000-\377]*. The header sets a run of k spaces after each #define and a run of k line terminators after _y_hot, then omits the [] after _bits. That forces Python's backtracking matcher to try every way of splitting those runs and rescan the remaining bytes each time. The cost grows roughly as k to the fifth power: k = 60 measured 375 s, while a well-formed XBM of the same size opens in about 40 ms. Because this happens before any format is identified, none of Pillow's size, pixel-count or decompression-bomb limits apply, and upload size limits do not help because the file is tiny. ImageFile.Parser.feed() repeats the cost on every chunk until the stream is identified. The only existing mitigation is passing a formats= allowlist that excludes "XBM".
The attached reproducer opens the same header with and without the trailing []. The valid version opens as XBM in 52 ms. The broken version takes 0.1 s, 0.75 s, 3.0 s and 8.6 s at k = 10, 15, 20 and 25, and the slow k = 60 case is not run. This is the same class of bug as CVE-2021-25292 in PdfParser, but in a different plugin and reachable from plain Image.open().
Details
XbmImageFile._open() identifies an XBM file by running the module-level regex xbm_head over the first 512 bytes of the stream. The pattern has several adjacent quantifier pairs that can consume the same characters, followed by a [\000-\377]*_bits\[] tail that rescans the rest of the buffer for every way of splitting them. A 512-byte input built to exercise all of them and then fail the final literal keeps Image.open() in xbm_head.match() for minutes before it raises UnidentifiedImageError.
This 512-byte input (k = 60) takes 375 s of CPU in Image.open(io.BytesIO(data)) with default settings, measured on the stock build at this commit:
k = 60
data = b"#define" + b" "*k + b"_width 1\r"
data += b"#define" + b" "*k + b"_height 1\r"
data += b"#define" + b" "*k + b"_x_hot 1\r"
data += b"#define" + b" "*k + b"_y_hot 1" + b"\r"*k
data += b"_bits" # no "[]": the final literal never matches
data += b"A" * (512 - len(data)) # pad to the 512 bytes _open() reads
Calling XbmImagePlugin.xbm_head.match(data) directly gives the same picture: k = 10 → 0.11 s, k = 15 → 0.76 s, k = 20 → 3.0 s, k = 25 → 8.5 s, k = 30 → 19.9 s (roughly ×27 per doubling of k, i.e. about k^4.7). A well-formed 512-byte XBM matches in 10 µs and opens and loads through Image.open() in ~40 ms including plugin import; the same k = 60 header with _bits[] present matches in 5 µs.
The regex, src/PIL/XbmImagePlugin.py:32:
xbm_head = re.compile(
rb"\s*#define[ \t]+.*_width[ \t]+(?P<width>[0-9]+)[\r\n]+"
b"#define[ \t]+.*_height[ \t]+(?P<height>[0-9]+)[\r\n]+"
b"(?P<hotspot>"
b"#define[ \t]+[^_]*_x_hot[ \t]+(?P<xhot>[0-9]+)[\r\n]+"
b"#define[ \t]+[^_]*_y_hot[ \t]+(?P<yhot>[0-9]+)[\r\n]+"
b")?"
rb"[\000-\377]*_bits\[]"
)
and the only call site, src/PIL/XbmImagePlugin.py:58:
def _open(self) -> None:
…
m = xbm_head.match(self.fp.read(512))
if not m:
msg = "not a XBM file"
raise SyntaxError(msg)
For a well-formed header (#define im_width 8\n…static char im_bits[] = {) each [ \t]+ eats the single space, .*/[^_]* eat the identifier prefix, and [\000-\377]*_bits\[] finds the literal on its first backward scan, so the match is linear. The crafted header diverges at every one of those points:
[ \t]+.*_widthand[ \t]+.*_height: the run of k spaces after#definecan be split between[ \t]+and.*in k ways, all leading to the same continuation. Factor k each. (The choice of\rterminators is incidental: the same header with\nterminators is equally slow.)[ \t]+[^_]*_x_hotand[ \t]+[^_]*_y_hotinside the optionalhotspotgroup:[^_]*also matches spaces, so the same k-way split exists twice more. Factor k each. These two lines are essential: without them the same input is rejected in about 10 ms.[\r\n]+closing thehotspotgroup, followed by)?and[\000-\377]*: the run of k\rbytes after_y_hot 1can be divided between[\r\n]+and[\000-\377]*in k ways. Factor k.[\000-\377]*_bits\[]: for every combination above, the engine swallows the remaining ~150 bytes of padding and walks back looking for_bits[]. The input contains_bitsbut never[], so this always fails and every combination is visited.
CPython's re is a backtracking engine without memoisation, so the total work is on the order of k^5 × (512 − header length) steps — about 10^11 for k = 60, consistent with the measured 375 s. The 512-byte read caps k (5k + ~60 ≤ 512), so the cost per open() is bounded, but the bound is minutes of CPU.
The path is the default one. Image.open() (src/PIL/Image.py:3719) reads a 16-byte prefix and offers it to every registered plugin's accept hook; XbmImagePlugin._accept() (src/PIL/XbmImagePlugin.py:43) returns true for anything whose left-stripped prefix starts with #define, and _open() then runs the regex. No size, pixel-count or decompression-bomb check can apply before this point because nothing has been parsed yet, and since the match ultimately fails the file is never identified, so the only outcome for the caller is UnidentifiedImageError after the delay. File name and extension are irrelevant because dispatch is by content. A faulthandler stack dump taken 20 s into the call shows the interpreter at XbmImagePlugin.py:58 in _open ← ImageFile.py:154 in __init__ ← Image.py:3699 in _open_core ← Image.py:3719 in open.
ImageFile.Parser.feed() (src/PIL/ImageFile.py:584) amplifies this further: until the stream is identified it calls Image.open() on all accumulated data at every feed(), so an application feeding the stream in chunks pays the regex cost once per chunk (measured: k = 15 header fed in 8 chunks → 4.6 s versus 0.76 s for a single open()).
Impact
Anyone who can get 512 bytes in front of Image.open() — an upload endpoint, thumbnailer, or any service that uses Pillow to sniff whether a blob is an image — pins one CPU core of the handling process for roughly six minutes per request with the default plugin set and default limits. Nothing large is allocated and no DecompressionBombWarning/Error fires; application-side upload size limits do not help because the file is tiny, and Image.MAX_IMAGE_PIXELS is never consulted because no image is ever identified. A handful of concurrent requests is enough to exhaust a typical worker pool. The per-call cost is bounded by the 512-byte header read, so this is a CPU-exhaustion denial of service of the handling process rather than an infinite loop. Applications that pass an explicit formats= allowlist to Image.open() that excludes "XBM" are not affected.
This is the same bug class as CVE-2021-25292 (catastrophic backtracking in the PdfParser regexes, fixed in 8.1.1) and CVE-2021-23437 (ImageColor.getrgb ReDoS, fixed in 8.3.2), in a different plugin; unlike the PDF case it is reached from plain Image.open() on any byte stream.
Reproducing
repro is a single Python script. It uses the installed Pillow through the public Image.open() API and needs no rebuild.
Each input is the 512-byte header from Details: four #define lines with k spaces after #define, lines ending in \r, k \r bytes after _y_hot 1, padding with A up to the 512 bytes that _open() reads. The only thing that changes between inputs is the tail: _bits[] (valid) or _bits (the final literal can never match).
- Control. Opens the k = 60 header with the tail
_bits[]. The regex matches on its first try and Pillow reportsXBM (1, 1)in about 50 ms. This shows that the same bytes are only slow when the match has to fail. - Attack. Opens the header with the tail
_bitsat k = 10, 15, 20 and 25. Each one raisesUnidentifiedImageError, after about 0.1 s, 0.75 s, 3.0 s and 8.6 s. The time grows polynomially, not linearly. The k = 60 input from Details, which takes about 6 minutes of CPU, is not run.
Expected output on this commit:
control k=60 '_bits[]': XBM (1, 1) in 0.052s
attack k=10 '_bits' : UnidentifiedImageError in 0.105s
attack k=15 '_bits' : UnidentifiedImageError in 0.748s
attack k=20 '_bits' : UnidentifiedImageError in 3.024s
attack k=25 '_bits' : UnidentifiedImageError in 8.561s
BUG
The script prints BUG only when all of these hold:
- the control header opened as
XBMin under 1 s; - the k = 25 attack input took more than 2 s;
- the k = 25 attack input took more than 5 times as long as the k = 15 one, i.e. the cost grows super-linearly in k.
Otherwise it prints OK. With the attached patch applied, every attack input is rejected at once, so the script prints OK.
Suggested fix
The attached patch removes the overlap between [ \t]+ and the quantifier that matches the identifier prefix in xbm_head (src/PIL/XbmImagePlugin.py:32-40), so the whitespace after #define can be consumed in exactly one way and the identifier cannot run across line terminators. It matches the identifier with [^ \t\r\n]* (and [^ \t\r\n_]* in the hotspot group, which keeps the existing "no underscore before _x_hot/_y_hot" behaviour); the remaining quantifier pairs are then either over disjoint character classes or reduce to a single linear rescan of at most 512 bytes:
xbm_head = re.compile(
- rb"\s*#define[ \t]+.*_width[ \t]+(?P<width>[0-9]+)[\r\n]+"
- b"#define[ \t]+.*_height[ \t]+(?P<height>[0-9]+)[\r\n]+"
+ rb"\s*#define[ \t]+[^ \t\r\n]*_width[ \t]+(?P<width>[0-9]+)[\r\n]+"
+ rb"#define[ \t]+[^ \t\r\n]*_height[ \t]+(?P<height>[0-9]+)[\r\n]+"
b"(?P<hotspot>"
- b"#define[ \t]+[^_]*_x_hot[ \t]+(?P<xhot>[0-9]+)[\r\n]+"
- b"#define[ \t]+[^_]*_y_hot[ \t]+(?P<yhot>[0-9]+)[\r\n]+"
+ rb"#define[ \t]+[^ \t\r\n_]*_x_hot[ \t]+(?P<xhot>[0-9]+)[\r\n]+"
+ rb"#define[ \t]+[^ \t\r\n_]*_y_hot[ \t]+(?P<yhot>[0-9]+)[\r\n]+"
b")?"
rb"[\000-\377]*_bits\[]"
)
This mirrors the PdfParser fix for CVE-2021-25292. The patch also adds a test_redos case to Tests/test_file_xbm.py, in the style of the one in Tests/test_file_pdf.py: it builds the k = 60 header from Details and, under @timeout_unless_slower_valgrind(1), expects XbmImageFile to raise SyntaxError. With the patch applied to a clean checkout and rebuilt, the reproducer prints OK and the existing Tests/test_file_xbm.py (including hopper.xbm, hopper_underscore.xbm and the hotspot round-trip) still passes. The change does reject headers whose identifier contains whitespace (#define foo bar_width 16), which is not valid C and is not produced by Pillow's own XBM writer.
The patch
Use more specific regex chars in the XBM header regex to prevent ReDoS in Image.open() on a crafted 512-byte header
Applies to src/PIL/XbmImagePlugin.py at the commit above.
diff --git a/Tests/test_file_xbm.py b/Tests/test_file_xbm.py
index 1988c417f..67236c795 100644
--- a/Tests/test_file_xbm.py
+++ b/Tests/test_file_xbm.py
@@ -6,7 +6,7 @@ import pytest
from PIL import Image, XbmImagePlugin
-from .helper import hopper
+from .helper import hopper, timeout_unless_slower_valgrind
TYPE_CHECKING = False
if TYPE_CHECKING:
@@ -91,3 +91,17 @@ def test_hotspot(tmp_path: Path) -> None:
with Image.open(out) as reloaded:
assert reloaded.info["hotspot"] == hotspot
+
+
+@timeout_unless_slower_valgrind(1)
+def test_redos() -> None:
+ k = 60
+ malicious = b"#define" + b" " * k + b"_width 1\r"
+ malicious += b"#define" + b" " * k + b"_height 1\r"
+ malicious += b"#define" + b" " * k + b"_x_hot 1\r"
+ malicious += b"#define" + b" " * k + b"_y_hot 1" + b"\r" * k + b"_bits"
+ malicious += b"A" * (512 - len(malicious))
+
+ # The important thing is it doesn't timeout, cause a ReDoS
+ with pytest.raises(SyntaxError):
+ XbmImagePlugin.XbmImageFile(BytesIO(malicious))
diff --git a/src/PIL/XbmImagePlugin.py b/src/PIL/XbmImagePlugin.py
index 95729d73d..7435d20f2 100644
--- a/src/PIL/XbmImagePlugin.py
+++ b/src/PIL/XbmImagePlugin.py
@@ -29,12 +29,14 @@ if TYPE_CHECKING:
from typing import IO
# XBM header
+# The identifier before each suffix cannot contain whitespace, so that it
+# cannot overlap with the preceding [ \t]+ and cause a ReDoS
xbm_head = re.compile(
- rb"\s*#define[ \t]+.*_width[ \t]+(?P<width>[0-9]+)[\r\n]+"
- b"#define[ \t]+.*_height[ \t]+(?P<height>[0-9]+)[\r\n]+"
+ rb"\s*#define[ \t]+[^ \t\r\n]*_width[ \t]+(?P<width>[0-9]+)[\r\n]+"
+ rb"#define[ \t]+[^ \t\r\n]*_height[ \t]+(?P<height>[0-9]+)[\r\n]+"
b"(?P<hotspot>"
- b"#define[ \t]+[^_]*_x_hot[ \t]+(?P<xhot>[0-9]+)[\r\n]+"
- b"#define[ \t]+[^_]*_y_hot[ \t]+(?P<yhot>[0-9]+)[\r\n]+"
+ rb"#define[ \t]+[^ \t\r\n_]*_x_hot[ \t]+(?P<xhot>[0-9]+)[\r\n]+"
+ rb"#define[ \t]+[^ \t\r\n_]*_y_hot[ \t]+(?P<yhot>[0-9]+)[\r\n]+"
b")?"
rb"[\000-\377]*_bits\[]"
)
The reproducer
Reproducer —repro, 1,138 bytes (click to open)
Its last line is `BUG` when the issue triggers and `OK` when it does not. Re-run on a clean build of that commit it printed `BUG`.
#!/usr/bin/env python3
# XbmImagePlugin.xbm_head catastrophic backtracking, reached from Image.open()
# on a <=512-byte stream. Prints BUG if a failing 512-byte header takes
# super-linearly long while the same-shaped valid header opens instantly.
import io, time
from PIL import Image
def hdr(k, tail):
d = b""
for name in (b"_width 1\r", b"_height 1\r", b"_x_hot 1\r", b"_y_hot 1"):
d += b"#define" + b" " * k + name
d += b"\r" * k + tail
return d + b"A" * (512 - len(d))
def timed(data):
s = time.perf_counter()
try:
im = Image.open(io.BytesIO(data)); r = f"{im.format} {im.size}"
except Exception as e:
r = type(e).__name__
return r, time.perf_counter() - s
ctl, tc = timed(hdr(60, b"_bits[]"))
print(f"control k=60 '_bits[]': {ctl} in {tc:.3f}s")
ts = {}
for k in (10, 15, 20, 25):
r, ts[k] = timed(hdr(k, b"_bits"))
print(f"attack k={k:2d} '_bits' : {r} in {ts[k]:.3f}s", flush=True)
# k=60 (fits easily in 512 bytes) runs for minutes; not executed here.
bug = ctl.startswith("XBM") and tc < 1 and ts[25] > 2 and ts[25] > 5 * ts[15]
print("BUG" if bug else "OK")
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 12.3.0"
},
"package": {
"ecosystem": "PyPI",
"name": "Pillow"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "13.0.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-112901"
],
"database_specific": {
"cwe_ids": [
"CWE-1333"
],
"github_reviewed": true,
"github_reviewed_at": "2026-10-21T20:45:06Z",
"nvd_published_at": "2026-10-19T22:17:10Z",
"severity": "MODERATE"
},
"details": "```\n============================================================================\nReDoS in XbmImagePlugin: 512-byte file stalls Image.open() for minutes\nLocation: src/PIL/XbmImagePlugin.py:58 in XbmImageFile._open()\nCommit: a707c6b21c313880d0771e54965d142dd42358b6\n============================================================================\n```\n\nA crafted 512-byte file makes Pillow\u0027s `Image.open()` spend about six minutes of processor time on one core before it gives up with `UnidentifiedImageError`. Anyone who can hand bytes to an application that opens images with Pillow\u0027s default settings can trigger this, for example through an upload form, a thumbnailer, or a service that checks whether a blob is an image. A few such files sent at once can tie up a typical pool of worker processes.\n\nThe cause is the `xbm_head` regular expression in `src/PIL/XbmImagePlugin.py:32-40`, which `XbmImageFile._open()` (line 58) runs over the first 512 bytes of any stream whose prefix starts with `#define`. Several adjacent parts of the pattern can match the same characters. `[ \\t]+` overlaps with `.*` in the width and height lines and with `[^_]*` in the optional hotspot lines, and `[\\r\\n]+` closing the hotspot group overlaps with the following `[\\000-\\377]*`. The header sets a run of k spaces after each `#define` and a run of k line terminators after `_y_hot`, then omits the `[]` after `_bits`. That forces Python\u0027s backtracking matcher to try every way of splitting those runs and rescan the remaining bytes each time. The cost grows roughly as k to the fifth power: k = 60 measured 375 s, while a well-formed XBM of the same size opens in about 40 ms. Because this happens before any format is identified, none of Pillow\u0027s size, pixel-count or decompression-bomb limits apply, and upload size limits do not help because the file is tiny. `ImageFile.Parser.feed()` repeats the cost on every chunk until the stream is identified. The only existing mitigation is passing a `formats=` allowlist that excludes `\"XBM\"`.\n\nThe attached reproducer opens the same header with and without the trailing `[]`. The valid version opens as XBM in 52 ms. The broken version takes 0.1 s, 0.75 s, 3.0 s and 8.6 s at k = 10, 15, 20 and 25, and the slow k = 60 case is not run. This is the same class of bug as CVE-2021-25292 in `PdfParser`, but in a different plugin and reachable from plain `Image.open()`.\n\n## Details\n\n`XbmImageFile._open()` identifies an XBM file by running the module-level regex `xbm_head` over the first 512 bytes of the stream. The pattern has several adjacent quantifier pairs that can consume the same characters, followed by a `[\\000-\\377]*_bits\\[]` tail that rescans the rest of the buffer for every way of splitting them. A 512-byte input built to exercise all of them and then fail the final literal keeps `Image.open()` in `xbm_head.match()` for minutes before it raises `UnidentifiedImageError`.\n\nThis 512-byte input (k = 60) takes 375 s of CPU in `Image.open(io.BytesIO(data))` with default settings, measured on the stock build at this commit:\n\n```python\nk = 60\ndata = b\"#define\" + b\" \"*k + b\"_width 1\\r\"\ndata += b\"#define\" + b\" \"*k + b\"_height 1\\r\"\ndata += b\"#define\" + b\" \"*k + b\"_x_hot 1\\r\"\ndata += b\"#define\" + b\" \"*k + b\"_y_hot 1\" + b\"\\r\"*k\ndata += b\"_bits\" # no \"[]\": the final literal never matches\ndata += b\"A\" * (512 - len(data)) # pad to the 512 bytes _open() reads\n```\n\nCalling `XbmImagePlugin.xbm_head.match(data)` directly gives the same picture: k = 10 \u2192 0.11 s, k = 15 \u2192 0.76 s, k = 20 \u2192 3.0 s, k = 25 \u2192 8.5 s, k = 30 \u2192 19.9 s (roughly \u00d727 per doubling of k, i.e. about k^4.7). A well-formed 512-byte XBM matches in 10 \u00b5s and opens and loads through `Image.open()` in ~40 ms including plugin import; the same k = 60 header with `_bits[]` present matches in 5 \u00b5s.\n\nThe regex, `src/PIL/XbmImagePlugin.py:32`:\n\n```python\nxbm_head = re.compile(\n rb\"\\s*#define[ \\t]+.*_width[ \\t]+(?P\u003cwidth\u003e[0-9]+)[\\r\\n]+\"\n b\"#define[ \\t]+.*_height[ \\t]+(?P\u003cheight\u003e[0-9]+)[\\r\\n]+\"\n b\"(?P\u003chotspot\u003e\"\n b\"#define[ \\t]+[^_]*_x_hot[ \\t]+(?P\u003cxhot\u003e[0-9]+)[\\r\\n]+\"\n b\"#define[ \\t]+[^_]*_y_hot[ \\t]+(?P\u003cyhot\u003e[0-9]+)[\\r\\n]+\"\n b\")?\"\n rb\"[\\000-\\377]*_bits\\[]\"\n)\n```\n\nand the only call site, `src/PIL/XbmImagePlugin.py:58`:\n\n```python\n def _open(self) -\u003e None:\n \u2026\n m = xbm_head.match(self.fp.read(512))\n if not m:\n msg = \"not a XBM file\"\n raise SyntaxError(msg)\n```\n\nFor a well-formed header (`#define im_width 8\\n\u2026static char im_bits[] = {`) each `[ \\t]+` eats the single space, `.*`/`[^_]*` eat the identifier prefix, and `[\\000-\\377]*_bits\\[]` finds the literal on its first backward scan, so the match is linear. The crafted header diverges at every one of those points:\n\n- `[ \\t]+.*_width` and `[ \\t]+.*_height`: the run of k spaces after `#define` can be split between `[ \\t]+` and `.*` in k ways, all leading to the same continuation. Factor k each. (The choice of `\\r` terminators is incidental: the same header with `\\n` terminators is equally slow.)\n- `[ \\t]+[^_]*_x_hot` and `[ \\t]+[^_]*_y_hot` inside the optional `hotspot` group: `[^_]*` also matches spaces, so the same k-way split exists twice more. Factor k each. These two lines are essential: without them the same input is rejected in about 10 ms.\n- `[\\r\\n]+` closing the `hotspot` group, followed by `)?` and `[\\000-\\377]*`: the run of k `\\r` bytes after `_y_hot 1` can be divided between `[\\r\\n]+` and `[\\000-\\377]*` in k ways. Factor k.\n- `[\\000-\\377]*_bits\\[]`: for every combination above, the engine swallows the remaining ~150 bytes of padding and walks back looking for `_bits[]`. The input contains `_bits` but never `[]`, so this always fails and every combination is visited.\n\nCPython\u0027s `re` is a backtracking engine without memoisation, so the total work is on the order of k^5 \u00d7 (512 \u2212 header length) steps \u2014 about 10^11 for k = 60, consistent with the measured 375 s. The 512-byte read caps k (5k + ~60 \u2264 512), so the cost per `open()` is bounded, but the bound is minutes of CPU.\n\nThe path is the default one. `Image.open()` (`src/PIL/Image.py:3719`) reads a 16-byte prefix and offers it to every registered plugin\u0027s accept hook; `XbmImagePlugin._accept()` (`src/PIL/XbmImagePlugin.py:43`) returns true for anything whose left-stripped prefix starts with `#define`, and `_open()` then runs the regex. No size, pixel-count or decompression-bomb check can apply before this point because nothing has been parsed yet, and since the match ultimately fails the file is never identified, so the only outcome for the caller is `UnidentifiedImageError` after the delay. File name and extension are irrelevant because dispatch is by content. A `faulthandler` stack dump taken 20 s into the call shows the interpreter at `XbmImagePlugin.py:58 in _open` \u2190 `ImageFile.py:154 in __init__` \u2190 `Image.py:3699 in _open_core` \u2190 `Image.py:3719 in open`.\n\n`ImageFile.Parser.feed()` (`src/PIL/ImageFile.py:584`) amplifies this further: until the stream is identified it calls `Image.open()` on all accumulated data at every `feed()`, so an application feeding the stream in chunks pays the regex cost once per chunk (measured: k = 15 header fed in 8 chunks \u2192 4.6 s versus 0.76 s for a single `open()`).\n\n## Impact\n\nAnyone who can get 512 bytes in front of `Image.open()` \u2014 an upload endpoint, thumbnailer, or any service that uses Pillow to sniff whether a blob is an image \u2014 pins one CPU core of the handling process for roughly six minutes per request with the default plugin set and default limits. Nothing large is allocated and no `DecompressionBombWarning`/`Error` fires; application-side upload size limits do not help because the file is tiny, and `Image.MAX_IMAGE_PIXELS` is never consulted because no image is ever identified. A handful of concurrent requests is enough to exhaust a typical worker pool. The per-call cost is bounded by the 512-byte header read, so this is a CPU-exhaustion denial of service of the handling process rather than an infinite loop. Applications that pass an explicit `formats=` allowlist to `Image.open()` that excludes `\"XBM\"` are not affected.\n\nThis is the same bug class as CVE-2021-25292 (catastrophic backtracking in the `PdfParser` regexes, fixed in 8.1.1) and CVE-2021-23437 (`ImageColor.getrgb` ReDoS, fixed in 8.3.2), in a different plugin; unlike the PDF case it is reached from plain `Image.open()` on any byte stream.\n\n## Reproducing\n\n`repro` is a single Python script. It uses the installed Pillow through the public `Image.open()` API and needs no rebuild.\n\nEach input is the 512-byte header from Details: four `#define` lines with k spaces after `#define`, lines ending in `\\r`, k `\\r` bytes after `_y_hot 1`, padding with `A` up to the 512 bytes that `_open()` reads. The only thing that changes between inputs is the tail: `_bits[]` (valid) or `_bits` (the final literal can never match).\n\n1. **Control.** Opens the k = 60 header with the tail `_bits[]`. The regex matches on its first try and Pillow reports `XBM (1, 1)` in about 50 ms. This shows that the same bytes are only slow when the match has to fail.\n2. **Attack.** Opens the header with the tail `_bits` at k = 10, 15, 20 and 25. Each one raises `UnidentifiedImageError`, after about 0.1 s, 0.75 s, 3.0 s and 8.6 s. The time grows polynomially, not linearly. The k = 60 input from Details, which takes about 6 minutes of CPU, is not run.\n\nExpected output on this commit:\n\n```\ncontrol k=60 \u0027_bits[]\u0027: XBM (1, 1) in 0.052s\nattack k=10 \u0027_bits\u0027 : UnidentifiedImageError in 0.105s\nattack k=15 \u0027_bits\u0027 : UnidentifiedImageError in 0.748s\nattack k=20 \u0027_bits\u0027 : UnidentifiedImageError in 3.024s\nattack k=25 \u0027_bits\u0027 : UnidentifiedImageError in 8.561s\nBUG\n```\n\nThe script prints `BUG` only when all of these hold:\n\n- the control header opened as `XBM` in under 1 s;\n- the k = 25 attack input took more than 2 s;\n- the k = 25 attack input took more than 5 times as long as the k = 15 one, i.e. the cost grows super-linearly in k.\n\nOtherwise it prints `OK`. With the attached patch applied, every attack input is rejected at once, so the script prints `OK`.\n\n## Suggested fix\n\nThe attached patch removes the overlap between `[ \\t]+` and the quantifier that matches the identifier prefix in `xbm_head` (`src/PIL/XbmImagePlugin.py:32-40`), so the whitespace after `#define` can be consumed in exactly one way and the identifier cannot run across line terminators. It matches the identifier with `[^ \\t\\r\\n]*` (and `[^ \\t\\r\\n_]*` in the hotspot group, which keeps the existing \"no underscore before `_x_hot`/`_y_hot`\" behaviour); the remaining quantifier pairs are then either over disjoint character classes or reduce to a single linear rescan of at most 512 bytes:\n\n```diff\n xbm_head = re.compile(\n- rb\"\\s*#define[ \\t]+.*_width[ \\t]+(?P\u003cwidth\u003e[0-9]+)[\\r\\n]+\"\n- b\"#define[ \\t]+.*_height[ \\t]+(?P\u003cheight\u003e[0-9]+)[\\r\\n]+\"\n+ rb\"\\s*#define[ \\t]+[^ \\t\\r\\n]*_width[ \\t]+(?P\u003cwidth\u003e[0-9]+)[\\r\\n]+\"\n+ rb\"#define[ \\t]+[^ \\t\\r\\n]*_height[ \\t]+(?P\u003cheight\u003e[0-9]+)[\\r\\n]+\"\n b\"(?P\u003chotspot\u003e\"\n- b\"#define[ \\t]+[^_]*_x_hot[ \\t]+(?P\u003cxhot\u003e[0-9]+)[\\r\\n]+\"\n- b\"#define[ \\t]+[^_]*_y_hot[ \\t]+(?P\u003cyhot\u003e[0-9]+)[\\r\\n]+\"\n+ rb\"#define[ \\t]+[^ \\t\\r\\n_]*_x_hot[ \\t]+(?P\u003cxhot\u003e[0-9]+)[\\r\\n]+\"\n+ rb\"#define[ \\t]+[^ \\t\\r\\n_]*_y_hot[ \\t]+(?P\u003cyhot\u003e[0-9]+)[\\r\\n]+\"\n b\")?\"\n rb\"[\\000-\\377]*_bits\\[]\"\n )\n```\n\nThis mirrors the `PdfParser` fix for CVE-2021-25292. The patch also adds a `test_redos` case to `Tests/test_file_xbm.py`, in the style of the one in `Tests/test_file_pdf.py`: it builds the k = 60 header from Details and, under `@timeout_unless_slower_valgrind(1)`, expects `XbmImageFile` to raise `SyntaxError`. With the patch applied to a clean checkout and rebuilt, the reproducer prints `OK` and the existing `Tests/test_file_xbm.py` (including `hopper.xbm`, `hopper_underscore.xbm` and the hotspot round-trip) still passes. The change does reject headers whose identifier contains whitespace (`#define foo bar_width 16`), which is not valid C and is not produced by Pillow\u0027s own XBM writer.\n\n## The patch\n\nUse more specific regex chars in the XBM header regex to prevent ReDoS in Image.open() on a crafted 512-byte header\n\nApplies to `src/PIL/XbmImagePlugin.py` at the commit above.\n\n```diff\ndiff --git a/Tests/test_file_xbm.py b/Tests/test_file_xbm.py\nindex 1988c417f..67236c795 100644\n--- a/Tests/test_file_xbm.py\n+++ b/Tests/test_file_xbm.py\n@@ -6,7 +6,7 @@ import pytest\n \n from PIL import Image, XbmImagePlugin\n \n-from .helper import hopper\n+from .helper import hopper, timeout_unless_slower_valgrind\n \n TYPE_CHECKING = False\n if TYPE_CHECKING:\n@@ -91,3 +91,17 @@ def test_hotspot(tmp_path: Path) -\u003e None:\n \n with Image.open(out) as reloaded:\n assert reloaded.info[\"hotspot\"] == hotspot\n+\n+\n+@timeout_unless_slower_valgrind(1)\n+def test_redos() -\u003e None:\n+ k = 60\n+ malicious = b\"#define\" + b\" \" * k + b\"_width 1\\r\"\n+ malicious += b\"#define\" + b\" \" * k + b\"_height 1\\r\"\n+ malicious += b\"#define\" + b\" \" * k + b\"_x_hot 1\\r\"\n+ malicious += b\"#define\" + b\" \" * k + b\"_y_hot 1\" + b\"\\r\" * k + b\"_bits\"\n+ malicious += b\"A\" * (512 - len(malicious))\n+\n+ # The important thing is it doesn\u0027t timeout, cause a ReDoS\n+ with pytest.raises(SyntaxError):\n+ XbmImagePlugin.XbmImageFile(BytesIO(malicious))\ndiff --git a/src/PIL/XbmImagePlugin.py b/src/PIL/XbmImagePlugin.py\nindex 95729d73d..7435d20f2 100644\n--- a/src/PIL/XbmImagePlugin.py\n+++ b/src/PIL/XbmImagePlugin.py\n@@ -29,12 +29,14 @@ if TYPE_CHECKING:\n from typing import IO\n \n # XBM header\n+# The identifier before each suffix cannot contain whitespace, so that it\n+# cannot overlap with the preceding [ \\t]+ and cause a ReDoS\n xbm_head = re.compile(\n- rb\"\\s*#define[ \\t]+.*_width[ \\t]+(?P\u003cwidth\u003e[0-9]+)[\\r\\n]+\"\n- b\"#define[ \\t]+.*_height[ \\t]+(?P\u003cheight\u003e[0-9]+)[\\r\\n]+\"\n+ rb\"\\s*#define[ \\t]+[^ \\t\\r\\n]*_width[ \\t]+(?P\u003cwidth\u003e[0-9]+)[\\r\\n]+\"\n+ rb\"#define[ \\t]+[^ \\t\\r\\n]*_height[ \\t]+(?P\u003cheight\u003e[0-9]+)[\\r\\n]+\"\n b\"(?P\u003chotspot\u003e\"\n- b\"#define[ \\t]+[^_]*_x_hot[ \\t]+(?P\u003cxhot\u003e[0-9]+)[\\r\\n]+\"\n- b\"#define[ \\t]+[^_]*_y_hot[ \\t]+(?P\u003cyhot\u003e[0-9]+)[\\r\\n]+\"\n+ rb\"#define[ \\t]+[^ \\t\\r\\n_]*_x_hot[ \\t]+(?P\u003cxhot\u003e[0-9]+)[\\r\\n]+\"\n+ rb\"#define[ \\t]+[^ \\t\\r\\n_]*_y_hot[ \\t]+(?P\u003cyhot\u003e[0-9]+)[\\r\\n]+\"\n b\")?\"\n rb\"[\\000-\\377]*_bits\\[]\"\n )\n```\n\n## The reproducer\n\n\u003cdetails\u003e\n\u003csummary\u003eReproducer \u2014 \u003ccode\u003erepro\u003c/code\u003e, 1,138 bytes (click to open)\u003c/summary\u003e\n\nIts last line is `BUG` when the issue triggers and `OK` when it does not. Re-run on a clean build of that commit it printed `BUG`.\n\n```python\n#!/usr/bin/env python3\n# XbmImagePlugin.xbm_head catastrophic backtracking, reached from Image.open()\n# on a \u003c=512-byte stream. Prints BUG if a failing 512-byte header takes\n# super-linearly long while the same-shaped valid header opens instantly.\nimport io, time\nfrom PIL import Image\n\ndef hdr(k, tail):\n d = b\"\"\n for name in (b\"_width 1\\r\", b\"_height 1\\r\", b\"_x_hot 1\\r\", b\"_y_hot 1\"):\n d += b\"#define\" + b\" \" * k + name\n d += b\"\\r\" * k + tail\n return d + b\"A\" * (512 - len(d))\n\ndef timed(data):\n s = time.perf_counter()\n try:\n im = Image.open(io.BytesIO(data)); r = f\"{im.format} {im.size}\"\n except Exception as e:\n r = type(e).__name__\n return r, time.perf_counter() - s\n\nctl, tc = timed(hdr(60, b\"_bits[]\"))\nprint(f\"control k=60 \u0027_bits[]\u0027: {ctl} in {tc:.3f}s\")\nts = {}\nfor k in (10, 15, 20, 25):\n r, ts[k] = timed(hdr(k, b\"_bits\"))\n print(f\"attack k={k:2d} \u0027_bits\u0027 : {r} in {ts[k]:.3f}s\", flush=True)\n# k=60 (fits easily in 512 bytes) runs for minutes; not executed here.\nbug = ctl.startswith(\"XBM\") and tc \u003c 1 and ts[25] \u003e 2 and ts[25] \u003e 5 * ts[15]\nprint(\"BUG\" if bug else \"OK\")\n```\n\u003c/details\u003e\n\n---",
"id": "GHSA-xgh8-jp6q-p5x8",
"modified": "2026-10-21T20:45:06Z",
"published": "2026-10-21T20:45:06Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/python-pillow/Pillow/security/advisories/GHSA-xgh8-jp6q-p5x8"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-112901"
},
{
"type": "WEB",
"url": "https://github.com/python-pillow/Pillow/commit/2852a3e3d568997ddec745fc800991f138878f4b"
},
{
"type": "PACKAGE",
"url": "https://github.com/python-pillow/Pillow"
},
{
"type": "WEB",
"url": "https://github.com/python-pillow/Pillow/releases/tag/13.0.0"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N",
"type": "CVSS_V4"
}
],
"summary": "Pillow: ReDoS in XbmImagePlugin: 512-byte file stalls Image.open() for minutes"
}
GHSA-XH9H-692F-MMG4
Vulnerability from github – Published: 2025-08-20 03:30 – Updated: 2025-08-29 20:14Withdrawn Advisory
This advisory has been withdrawn because the attack surface of this vulnerability is outside of Knack's intended functionality. The maintainer states the following:
These CVEs are invalid. Knack is a CLI framework used by Azure CLI. It's a local library, not a web service. In addition, the regex is used to extract function and parameter docstrings from the source code. It is not used to match user input. Therefore, it does not expose any attack surface. There is no way to use it for ReDoS attack.
This link is maintained to preserve external references.
Original Description
Microsoft Knack 0.12.0 allows Regular expression Denial of Service (ReDoS) in the knack.introspection module (issue 2 of 2).
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "knack"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "0.12.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2025-54364"
],
"database_specific": {
"cwe_ids": [
"CWE-1333"
],
"github_reviewed": true,
"github_reviewed_at": "2025-08-21T15:01:00Z",
"nvd_published_at": "2025-08-20T03:15:35Z",
"severity": "LOW"
},
"details": "### Withdrawn Advisory\nThis advisory has been withdrawn because the attack surface of this vulnerability is outside of Knack\u0027s intended functionality. The maintainer states the following:\n\n\u003e These CVEs are invalid. Knack is a CLI framework used by [Azure CLI](https://github.com/Azure/azure-cli). It\u0027s a local library, not a web service. In addition, the regex is used to extract function and parameter docstrings from the source code. It is not used to match user input. Therefore, it does not expose any attack surface. There is no way to use it for ReDoS attack.\n\nThis link is maintained to preserve external references.\n\n### Original Description\nMicrosoft Knack 0.12.0 allows Regular expression Denial of Service (ReDoS) in the knack.introspection module (issue 2 of 2).",
"id": "GHSA-xh9h-692f-mmg4",
"modified": "2025-08-29T20:14:37Z",
"published": "2025-08-20T03:30:21Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-54364"
},
{
"type": "WEB",
"url": "https://github.com/microsoft/knack/issues/281"
},
{
"type": "WEB",
"url": "https://github.com/microsoft/knack/issues/281#issuecomment-3218922941"
},
{
"type": "PACKAGE",
"url": "https://github.com/microsoft/knack"
},
{
"type": "WEB",
"url": "https://www.vulncheck.com/advisories/microsoft-knack-python-package-regular-expression-dos"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:U",
"type": "CVSS_V4"
}
],
"summary": "Withdrawn Advisory: Microsoft Knack ReDoS Vulnerability in the Introspection Module",
"withdrawn": "2025-08-29T20:14:37Z"
}
GHSA-XMC8-CJFR-PHX3
Vulnerability from github – Published: 2019-03-18 15:59 – Updated: 2021-09-21 22:36Versions of highcharts prior to 6.1.0 are vulnerable to Regular Expression Denial of Service (ReDoS). Untrusted input may cause catastrophic backtracking while matching regular expressions. This can cause the application to be unresponsive leading to Denial of Service.
Recommendation
Upgrade to version 6.1.0 or higher.
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "highcharts"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "6.1.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2018-20801"
],
"database_specific": {
"cwe_ids": [
"CWE-1333"
],
"github_reviewed": true,
"github_reviewed_at": "2020-06-16T22:03:47Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "Versions of `highcharts` prior to 6.1.0 are vulnerable to Regular Expression Denial of Service (ReDoS). Untrusted input may cause catastrophic backtracking while matching regular expressions. This can cause the application to be unresponsive leading to Denial of Service.\n\n\n## Recommendation\n\nUpgrade to version 6.1.0 or higher.",
"id": "GHSA-xmc8-cjfr-phx3",
"modified": "2021-09-21T22:36:57Z",
"published": "2019-03-18T15:59:32Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2018-20801"
},
{
"type": "WEB",
"url": "https://github.com/highcharts/highcharts/commit/7c547e1e0f5e4379f94396efd559a566668c0dfa"
},
{
"type": "ADVISORY",
"url": "https://github.com/advisories/GHSA-xmc8-cjfr-phx3"
},
{
"type": "PACKAGE",
"url": "https://github.com/highcharts/highcharts"
},
{
"type": "WEB",
"url": "https://security.netapp.com/advisory/ntap-20190715-0001"
},
{
"type": "WEB",
"url": "https://snyk.io/vuln/npm:highcharts:20180225"
},
{
"type": "WEB",
"url": "https://www.npmjs.com/advisories/793"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "Regular Expression Denial of Service in highcharts"
}
GHSA-XQ93-2HG3-RPJX
Vulnerability from github – Published: 2025-10-30 15:32 – Updated: 2025-10-30 15:32Zohocorp ManageEngine Exchange Reporter Plus through 5721 are vulnerable to ReDOS vulnerability in the search module.
{
"affected": [],
"aliases": [
"CVE-2025-5342"
],
"database_specific": {
"cwe_ids": [
"CWE-1333",
"CWE-400"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-10-30T15:15:40Z",
"severity": "MODERATE"
},
"details": "Zohocorp ManageEngine Exchange Reporter Plus through 5721 are vulnerable to ReDOS vulnerability in the search module.",
"id": "GHSA-xq93-2hg3-rpjx",
"modified": "2025-10-30T15:32:37Z",
"published": "2025-10-30T15:32:37Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-5342"
},
{
"type": "WEB",
"url": "https://www.manageengine.com/products/exchange-reports/advisory/CVE-2025-5342.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L",
"type": "CVSS_V3"
}
]
}
GHSA-XR9W-X6GW-C9MJ
Vulnerability from github – Published: 2023-02-25 06:30 – Updated: 2023-04-03 17:18Duplicate Advisory
This advisory has been withdrawn because it is a duplicate of GHSA-jc97-h3h9-7xh6. This link is maintained to preserve external references.
Original Description
Versions of the package deno before 1.31.0 are vulnerable to Regular Expression Denial of Service (ReDoS) due to the upgradeWebSocket function, which contains regexes in the form of /s,s/, used for splitting the Connection/Upgrade header. A specially crafted Connection/Upgrade header can be used to significantly slow down a web socket server. This issue has been patched in version 1.31.0.
{
"affected": [
{
"package": {
"ecosystem": "crates.io",
"name": "deno"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.31.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [],
"database_specific": {
"cwe_ids": [
"CWE-1333"
],
"github_reviewed": true,
"github_reviewed_at": "2023-02-28T14:00:55Z",
"nvd_published_at": "2023-02-25T05:15:00Z",
"severity": "HIGH"
},
"details": "## Duplicate Advisory\nThis advisory has been withdrawn because it is a duplicate of [GHSA-jc97-h3h9-7xh6](https://github.com/advisories/GHSA-jc97-h3h9-7xh6). This link is maintained to preserve external references.\n\n## Original Description\nVersions of the package deno before 1.31.0 are vulnerable to Regular Expression Denial of Service (ReDoS) due to the upgradeWebSocket function, which contains regexes in the form of /s*,s*/, used for splitting the Connection/Upgrade header. A specially crafted Connection/Upgrade header can be used to significantly slow down a web socket server. This issue has been patched in version 1.31.0.",
"id": "GHSA-xr9w-x6gw-c9mj",
"modified": "2023-04-03T17:18:44Z",
"published": "2023-02-25T06:30:21Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-26103"
},
{
"type": "WEB",
"url": "https://github.com/denoland/deno/pull/17722"
},
{
"type": "WEB",
"url": "https://github.com/denoland/deno/commit/cf06a7c7e672880e1b38598fe445e2c50b4a9d06"
},
{
"type": "PACKAGE",
"url": "https://github.com/denoland/deno"
},
{
"type": "WEB",
"url": "https://github.com/denoland/deno/blob/2b247be517d789a37e532849e2e40b724af0918f/ext/http/01_http.js%23L395-L409"
},
{
"type": "WEB",
"url": "https://github.com/denoland/deno/releases/tag/v1.31.0"
},
{
"type": "WEB",
"url": "https://security.snyk.io/vuln/SNYK-RUST-DENO-3315970"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "Duplicate advisory: Deno vulnerable to Regular Expression Denial of Service",
"withdrawn": "2023-04-03T17:18:44Z"
}
GHSA-XRRM-R8X3-WH4P
Vulnerability from github – Published: 2025-01-30 18:32 – Updated: 2025-01-30 18:32In versions 3.1.0 and lower of the Splunk Supporting Add-on for Active Directory, also known as SA-ldapsearch, a vulnerable regular expression pattern could lead to a Regular Expression Denial of Service (ReDoS) attack.
{
"affected": [],
"aliases": [
"CVE-2025-0367"
],
"database_specific": {
"cwe_ids": [
"CWE-1333"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-01-30T17:15:18Z",
"severity": "MODERATE"
},
"details": "In versions 3.1.0 and lower of the Splunk Supporting Add-on for Active Directory, also known as SA-ldapsearch, a vulnerable regular expression pattern could lead to a Regular Expression Denial of Service (ReDoS) attack.",
"id": "GHSA-xrrm-r8x3-wh4p",
"modified": "2025-01-30T18:32:08Z",
"published": "2025-01-30T18:32:08Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-0367"
},
{
"type": "WEB",
"url": "https://advisory.splunk.com/advisories/SVD-2025-0103"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-XRX9-GJ26-5WX9
Vulnerability from github – Published: 2022-10-07 07:33 – Updated: 2022-10-07 07:33Impact
Inefficient regular expression complexity of lowercase() and uppercase() regex could lead to a denial of service attack. With a formed payload 'a' + 'a'.repeat(i) + 'A', only 32 characters payload could take 29443 ms time execution when testing lowercase(). The same issue happens with uppercase().
Patches
v1.5.1
References
huntr.dev report Regular Expression Denial of Service (ReDoS) and Catastrophic Backtracking
For more information
If you have any questions or comments about this advisory: * Open an issue in v8n issues list * Email us at brunodev02221@gmail.com
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "v8n"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.5.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2022-35923"
],
"database_specific": {
"cwe_ids": [
"CWE-1333",
"CWE-400"
],
"github_reviewed": true,
"github_reviewed_at": "2022-10-07T07:33:44Z",
"nvd_published_at": "2022-08-02T20:15:00Z",
"severity": "HIGH"
},
"details": "### Impact\nInefficient regular expression complexity of `lowercase()` and `uppercase()` regex could lead to a denial of service attack. With a formed payload `\u0027a\u0027 + \u0027a\u0027.repeat(i) + \u0027A\u0027`, only 32 characters payload could take 29443 ms time execution when testing `lowercase()`. The same issue happens with `uppercase()`.\n\n### Patches\nv1.5.1\n\n### References\n[huntr.dev report](https://huntr.dev/bounties/2d92f644-593b-43b4-bfd1-c8042ac60609)\n[_Regular Expression Denial of Service (ReDoS) and Catastrophic Backtracking_](https://snyk.io/blog/redos-and-catastrophic-backtracking/)\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [v8n issues list](https://github.com/imbrn/v8n)\n* Email us at [brunodev02221@gmail.com](mailto:brunodev02221@gmail.com)\n",
"id": "GHSA-xrx9-gj26-5wx9",
"modified": "2022-10-07T07:33:44Z",
"published": "2022-10-07T07:33:44Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/imbrn/v8n/security/advisories/GHSA-xrx9-gj26-5wx9"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-35923"
},
{
"type": "WEB",
"url": "https://github.com/imbrn/v8n/commit/92393862156fad190c05ec3f6e2bc73308dcd2f9"
},
{
"type": "PACKAGE",
"url": "https://github.com/imbrn/v8n"
},
{
"type": "WEB",
"url": "https://huntr.dev/bounties/2d92f644-593b-43b4-bfd1-c8042ac60609"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "v8n vulnerable to Inefficient Regular Expression Complexity"
}
GHSA-XX4C-JJ58-R7X6
Vulnerability from github – Published: 2021-11-19 20:14 – Updated: 2022-07-12 00:11Impact
Versions of validator prior to 13.7.0 are affected by an inefficient Regular Expression complexity when using the rtrim and trim sanitizers.
Patches
The problem has been patched in validator 13.7.0
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "validator"
},
"ranges": [
{
"events": [
{
"introduced": "11.1.0"
},
{
"fixed": "13.7.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [],
"database_specific": {
"cwe_ids": [
"CWE-1333"
],
"github_reviewed": true,
"github_reviewed_at": "2021-11-08T21:27:48Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "### Impact\nVersions of `validator` prior to 13.7.0 are affected by an inefficient Regular Expression complexity when using the `rtrim` and `trim` sanitizers.\n\n### Patches\nThe problem has been patched in validator 13.7.0",
"id": "GHSA-xx4c-jj58-r7x6",
"modified": "2022-07-12T00:11:53Z",
"published": "2021-11-19T20:14:23Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/validatorjs/validator.js/security/advisories/GHSA-xx4c-jj58-r7x6"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2021-3765"
},
{
"type": "WEB",
"url": "https://github.com/validatorjs/validator.js/issues/1599"
},
{
"type": "WEB",
"url": "https://github.com/validatorjs/validator.js/pull/1738"
},
{
"type": "PACKAGE",
"url": "https://github.com/validatorjs/validator.js"
},
{
"type": "WEB",
"url": "https://huntr.dev/bounties/c37e975c-21a3-4c5f-9b57-04d63b28cfc9"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L",
"type": "CVSS_V3"
}
],
"summary": "Inefficient Regular Expression Complexity in Validator.js"
}
GHSA-XX4V-PRFH-6CGC
Vulnerability from github – Published: 2025-02-14 17:58 – Updated: 2025-02-14 23:07Summary
A Regular Expression Denial of Service (ReDoS) vulnerability exists in the processing of HTTP request headers. By sending an authorization header containing an excessively long sequence of spaces followed by a newline and "@", an attacker can exploit inefficient regular expression processing, leading to excessive resource consumption. This can significantly degrade server performance or cause a denial-of-service (DoS) condition, impacting availability.
Details
The issue occurs at line 52 of iterator.ts in the @octokit/request-error repository.
The vulnerability is caused by the use of an inefficient regular expression in the handling of the authorization header within the request processing logic:
authorization: options.request.headers.authorization.replace(
/ .*$/,
" [REDACTED]"
)
The regular expression / .*$/ matches a space followed by any number of characters until the end of the line. This pattern is vulnerable to Regular Expression Denial of Service (ReDoS) when processing specially crafted input. Specifically, an attacker can send an authorization header containing a long sequence of spaces followed by a newline and "@", such as:
headers: {
authorization: "" + " ".repeat(100000) + "\n@",
}
Due to the way JavaScript's regular expression engine backtracks while attempting to match the space followed by arbitrary characters, this input can cause excessive CPU usage, significantly slowing down or even freezing the server. This leads to a denial-of-service condition, impacting availability.
PoC
The gist of PoC.js 1. run npm i @octokit/request-error 2. run 'node poc.js' result: 3. then the program will stuck forever with high CPU usage
import { RequestError } from "@octokit/request-error";
const error = new RequestError("Oops", 500, {
request: {
method: "POST",
url: "https://api.github.com/foo",
body: {
bar: "baz",
},
headers: {
authorization: ""+" ".repeat(100000)+"\n@",
},
},
response: {
status: 500,
url: "https://api.github.com/foo",
headers: {
"x-github-request-id": "1:2:3:4",
},
data: {
foo: "bar",
},
},
});
Impact
Vulnerability Type & Impact:
This is a Regular Expression Denial of Service (ReDoS) vulnerability, which occurs due to an inefficient regular expression (/ .*$/) used to sanitize the authorization header. An attacker can craft a malicious input that triggers excessive backtracking in the regex engine, leading to high CPU consumption and potential denial-of-service (DoS).
Who is Impacted?
- Projects or services using this code to process HTTP headers are vulnerable.
- Applications that rely on user-supplied
authorizationheaders are at risk, especially those processing a large volume of authentication requests. - Multi-tenant or API-driven platforms could experience degraded performance or service outages if exploited at scale.
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "@octokit/request-error"
},
"ranges": [
{
"events": [
{
"introduced": "1.0.0"
},
{
"fixed": "5.1.1"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"package": {
"ecosystem": "npm",
"name": "@octokit/request-error"
},
"ranges": [
{
"events": [
{
"introduced": "6.0.0"
},
{
"fixed": "6.1.7"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2025-25289"
],
"database_specific": {
"cwe_ids": [
"CWE-1333"
],
"github_reviewed": true,
"github_reviewed_at": "2025-02-14T17:58:54Z",
"nvd_published_at": "2025-02-14T20:15:35Z",
"severity": "MODERATE"
},
"details": "### Summary\nA Regular Expression Denial of Service (ReDoS) vulnerability exists in the processing of HTTP request headers. By sending an authorization header containing an excessively long sequence of spaces followed by a newline and \"@\", an attacker can exploit inefficient regular expression processing, leading to excessive resource consumption. This can significantly degrade server performance or cause a denial-of-service (DoS) condition, impacting availability.\n### Details\nThe issue occurs at [line 52](https://github.com/octokit/request-error.js/blob/main/src/index.ts) of iterator.ts in the @octokit/request-error repository.\nThe vulnerability is caused by the use of an inefficient regular expression in the handling of the `authorization` header within the request processing logic:\n```js\nauthorization: options.request.headers.authorization.replace(\n / .*$/, \n \" [REDACTED]\"\n)\n```\nThe regular expression `/ .*$/` matches a space followed by any number of characters until the end of the line. This pattern is vulnerable to Regular Expression Denial of Service (ReDoS) when processing specially crafted input. Specifically, an attacker can send an `authorization` header containing a long sequence of spaces followed by a newline and \"@\", such as:\n```js\nheaders: {\n authorization: \"\" + \" \".repeat(100000) + \"\\n@\",\n}\n```\nDue to the way JavaScript\u0027s regular expression engine backtracks while attempting to match the space followed by arbitrary characters, this input can cause excessive CPU usage, significantly slowing down or even freezing the server. This leads to a denial-of-service condition, impacting availability.\n### PoC\n[The gist of PoC.js](https://gist.github.com/ShiyuBanzhou/e1203ad22701fd043b8501eb37676a0d)\n1. run npm i @octokit/request-error\n2. run \u0027node poc.js\u0027\nresult:\n3. then the program will stuck forever with high CPU usage\n```js\nimport { RequestError } from \"@octokit/request-error\";\n\nconst error = new RequestError(\"Oops\", 500, {\n request: {\n method: \"POST\",\n url: \"https://api.github.com/foo\",\n body: {\n bar: \"baz\",\n },\n headers: {\n authorization: \"\"+\" \".repeat(100000)+\"\\n@\",\n },\n },\n response: {\n status: 500,\n url: \"https://api.github.com/foo\",\n headers: {\n \"x-github-request-id\": \"1:2:3:4\",\n },\n data: {\n foo: \"bar\",\n },\n },\n});\n```\n\n### Impact\n#### Vulnerability Type \u0026 Impact:\nThis is a `Regular Expression Denial of Service (ReDoS) vulnerability`, which occurs due to an inefficient regular expression (`/ .*$/`) used to sanitize the `authorization` header. An attacker can craft a malicious input that triggers excessive backtracking in the regex engine, leading to high CPU consumption and potential denial-of-service (DoS).\n#### Who is Impacted?\n* Projects or services using this code to process HTTP headers are vulnerable.\n* Applications that rely on user-supplied `authorization` headers are at risk, especially those processing a large volume of authentication requests.\n* Multi-tenant or API-driven platforms could experience degraded performance or service outages if exploited at scale.",
"id": "GHSA-xx4v-prfh-6cgc",
"modified": "2025-02-14T23:07:29Z",
"published": "2025-02-14T17:58:54Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/octokit/request-error.js/security/advisories/GHSA-xx4v-prfh-6cgc"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-25289"
},
{
"type": "WEB",
"url": "https://github.com/octokit/request-error.js/commit/d558320874a4bc8d356babf1079e6f0056a59b9e"
},
{
"type": "PACKAGE",
"url": "https://github.com/octokit/request-error.js"
},
{
"type": "WEB",
"url": "https://github.com/octokit/request-error.js/blob/main/src/index.ts"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L",
"type": "CVSS_V3"
}
],
"summary": "@octokit/request-error has a Regular Expression in index that Leads to ReDoS Vulnerability Due to Catastrophic Backtracking"
}
Mitigation
Use regular expressions that do not support backtracking, e.g. by removing nested quantifiers.
Mitigation
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.
Mitigation
Do not use regular expressions with untrusted input. If regular expressions must be used, avoid using backtracking in the expression.
Mitigation
Limit the length of the input that the regular expression will process.
CAPEC-492: Regular Expression Exponential Blowup
An adversary may execute an attack on a program that uses a poor Regular Expression(Regex) implementation by choosing input that results in an extreme situation for the Regex. A typical extreme situation operates at exponential time compared to the input size. This is due to most implementations using a Nondeterministic Finite Automaton(NFA) state machine to be built by the Regex algorithm since NFA allows backtracking and thus more complex regular expressions.