Skip to content

Commit bd25942

Browse files
committed
docs: add warning about ReDoS
1 parent 1a9c27c commit bd25942

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
@@ -10,6 +10,43 @@ This is the matching library used internally by npm.
1010
It works by converting glob expressions into JavaScript `RegExp`
1111
objects.
1212

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

1552
```javascript

0 commit comments

Comments
 (0)