logdna-agent
logdna-agent copied to clipboard
fix: Regular expression injection
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.
- Install the lodash package if it is not already installed.
- Import the lodash library in the file.
- Use the
_.escapeRegExpfunction to sanitize theconfig.exclude_regexbefore 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
Thanks for the PR, this repository is no longer maintained.