Investigate in your agent.

Turn this advisory into a focused investigation. Ask your agent to check your project’s versions, explain the evidence, and suggest a compatible fix.

Your agent needs remote MCP support and access to https://cve.new/mcp.

Read the setup guide

Skip to content
Check your stack
CVE-2026-118772high7.5

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

Impact

The `joi` package's `string().email({ multiple: true })` function has a quadratic-time split vulnerability, allowing a denial of service attack. Affected versions include `joi` releases from `17.1.1` to `17.13.8` and from `18.0.0` to `18.3.0`, as well as `@hapi/joi` releases from `16.0.0`. An attacker can cause CPU exhaustion with a single request containing a large amount of whitespace.

Summarized by @cf/meta/llama-3.3-70b-instruct-fp8-fast. Verify details against the original sources.
Applies when
const Joi = require('joi');

Affected packages

Start with the recorded fix for your release branch. Check your installed version and test compatibility before upgrading. Fixing this advisory does not rule out other vulnerabilities in the release.

joi npm
Affected range Recorded fix
From 17.1.1 before 17.13.9Semantic versions17.13.9
From 18.0.0 before 18.3.1Semantic versions18.3.1

Version evidence: OSV · GHSA-4528-x5fx-h6hg

View original version evidence (0 explicit versions)
Affected range Recorded fix
From 16.0.0 through 17.1.1 (inclusive)Semantic versionsNot recorded

Version evidence: OSV · GHSA-4528-x5fx-h6hg

View original version evidence (0 explicit versions)

Affected products

Vendor version evidence. Product records are separate from automatic dependency matching.

hapijs · GitHub_M

joi

2 ranges

Compare with this publisher’s ranges. This does not inspect your installation.

affected

>= 16.0.0, <= 17.1.1

>= 18.0.0, < 18.3.1

unaffected

unknown

Other versions: unknown

@hapi · GitHub_M

joi

1 range

Compare with this publisher’s ranges. This does not inspect your installation.

affected

>= 16.0.0, <= 17.1.1

unaffected

unknown

Other versions: unknown

Original source description

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:

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:

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

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:

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.

Inside the record

Evidence available

Package identity
Version evidence
Remediation guidance · not supplied
Weakness classification
Additional publishers · not supplied

Describes the evidence in this view, not whether the product is safe.

Original records

CVE-2026-118772

View the latest unmodified CVE JSON from the official source. It may be newer than this imported page.

cve.new JSON →

Underlying weaknesses

The source’s classification of what caused the vulnerability.

CWE-1333 ↗

CWE-1333: Inefficient Regular Expression Complexity

GitHub_M

Related →
Contributing organizations · 1
GitHub_M

Assigning organization

2026-10-29

What changed

Follow changes
No substantive changes have been recorded here yet. History starts when cve.new observes a change after tracking is enabled; earlier edits are not reconstructed.

Large field values are marked as truncated previews. Original source snapshots remain retained.

References

9 sources