Using Selective Memoization to Defeat Regular Expression Denial of Service (ReDoS)
摘要
Regular expressions (regexes) are a denial of service vector in most mainstream programming languages. Recent empirical work has demonstrated that up to 10% of regexes have super-linear worst-case behavior in typical regex engines. It is therefore not surprising that many web services are reportedly vulnerable to regex denial of service (ReDoS). If the time complexity of a regex engine can be reduced transparently, ReDoS vulnerabilities can be eliminated at no cost to application developers. Unfortunately, existing ReDoS defenses — replacing the regex engine, optimizing it, or replacing regexes piecemeal — struggle with soundness and compatibility. Full memoization is sound and compatible, but its space costs are too high. No effective ReDoS defense has been adopted in practice. We present techniques to provably eliminate super-linear regex behavior with low space costs for typical regexes. We propose selective memoization schemes with varying space/time tradeoffs. We then describe an encoding scheme that leverages insights about regex engine semantics to further reduce the space cost of memoization. We also consider how to safely handle extended regex features. We implemented our proposals and evaluated them on a corpus of real-world regexes. We found that selective memoization lowers the space cost of memoization by an order of magnitude for the median regex, and that run-length encoding further lowers the space cost to constant for 90% of regexes. "Those who cannot remember the past are condemned to repeat it." –George Santayana
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 14 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Repairing DoS Vulnerability of Real-World Regexes 引用了 Freezing the Web: A Study of ReDoS Vulnerabilities in JavaScript-based Web Servers
- Exploiting Input Sanitization for Regex Denial of Service 引用了 A Sense of Time for JavaScript and Node.js: First-Class Timeouts as a Cure for Event Handler Poisoning
- Exploiting Input Sanitization for Regex Denial of Service 引用了 Freezing the Web: A Study of ReDoS Vulnerabilities in JavaScript-based Web Servers
- Exploiting Input Sanitization for Regex Denial of Service 引用了 Runtime Recovery of Web Applications under Zero-Day ReDoS Attacks
- SecBench.js: An Executable Security Benchmark Suite for Server-Side JavaScript 引用了 A Sense of Time for JavaScript and Node.js: First-Class Timeouts as a Cure for Event Handler Poisoning
- SecBench.js: An Executable Security Benchmark Suite for Server-Side JavaScript 引用了 Freezing the Web: A Study of ReDoS Vulnerabilities in JavaScript-based Web Servers
- SecBench.js: An Executable Security Benchmark Suite for Server-Side JavaScript 引用了 Runtime Recovery of Web Applications under Zero-Day ReDoS Attacks
- A Sense of Time for JavaScript and Node.js: First-Class Timeouts as a Cure for Event Handler Poisoning 引用了 Freezing the Web: A Study of ReDoS Vulnerabilities in JavaScript-based Web Servers
- Runtime Recovery of Web Applications under Zero-Day ReDoS Attacks 引用了 A Sense of Time for JavaScript and Node.js: First-Class Timeouts as a Cure for Event Handler Poisoning
- Runtime Recovery of Web Applications under Zero-Day ReDoS Attacks 引用了 Freezing the Web: A Study of ReDoS Vulnerabilities in JavaScript-based Web Servers
- ReDoSHunter: A Combined Static and Dynamic Approach for Regular Expression DoS Detection 引用了 Freezing the Web: A Study of ReDoS Vulnerabilities in JavaScript-based Web Servers
引用它的顶会 Paper14
- SecBench.js: An Executable Security Benchmark Suite for Server-Side JavaScriptMasudul Hasan Masud Bhuiyan, Adithya Srinivas Parthasarathy, Nikos Vasilakis, Michael Pradel 等ICSE 2023 · 20 次引用
- ReDoSHunter: A Combined Static and Dynamic Approach for Regular Expression DoS DetectionYeting Li, Zixuan Chen, Jialun Cao, Zhiwu Xu 等USENIX Security 2021 · 20 次引用
- Runtime Recovery of Web Applications under Zero-Day ReDoS AttacksZhihao Bai, Ke Wang, Hang Zhu, Yinzhi Cao 等S&P 2021 · 19 次引用
- Exploiting Input Sanitization for Regex Denial of ServiceEfe Barlas, Xin Du, James C. DavisICSE 2022 · 16 次引用
- Repairing DoS Vulnerability of Real-World RegexesNariyoshi Chida, Tachio TerauchiS&P 2022 · 15 次引用
它引用的 Paper2
- Freezing the Web: A Study of ReDoS Vulnerabilities in JavaScript-based Web ServersCristian-Alexandru Staicu, Michael PradelUSENIX Security 2018 · 125 次引用
- A Sense of Time for JavaScript and Node.js: First-Class Timeouts as a Cure for Event Handler PoisoningJames C. Davis, Eric R. Williamson, Dongyoon LeeUSENIX Security 2018 · 54 次引用
相关 Paper
- FlashRegex: Deducing Anti-ReDoS Regexes from ExamplesYeting Li, Zhiwu Xu, Jialun Cao, Haiming Chen 等ASE 2020 · 17 次引用
- Revealer: Detecting and Exploiting Regular Expression Denial-of-Service VulnerabilitiesYinxi Liu, Mingxue Zhang, Wei MengS&P 2021 · 28 次引用
- Improving Developers' Understanding of Regex Denial of Service Tools through Anti-Patterns and Fix StrategiesSk Adnan Hassan, Zainab Aamir, Dongyoon Lee, James C. Davis 等S&P 2023
- Towards an Effective Method of ReDoS Detection for Non-backtracking EnginesWeihao Su, Hong Huang, Rongchen Li, Haiming Chen 等USENIX Security 2024 · 4 次引用
- Regulator: Dynamic Analysis to Detect ReDoSRobert McLaughlin, Fabio Pagani, Noah Spahn, Christopher Kruegel 等USENIX Security 2022
