Is it safe to use user's RegEx?
I want to add a feature to my website to let users search the texts with RegEx . But, is it safe to let the users do something like that ? preg_match('/' . $user_input_regex . '/', $subject); There is a possible attack on this code called a ReDoS attack (Regular expression Denial of Service). The Regular expression Denial of Service (ReDoS) is a Denial of Service attack, that exploits the fact that most Regular Expression implementations may reach extreme situations that cause them to work very slowly (exponentially related to input size). An attacker can then cause a program using a Regular