SShortSingh.
Back to feed

Catastrophic Regex Backtracking: Measured Timing Curve Shows Exponential Slowdown

0
·6 views

A developer measured how a nested-quantifier regex, ^(a+)+$, slows down as input grows, using Node 22 and a high-resolution timer. On a failing input, the vulnerable pattern climbed from 46ms at 20 characters to about 31.6 seconds at 32 characters, and at 34 characters it had not returned within two minutes. A rewritten pattern, ^a+$, matched the same strings and stayed under 0.2ms at every length tested. The slowdown comes from the engine trying a roughly exponential number of ways to group characters before concluding that no match exists. The author notes that testing only with strings that match can hide the problem, since failing inputs trigger the worst behavior.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

RBA Questions AI Productivity Gains as Data Centre Spending Strains Economy

Reserve Bank of Australia Assistant Governor Sarah Hunter told the UBS Australasia Conference in Sydney that evidence of AI meaningfully lifting productivity or reducing employment in Australia is still limited. She noted that data centre capital spending has risen roughly tenfold in recent years, placing demand pressure on the power grid, construction sector and engineering workforce. Hunter warned this investment could fuel persistent inflation and keep interest rates high. She also flagged that shared cloud and foundation model providers create new systemic risks to financial stability.

0
ProgrammingDEV Community ·

AI Hackathons Need Scoped Budgets, Not Shared Keys or Cards

AI teams often struggle less with ideas than with a clean way to pay for experiments, and this quickly becomes a developer-experience problem. Default workarounds like shared subscriptions or shared API keys are convenient at first but create security risks, accounting confusion, and unclear ownership. The article proposes treating experimental AI budget as a temporary, bounded capability, similar to short-lived branches or limited tokens. Contributors would receive a defined credit envelope that limits spending without exposing the sponsor's full account or credentials. The author notes that prepaid credits or gift cards can support this model, though rules vary, and that such budgets should still be paired with engineering controls like server-side secrets, input validation, usage logging, and per-user limits.

0
ProgrammingDEV Community ·

Guide Explains Using One Free IPv6 /48 Across Two VPS Providers Without Renumbering

A network operator describes how to announce a single IPv6 /48 prefix from two VPS hosts in different cities so both sites can carry traffic. The article recommends setting local-preference and AS-path prepending to make one site primary and the other a backup, while keeping ROA maxLength at /48. It also covers export filters, drain and withdrawal procedures during maintenance, and choosing between anycast and DNS failover for stateless versus stateful services. The piece is written by a leasing company's representative, who discloses that the company's IP space is featured in the walkthrough.

0
ProgrammingDEV Community ·

Python script flags failing endpoints and slow requests in fictional iPhone log demo

A DEV Community tutorial shows how to build a small Python log analyzer that runs on an iPhone using only the standard library, requiring no server or network connection. The script parses simplified, fictional access-log lines, rejecting malformed entries while keeping their line numbers visible. It counts HTTP 5xx server failures, computes a 30% server-error rate across ten parsed requests, and reports a 195 ms median latency. It also ranks the slowest requests and groups failures by endpoint, with checkout showing the most errors. The author stresses that such summaries point to where to investigate rather than revealing the underlying cause.