How to fix a ReDoS
Blog post from GitHub
ReDoS (Regular Expression Denial of Service) vulnerabilities, although often deemed less severe, pose significant challenges due to their obscure nature and the complexities involved in fixing them. They are typically the result of inefficiencies in regex engines rather than developer errors, leading to exponential runtimes on certain inputs, particularly in languages like Python and JavaScript. CodeQL queries, improved by Erik Kristensen in 2021, have made detecting these vulnerabilities easier, though remediation remains manual and often involves altering minimal characters in the regex. The blog post, authored by Kevin Backhouse from GitHub Security Lab, provides insights into the history and spread of ReDoS vulnerabilities via shared regex patterns, and emphasizes methodology for identifying and fixing such issues, including creating a proof of concept, simplifying problematic regexes, and employing fuzz testing for verification. Backhouse shares his personal experiences in reporting and remediating these vulnerabilities, highlighting successful strategies such as submitting public pull requests when maintainers are unresponsive. Despite the challenges posed by ReDoS, advancements in code scanning and regex engine improvements in certain languages offer hope for reducing their prevalence in the future.