Exploring Motif-based Heterogeneous Graph Learning for ReDoS Detection
Abstract
Lay Summary
Regular expressions (regexes) are widely used in real-world software to search, validate, and filter text. However, vulnerable regexes may exhibit super-linear worst-case behavior in regex engines when matched against carefully crafted inputs, leading to Regex Denial-of-Service (ReDoS) attacks. We propose an effective graph-based learning method to efficiently identify potentially vulnerable regexes. Our paper presents ReDoS-MotifGNN, which converts real-world regexes into Heterogeneous Regex Graphs (HRGs). This representation preserves the structure of real-world regexes, including extended features commonly used in practice. To incorporate domain knowledge, we further enrich these graphs with ReDoS-related prior information, allowing the model to consider high-level vulnerable structures during learning. The model then learns the HRG representations by jointly modeling local structural information and high-level vulnerable structures through attention-based fusion. Our findings demonstrate the potential of graph-based learning methods for ReDoS detection. They suggest that structure-aware learning can effectively model the structural characteristics of vulnerable real-world regexes, offering a practical way to detect ReDoS vulnerabilities in real-time scenarios.