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

fix: Regular expression injection #248

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

Conversation

odaysec
Copy link

@odaysec odaysec commented Feb 26, 2025

fix vulnerable in #247

To fix the problem, we need to sanitize the user input before using it to construct the regular expression. The best way to do this is by using the _.escapeRegExp function from the lodash library, which escapes special characters in the input string. This ensures that the user cannot insert characters that have special meaning in regular expressions.

  1. Install the lodash package if it is not already installed.
  2. Import the lodash library in the file.
  3. Use the _.escapeRegExp function to sanitize the config.exclude_regex before constructing the regular expression.

Suggested fixes powered by Zeroday Operation Research LLC.

References

OWASP: Regular expression Denial of Service - ReDoS
Wikipedia: ReDoS
npm: lodash
Common Weakness Enumeration: CWE-730
Common Weakness Enumeration: CWE-400

@c-nixon
Copy link

c-nixon commented Feb 26, 2025

Thanks for the PR, this repository is no longer maintained.

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