Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit digit matches to mitigate ReDoS vulnerabilities #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maxcbc
Copy link

@maxcbc maxcbc commented Dec 4, 2017

  • Replaced use of \d+ with \d{0,16}

This should in theory go some way to mitigate ReDoS issues listed in #10 by limiting the number of matches to the length of the MAX_SAFE_INTEGER.

- Replaced use of `\d+` with `\d{0,16}`
@maxcbc maxcbc force-pushed the limit_digit_matches_to_max_safe_integer branch from 082d077 to 35b28be Compare December 4, 2017 14:25
Copy link

@tiffon tiffon left a comment

Choose a reason for hiding this comment

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

Thanks for creating this PR! 🎉

One comment: The \d{0,16} should be \d{1,16} in order to approximate the \d+ as opposed to \d*.

console.log([
null === ':::'.match(/^(\d+):(\d+):(\d+):(\d+)(\.\d+)?/),
null === ':::'.match(/^(\d{0,16}):(\d{0,16}):(\d{0,16}):(\d{0,16})(\.\d{0,16})?/),
null === ':::'.match(/^(\d{1,16}):(\d{1,16}):(\d{1,16}):(\d{1,16})(\.\d{1,16})?/),
])
// -> [true, false, true]

@indexzero Any chance this can get republished after the above adjustment is made?

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