Skip to content
DoS Disclosed report Intermediate

[is-my-json-valid] ReDoS via 'style' format

The built-in 'style' format in the is-my-json-valid JSON schema validator uses a regular expression that runs in polynomial time, so a long input string can make validation take far too long. An attacker could cause a denial of service by submitting input that is checked against a schema using that format.

chalker Follow

Originally disclosed on HackerOne

High 7.5 View original
  • Triaged in 41 hours
  • Fixed in 4 days
  • Disclosed after 34 days

I would like to report a ReDoS in is-my-json-valid It allows cause a denial of service if schema uses the built-in style format.

Module

module name: is-my-json-valid version: 2.20.1 npm page: https://www.npmjs.com/package/is-my-json-valid

Module Description

A JSONSchema validator that uses code generation to be extremely fast.

Module Stats

1 250 253 weekly downloads

Vulnerability

Vulnerability Description

Classic ReDoS, polynomial time.

Note that https://www.npmjs.com/package/safe-regex is not free from false positives/negatives (as noted in its Readme) and does not catch this and other polynomial regexps (e.g. /a*a*b/).

Steps To Reproduce:

JavaScript
const imjv = require('is-my-json-valid')
const validate = imjv({ maxLength: 100, format: 'style' })
console.log(validate(' '.repeat(1e4)))

Wrap up

  • I contacted the maintainer to let them know: N
  • I opened an issue in the related repository: N

Impact

DoS if schema uses the style format.

The original report as published on HackerOne, by chalker. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 behind the built-in 'style' format has polynomial-time backtracking, so its running time grows quickly with input length.

Impact

A schema that uses the 'style' format can be made to validate very slowly, causing a denial of service.

What the attacker needed

Schema uses the 'style' format; attacker controls validated input

How it was found

  1. Load the is-my-json-valid module.
  2. Build a validator from a schema that sets a maximum length and uses the 'style' format.
  3. Validate a long string of spaces and observe the slow validation.

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 JSON schema validator checks whether data matches a set of rules. One rule, called a format, checks that a value looks like a particular kind of text, and here that check uses a pattern-matching expression that gets very slow on long strings. If a service validates user input with this rule, someone can send a long string and tie up the server, which is called a denial of service.

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 chalker

View all

36 more disclosed reports, best first.

More from Node.js third-party modules

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.