Skip to content

Fix ReDoS in numeric option value detection - #80

Open
Hashim1999164 wants to merge 1 commit into
vercel:mainfrom
Hashim1999164:fix/redos-number-looks-like
Open

Hashim1999164 wants to merge 1 commit into
vercel:mainfrom
Hashim1999164:fix/redos-number-looks-like

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Sep 4, 2026 •

Copy link
Copy Markdown

Fixes #70

The previous pattern used overlapping optional digit runs with a lookahead, which backtracks badly on long non matching strings that start with a dash. That path runs for every option value that begins with -, including String options, so a crafted argv entry can stall parsing.

This switches to an equivalent check that accepts the same shapes (optional leading dash, digits, optional fractional part with at least one digit) without that nested ambiguity. Existing negative number option parsing still works, and a regression test covers a long non numeric value completing quickly.

Replace the nested digit regex with an equivalent pattern that does not
backtrack on long non matching input. Keeps negative and decimal number
option values working.
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.

ReDoS vulnerability in index.js

1 participant