Skip to content

Commit 8fa151a

Browse files
committed
docs: add warning about ReDoS
1 parent 71b78a2 commit 8fa151a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,43 @@ This is the matching library used internally by npm.
77
It works by converting glob expressions into JavaScript `RegExp`
88
objects.
99

10+
## Important Security Consideration!
11+
12+
> [!WARNING]
13+
> This library uses JavaScript regular expressions. Please read
14+
> the following warning carefully, and be thoughtful about what
15+
> you provide to this library in production systems.
16+
17+
_Any_ library in JavaScript that deals with matching string
18+
patterns using regular expressions will be subject to
19+
[ReDoS](https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS)
20+
if the pattern is generated using untrusted input.
21+
22+
Efforts have been made to mitigate risk as much as is feasible in
23+
such a library, providing maximum recursion depths and so forth,
24+
but these measures can only ultimately protect against accidents,
25+
not malice. A dedicated attacker can _always_ find patterns that
26+
cannot be defended against by a bash-compatible glob pattern
27+
matching system that uses JavaScript regular expressions.
28+
29+
To be extremely clear:
30+
31+
> [!WARNING]
32+
> **If you create a system where you take user input, and use
33+
> that input as the source of a Regular Expression pattern, in
34+
> this or any extant glob matcher in JavaScript, you will be
35+
> pwned.**
36+
37+
A future version of this library _may_ use a different matching
38+
algorithm which does not exhibit backtracking problems. If and
39+
when that happens, it will likely be a sweeping change, and those
40+
improvements will **not** be backported to legacy versions.
41+
42+
In the near term, it is not reasonable to continue to play
43+
whack-a-mole with security advisories, and so any future ReDoS
44+
reports will be considered "working as intended", and resolved
45+
entirely by this warning.
46+
1047
## Usage
1148

1249
```js

0 commit comments

Comments
 (0)