Skip to content
DoS Advisory Intermediate

GHSL-2021-113: ReDoS (Regular Expression Denial of Service) in JS Beautifier

A regular expression in JS Beautifier's JavaScript tokenizer was inefficient and could take extremely long to process a crafted input string. An attacker could use such input to cause a denial of service when the beautifier processes it.

ghsecuritylab Follow

Originally disclosed on GitHub Security Lab

JS Beautifier contains a regular expression that is vulnerable to ReDoS (Regular Expression Denial of Service).

ghsecuritylab, on GitHub Security Lab

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the regular expression in the JavaScript tokenizer has ambiguous repetition that causes catastrophic backtracking on crafted input.

Impact

This issue may lead to a denial of service.

What the attacker needed

Ability to supply input to the beautifier; e4x option enabled

The fix

The bug was fixed by a pull request that replaced the inefficient regular expression.

How it was found

  1. Install the jsbeautifier Python package.
  2. Run the beautifier on a crafted string with the e4x option enabled.
  3. Observe that processing takes an extremely long time.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A regular expression is a pattern used to match text, and some patterns can slow down dramatically on certain inputs. Here, a specially crafted piece of JavaScript code makes the beautifier spend a very long time matching it, so the program effectively hangs. That is a denial of service: the tool becomes unusable for anyone relying on it.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by ghsecuritylab

View all

132 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.