# Repairing Regex Vulnerabilities via Localization-Guided Instructions

arXiv: https://arxiv.org/abs/2510.09037 · HTML: https://mlsanity.com/paper/2510.09037/

## Key facts

- No citing papers in the map yet (data through 14 Oct 2026).
- Builds on 18 of its 41 references that are in the map.
- First posted on arXiv 10 Oct 2025.

## Builds on (most cited first, 18 of 18)

- [Language Models are Few-Shot Learners](https://mlsanity.com/paper/2005.14165/) (2020)
- [Self-Consistency Improves Chain of Thought Reasoning in Language Models](https://mlsanity.com/paper/2203.11171/) (2022)
- [PaLM: Scaling Language Modeling with Pathways](https://mlsanity.com/paper/2204.02311/) (2022)
- [Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?](https://mlsanity.com/paper/2202.12837/) (2022)
- [MetaICL: Learning to Learn In Context](https://mlsanity.com/paper/2110.15943/) (2021)
- [Large Language Models Meet NL2Code: A Survey](https://mlsanity.com/paper/2212.09420/) (2022)
- [Diet Code Is Healthy: Simplifying Programs for Pre-trained Models of Code](https://mlsanity.com/paper/2206.14390/) (2022)
- [Llama-3.1-FoundationAI-SecurityLLM-8B-Instruct Technical Report](https://mlsanity.com/paper/2508.01059/) (2025)
- [LAQuer: Localized Attribution Queries in Content-grounded Generation](https://mlsanity.com/paper/2506.01187/) (2025)
- [Sketch-Guided Constrained Decoding for Boosting Blackbox Large Language Models without Logit Access](https://mlsanity.com/paper/2401.09967/) (2024)
- [Out of Context: How important is Local Context in Neural Program Repair?](https://mlsanity.com/paper/2312.04986/) (2023)
- [Why Aren't Regular Expressions a Lingua Franca? An Empirical Study on the Re-use and Portability of Regular Expressions](https://mlsanity.com/paper/2105.04397/) (2021)
- [Deconstructing In-Context Learning: Understanding Prompts via Corruption](https://mlsanity.com/paper/2404.02054/) (2024)
- [Repairing DoS Vulnerability of Real-World Regexes](https://mlsanity.com/paper/2010.12450/) (2020)
- [Locally Repairable Codes with Multiple Repair Alternatives](https://mlsanity.com/paper/1302.5518/) (2013)
- [Static Analysis for Regular Expression Exponential Runtime via Substructural Logics (Extended)](https://mlsanity.com/paper/1405.7058/) (2014)
- [Improving Developers' Understanding of Regex Denial of Service Tools through Anti-Patterns and Fix Strategies](https://mlsanity.com/paper/2212.07979/) (2022)
- [SoK: A Literature and Engineering Review of Regular Expression Denial of Service (ReDoS)](https://mlsanity.com/paper/2406.11618/) (2024)

## Abstract (arXiv)

Regular expressions (regexes) are foundational to modern computing for critical tasks like input validation and data parsing, yet their ubiquity exposes systems to regular expression denial of service (ReDoS), a vulnerability requiring automated repair methods. Current approaches, however, are hampered by a trade-off. Symbolic, rule-based system are precise but fails to repair unseen or complex vulnerability patterns. Conversely, large language models (LLMs) possess the necessary generalizability but are unreliable for tasks demanding strict syntactic and semantic correctness. We resolve this impasse by introducing a hybrid framework, localized regex repair (LRR), designed to harness LLM generalization while enforcing reliability. Our core insight is to decouple problem identification from the repair process. First, a deterministic, symbolic module localizes the precise vulnerable subpattern, creating a constrained and tractable problem space. Then, the LLM invoked to generate a semantically equivalent fix for this isolated segment. This combined architecture successfully resolves complex repair cases intractable for rule-based repair while avoiding the semantic errors of LLM-only approaches. Our work provides a validated methodology for solving such problems in automated repair, improving the repair rate by 15.4%p over the state-of-the-art. Our code is available at https://github.com/cdltlehf/LRR.
