CWE-1333AvailabilitySeverity · Medium

Patterns that take forever to match

A badly built regular expression can spend minutes on one crafted string. A few such requests can tie up every worker and take a service offline.

At a glance

Controls
CWE-1333
Typical severityMedium
ReferenceCWE-1333

What it is

Some regular expressions can try an enormous number of ways to match a string before they give up. A short, carefully shaped input can make one such check run for seconds or minutes. While it runs, the server thread doing the work is stuck.

An attacker looks for any field that is checked by a vulnerable pattern, such as an email, a URL or a search box. They send a few crafted strings and watch response times climb until the service stops answering. AI tools can read a pattern and write the input that triggers the worst case within moments.

Where it hides

What a reviewer can look for in the code and in the behaviour, before anyone proves it.

  • Email, URL and phone number validation on sign-up and profile forms
  • Search and filter boxes that build patterns from user text
  • Log parsing or content filtering jobs that run on user-supplied text
  • Route matching and input checks in shared validation libraries

How MATT tests it

The proof runs against the deployed product, on every release, whoever wrote the code.

  1. 01Read the code to find regular expressions that run on user input and have nested or overlapping repetition
  2. 02Sign in with the test login and send a short crafted string to that field, growing it a few characters at a time
  3. 03Record how response time rises with input length, and stop once the growth is clear
The rule, in plain English

No user input may reach a pattern that can backtrack without limit.

Executable check

as any user: POST /v1/profile with email = crafted string of 50 characters expect: response within 1 second expect: 400 for invalid input expect: response time does not grow sharply as the string gets longer

Every rule MATT holds →

What the fix looks like

  1. 01

    Rewrite risky patterns to remove nested and overlapping repetition

  2. 02

    Use a regular expression engine with linear‑time matching where the language offers one

  3. 03

    Cap input length before any pattern runs

  4. 04

    Set a time limit on pattern matching where the runtime supports it

A check that was never written is found by proving the deployed behaviour, fixed with the engineer who shipped it, and kept fixed by running the control on every change. What is ExploitOps? →

ExploitOps discovery call

Understand where your security loop breaks.

A call with a MATT co-founder to understand your product and whether an ExploitOps Review is worth doing. If there is a real need, we scope one with the research team.

Let’s understand your priority

What brings you to MATT?

What would you like help with?
01 / 02