Lune

PLDI2024Top-tier venue

Linear Matching of JavaScript Regular Expressions

Aurèle Barrière, Clément Pit-Claudel

Abstract

Modern regex languages have strayed far from well-understood traditional regular expressions: they include features that fundamentally transform the matching problem. In exchange for these features, modern regex engines at times suffer from exponential complexity blowups, a frequent source of denial-of-service vulnerabilities in JavaScript applications. Worse, regex semantics differ across languages, and the impact of these divergences on algorithmic design and worst-case matching complexity has seldom been investigated.

This paper provides a novel perspective on JavaScript's regex semantics by identifying a larger-thanpreviously-understood subset of the language that can be matched with linear time guarantees. In the process, we discover several cases where state-of-the-art algorithms were either wrong (semantically incorrect), inefficient (suffering from superlinear complexity) or excessively restrictive (assuming certain features could not be matched linearly). We introduce novel algorithms to restore correctness and linear complexity. We further advance the state-of-the-art in linear regex matching by presenting the first nonbacktracking algorithms for matching lookarounds in linear time: one supporting captureless lookbehinds in any regex language, and another leveraging a JavaScript property to support unrestricted lookaheads and lookbehinds. Finally, we describe new time and space complexity tradeoffs for regex engines. All of our algorithms are practical: we validated them in a prototype implementation, and some have also been merged in the V8 JavaScript implementation used in Chrome and Node.js.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

5 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Towards Efficient Matching of Regexes with Backreferences using Register Set Automata cites RE#: High Performance Derivative-Based Regex Matching with Intersection, Complement, and Restricted Lookarounds
  • Towards Efficient Matching of Regexes with Backreferences using Register Set Automata cites Regex matching with counting-set automata
  • Towards Efficient Matching of Regexes with Backreferences using Register Set Automata cites Revealer: Detecting and Exploiting Regular Expression Denial-of-Service Vulnerabilities
  • Efficient Algorithms for the Uniform Tokenization Problem cites Regular Expression Matching using Bit Vector Automata
  • RE#: High Performance Derivative-Based Regex Matching with Intersection, Complement, and Restricted Lookarounds cites Regex matching with counting-set automata
  • RE#: High Performance Derivative-Based Regex Matching with Intersection, Complement, and Restricted Lookarounds cites Regular Expression Matching using Bit Vector Automata
  • Regex Decision Procedures in Extended RE# cites RE#: High Performance Derivative-Based Regex Matching with Intersection, Complement, and Restricted Lookarounds
  • Revealer: Detecting and Exploiting Regular Expression Denial-of-Service Vulnerabilities cites Freezing the Web: A Study of ReDoS Vulnerabilities in JavaScript-based Web Servers
  • Regular Expression Matching using Bit Vector Automata cites Regex matching with counting-set automata
  • Formal Verification for JavaScript Regular Expressions: A Proven Mechanized Semantics and Its Applications cites RE#: High Performance Derivative-Based Regex Matching with Intersection, Complement, and Restricted Lookarounds
  • Formal Verification for JavaScript Regular Expressions: A Proven Mechanized Semantics and Its Applications cites Freezing the Web: A Study of ReDoS Vulnerabilities in JavaScript-based Web Servers
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers5

  1. RE#: High Performance Derivative-Based Regex Matching with Intersection, Complement, and Restricted LookaroundsIan Erik Varatalu, Margus Veanes, Juhan P. ErnitsPOPL 2025 · 9 citations
  2. Efficient Algorithms for the Uniform Tokenization ProblemAngela W. Li, Konstantinos MamourasOOPSLA 2025 · 3 citations
  3. Regex Decision Procedures in Extended RE#Ian Erik Varatalu, Margus Veanes, Ekaterina Zhuchko, Juhan P. ErnitsCAV 2025 · 3 citations
  4. Towards Efficient Matching of Regexes with Backreferences using Register Set AutomataVojtech Havlena, Lukás Holík, Ondrej Lengál, Jan Vasák et al.PLDI 2026
  5. Formal Verification for JavaScript Regular Expressions: A Proven Mechanized Semantics and Its ApplicationsAurèle Barrière, Victor Deng, Clément Pit-ClaudelPOPL 2026

Builds on9

  1. Freezing the Web: A Study of ReDoS Vulnerabilities in JavaScript-based Web ServersCristian-Alexandru Staicu, Michael PradelUSENIX Security 2018 · 125 citations
  2. Using Selective Memoization to Defeat Regular Expression Denial of Service (ReDoS)James C. Davis, Francisco Servant, Dongyoon LeeS&P 2021 · 43 citations
  3. Revealer: Detecting and Exploiting Regular Expression Denial-of-Service VulnerabilitiesYinxi Liu, Mingxue Zhang, Wei MengS&P 2021 · 28 citations
  4. Regex matching with counting-set automataLenka Turonová, Lukás Holík, Ondrej Lengál, Olli Saarikivi et al.OOPSLA 2020 · 22 citations
  5. Regular Expression Matching using Bit Vector AutomataAlexis Le Glaunec, Lingkun Kong, Konstantinos MamourasOOPSLA 2023 · 22 citations

Related papers

  1. Efficient Matching of Regular Expressions with Lookaround AssertionsKonstantinos Mamouras, Agnishom ChattopadhyayPOPL 2024 · 19 citations
  2. Repairing DoS Vulnerability of Real-World RegexesNariyoshi Chida, Tachio TerauchiS&P 2022 · 15 citations
  3. Exploring Motif-based Heterogeneous Graph Learning for ReDoS DetectionHong Huang, Chengyu Yao, Rongchen Li, Weihao Su et al.ICML 2026
  4. ReDoSHunter: A Combined Static and Dynamic Approach for Regular Expression DoS DetectionYeting Li, Zixuan Chen, Jialun Cao, Zhiwu Xu et al.USENIX Security 2021 · 20 citations
  5. Regulator: Dynamic Analysis to Detect ReDoSRobert McLaughlin, Fabio Pagani, Noah Spahn, Christopher Kruegel et al.USENIX Security 2022
Dusk over the sea between two cliffs drawn in fine vertical lines