High

joi: quadratic-time split in `string().email({ multiple: true })` allows denial of service

  • Disclosed: 30.10.2026
  • Updated: 04.11.2026 10:00

Summary

Joi.string().email({ multiple: true }) takes quadratic time to split a value that contains a long run of whitespace. One request with 100 KB of spaces blocks the Node.js event loop for several seconds, which causes a denial of service.

Details

When the multiple option is set, the email rule splits the value into addresses with a regular expression that removes whitespace on each side of the separator:

js
const regex = new RegExp(`\\s*[${options.separator ? escapeRegex(options.separator) : ','}]\\s*`);
// ...
const emails = options.multiple ? value.split(regex) : [value];

String.prototype.split tries a match at each position of the value. At each position inside a whitespace run, the leading \s* reads the rest of the run, does not find a separator, and backtracks through all of it. A run of n whitespace characters without a separator therefore costs n² steps. This applies to the default separator and to all custom separator values.

The fix lets the leading whitespace match start only at the beginning of a whitespace run, so the split is linear:

js
const regex = new RegExp(`(?:(?<!\\s)\\s+)?[${options.separator ? escapeRegex(options.separator) : ','}]\\s*`);

The split results do not change. The regular expression is now built only when multiple is set.

Every joi release from 17.1.1 up to and including 17.13.8, and from 18.0.0 up to and including 18.3.0, is affected. Every @hapi/joi release from 16.0.0 is affected.

Workarounds for users who cannot upgrade:

  • Add .max() before .email(), for example Joi.string().max(1000).email({ multiple: true }). The max rule then rejects long values before the email rule runs.
  • Do not use the abortEarly: false option with this schema. With abortEarly: false, the email rule runs even when the max rule fails.
  • Do not use .trim() as a workaround. It removes only the whitespace at the start and at the end of the value.

Proof of concept

js
const Joi = require('joi');

const schema = Joi.string().email({ multiple: true });
for (const n of [25000, 50000, 100000, 200000]) {
    const start = Date.now();
    schema.validate(' '.repeat(n));
    console.log(`${n} spaces: ${Date.now() - start} ms`);
}

Output on joi@18.3.0 (Node.js 26):

25000 spaces: 244 ms
50000 spaces: 887 ms
100000 spaces: 3349 ms
200000 spaces: 13579 ms

Output on the patched version:

25000 spaces: 0 ms
50000 spaces: 0 ms
100000 spaces: 0 ms
200000 spaces: 1 ms

Over HTTP, send the whitespace in a field that the route validates with this schema:

http
POST /invite HTTP/1.1
Content-Type: application/json

{"emails": "<100000 spaces>"}

Impact

This is a denial of service by CPU exhaustion. It affects each application that validates untrusted input with Joi.string().email({ multiple: true }) and that has no length limit before the email rule. One request with 100 KB of whitespace blocks the Node.js event loop for several seconds, and the server cannot process other requests during that time. The attacker needs no authentication when the route is public, and a small number of concurrent requests can keep the service unavailable.

What to do

Upgrade to patched versions (17.13.9, 18.3.1, or later). If upgrading is not immediately possible, apply the following workarounds:

  • Add .max() before .email(), for example Joi.string().max(1000).email({ multiple: true }), so that long values are rejected prior to email execution.
  • Do not enable the abortEarly: false option on the schema, as abortEarly: false causes email to execute even if max fails.
  • Do not rely on .trim() as a workaround, as it only strips whitespace from the start and end of values.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
npm package @hapi/joi >= 16.0.0, <= 17.1.1 no fix
npm package joi >= 17.1.1, < 17.13.9, >= 18.0.0, < 18.3.1 17.13.9, 18.3.1

References

CVSS score 7.5/10
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Weakness (CWE)
CWE-1333
Platform
npm
Package
@hapi/joi, joi
Disclosed
30.10.2026
Updated
04.11.2026 10:00

Sources and licenses · Edited or translated by DockRay; source rights and applicable licenses are retained.

OSV / GitHub Advisory Database - GHSA-4528-x5fx-h6hg - CC BY 4.0

Vulnerability history: joi

All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.

Total entries
6
First → latest
06.2026 10.2026
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • High 2
  • Medium 2
  • Low 2

Disclosures per year

  1. 2026: 6
  1. joi: quadratic-time split in `string().email({ multiple: true })` allows denial of service this entry
    High · 7.5 CVE-2026-118772 >= 17.1.1, < 17.13.9, >= 18.0.0, < 18.3.1 17.13.9, 18.3.1
  2. High · 7.5 CVE-2026-92599 >= 17.2.0, < 17.13.7, >= 18.0.0, < 18.2.6 17.13.7, 18.2.6
  3. Medium · 3.7 CVE-2026-90771 < 17.13.8, >= 18.0.0, < 18.2.9 17.13.8, 18.2.9
  4. Low · 3.7 CVE-2026-84368 >= 17.2.0, < 17.13.6, >= 18.0.0, < 18.2.5 17.13.6, 18.2.5
  5. Low · 3.7 CVE-2026-84367 >= 16.0.0, < 17.13.5, >= 18.0.0, < 18.2.4 17.13.5, 18.2.4
  6. Medium · 5.3 CVE-2026-48038 >= 18.0.0, < 18.2.1, < 17.13.4 18.2.1, 17.13.4

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.