ReDoS is a well-known type of algorithmic complexity attack, where an adversary supplies maliciously crafted strings to a regular expression matching engine, aiming to exhaust computational resources of systems. Even quadratic-time behavior in matching engines has been exploited in successful attacks, as exemplified by major outages at Stack Overflow (2016) and Cloudflare (2019). These incidents motivate a fundamental question: Is it possible to construct matching engines that are provably efficient, running in (near-)linear time in the length of the input string? For classical regular expressions (REGEX), Thompson's construction yields a linear-time algorithm. However, practical engines support powerful features such as backreferences, which strictly extend the expressive power of REGEX but unfortunately increase the risk of ReDoS attacks. This paper investigates the fine-grained complexity of the string matching problem for regular expressions with backreferences (REWBs). Specifically, we consider $r$-use $k$-REWBs. On the hardness side, we show that the string matching problem for $k$-REWBs cannot be solved in $O(n^{2k-ε})$ time for any $ε> 0$ under SETH. We also prove that this problem is \textbf{W[2]}-hard when parameterized by the length of the REWB expression, strengthening the previous \textbf{W[1]}-hardness. Moreover, we prove that this problem for $2$-use $2$-REWBs cannot be solved in $n^{1+o(1)}$ time unless the triangle detection problem can be solved in that time. On the algorithmic side, we present an $O(n \log^2 n)$-time algorithm for $1$-use REWBs, which significantly improves upon the recent $O(n^2)$-time algorithm by Nogami and Terauchi (MFCS, 2025). Our algorithm employs several techniques including suffix trees, transition monoids of REGEXes, factorization forest data structures, and periodicity of strings.


翻译:ReDoS是一种众所周知的算法复杂度攻击类型,攻击者通过向正则表达式匹配引擎注入精心构造的字符串,旨在耗尽系统计算资源。即使匹配引擎中表现出二次时间复杂度,也能成功实施攻击,例如Stack Overflow(2016年)和Cloudflare(2019年)的重大故障事件。这些事件引发了一个根本性问题:是否可能构建可证明高效的匹配引擎,使其运行时间与输入字符串长度呈(近)线性关系?对于经典正则表达式(REGEX),汤普森构造法可提供线性时间算法。然而,实际引擎支持回溯引用等强大功能,这严格扩展了REGEX的表达能力,但也增加了ReDoS攻击的风险。本文研究了含回溯引用正则表达式(REWB)字符串匹配问题的细粒度复杂度。具体而言,我们考虑$r$次使用$k$-REWB。在难度方面,我们证明在SETH假设下,$k$-REWB的字符串匹配问题无法在$O(n^{2k-ε})$时间内求解(对任意$ε> 0$)。我们还证明,当以REWB表达式长度为参数时,该问题属于\textbf{W[2]}-难问题,强化了此前的\textbf{W[1]}-难结论。此外,我们证明了$2$次使用$2$-REWB的匹配问题无法在$n^{1+o(1)}$时间内求解,除非三角形检测问题能在相同时间内解决。在算法方面,我们为$1$次使用REWB提出了一种$O(n \log^2 n)$时间复杂度的算法,显著改进了Nogami和Terauchi(MFCS, 2025)近期提出的$O(n^2)$时间复杂度算法。我们的算法综合运用了后缀树、正则表达式迁移幺半群、因子化森林数据结构及字符串周期性等多种技术。

0
下载
关闭预览

相关内容

正则表达式(Regular Expression,一般简写为RegEx或者RegExp),也译为正规表示法、常规表示法,台湾译「规则运算式」,在计算机科学中,是指一个用来描述或者匹配一系列符合某个句法规则的字符串的单个字符串。
论学习、公平性与复杂度
专知会员服务
11+阅读 · 2月28日
物理引导的深度学习研究综述:进展、挑战和展望
专知会员服务
30+阅读 · 2025年5月11日
结合知识增强的大型语言模型复杂问题求解综述
专知会员服务
16+阅读 · 2025年5月7日
神经图推理:复杂逻辑查询回答的综述
专知会员服务
28+阅读 · 2024年12月10日
综述:军事应用中使用的一些重要算法
专知
13+阅读 · 2022年7月3日
【深度语义匹配模型】原理篇二:交互篇
AINLP
16+阅读 · 2020年5月18日
重磅发布:基于 PyTorch 的深度文本匹配工具 MatchZoo-py
中国科学院网络数据重点实验室
16+阅读 · 2019年8月26日
深度文本匹配开源工具(MatchZoo)
机器学习研究会
10+阅读 · 2017年12月5日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 4月6日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
7+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
7+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
5+阅读 · 6月17日
相关VIP内容
论学习、公平性与复杂度
专知会员服务
11+阅读 · 2月28日
物理引导的深度学习研究综述:进展、挑战和展望
专知会员服务
30+阅读 · 2025年5月11日
结合知识增强的大型语言模型复杂问题求解综述
专知会员服务
16+阅读 · 2025年5月7日
神经图推理:复杂逻辑查询回答的综述
专知会员服务
28+阅读 · 2024年12月10日
相关基金
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员