Skip to content

Security: Regex Denial of Service (ReDoS) via ignore-watch option#901

Open
tomaioo wants to merge 1 commit into
fastify:mainfrom
tomaioo:fix/security/regex-denial-of-service-redos-via-ignore
Open

Security: Regex Denial of Service (ReDoS) via ignore-watch option#901
tomaioo wants to merge 1 commit into
fastify:mainfrom
tomaioo:fix/security/regex-denial-of-service-redos-via-ignore

Conversation

@tomaioo

@tomaioo tomaioo commented Jul 20, 2026

Copy link
Copy Markdown

Summary

Security: Regex Denial of Service (ReDoS) via ignore-watch option

Problem

Severity: Medium | File: lib/watch/utils.js:L5

The arrayToRegExp function in lib/watch/utils.js constructs a regular expression from an array of strings. If a user passes specially crafted strings via the --ignore-watch CLI argument or the ignoreWatch configuration option, it can lead to catastrophic backtracking (ReDoS) and cause the application to hang.

Solution

Escape user-supplied strings before injecting them into the RegExp constructor. You can use a library like escape-string-regexp or manually escape special regex characters.

Changes

  • lib/watch/utils.js (modified)

The `arrayToRegExp` function in `lib/watch/utils.js` constructs a regular expression from an array of strings. If a user passes specially crafted strings via the `--ignore-watch` CLI argument or the `ignoreWatch` configuration option, it can lead to catastrophic backtracking (ReDoS) and cause the application to hang.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening a PR! Can you please add a unit test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants