Skip to content

Conversation

@pavelzotikov
Copy link
Contributor

Summary

Integrated safe-regex library to validate user-provided regular expressions and prevent potential ReDoS (Regular Expression Denial of Service) vulnerabilities.

Changes

  • Added safe-regex to check the safety of user-generated search regex patterns.
  • If the input regex is considered unsafe (exponential-time), the search will be rejected or skipped.
  • Improves overall stability and security of the search endpoint.

Motivation

User input passed to $regex can introduce catastrophic backtracking. This change ensures that only safe regex patterns are used in database queries.

Notes

  • The validation runs before executing the MongoDB query.

@pavelzotikov pavelzotikov requested a review from neSpecc July 11, 2025 15:27
@pavelzotikov pavelzotikov merged commit cd4e426 into master Jul 11, 2025
6 of 10 checks passed
@pavelzotikov pavelzotikov deleted the chore-add-safe-regex-in-search branch July 11, 2025 15:43
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.

4 participants