CVE-2026-118772

CVE-2026-118772 is a high-severity inefficient regular expression (ReDoS) vulnerability in joi (npm), affecting versions >= 17.1.1, < 17.13.9. It is fixed in 17.13.9, 18.3.1.

Does this CVE actually affect you?

Kodem shows which CVEs are reachable and running in your applications, so you fix what's exploitable, not just what's listed.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Runtime intelligence, not another scanner.

Summary

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

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 [email protected] (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.

A regular expression with worst-case exponential or polynomial matching time is applied to untrusted input, causing excessive CPU use. Typical impact: denial of service when input is crafted to trigger backtracking.

CVE-2026-118772 has a CVSS score of 7.5 (High). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (17.13.9, 18.3.1); upgrading removes the vulnerable code path.

Affected versions

joi (>= 17.1.1, < 17.13.9) @hapi/joi (>= 16.0.0, <= 17.1.1) joi (>= 18.0.0, < 18.3.1)

Security releases

joi → 17.13.9 (npm) joi → 18.3.1 (npm)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

Already deployed Kodem?

See it in your environmentNew to Kodem? Get a demo →

Remediation advice

Upgrade the following packages to resolve this vulnerability:

joi to 17.13.9 or later; joi to 18.3.1 or later

Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.

Frequently Asked Questions

  1. What is CVE-2026-118772? CVE-2026-118772 is a high-severity inefficient regular expression (ReDoS) vulnerability in joi (npm), affecting versions >= 17.1.1, < 17.13.9. It is fixed in 17.13.9, 18.3.1. A regular expression with worst-case exponential or polynomial matching time is applied to untrusted input, causing excessive CPU use.
  2. How severe is CVE-2026-118772? CVE-2026-118772 has a CVSS score of 7.5 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which packages are affected by CVE-2026-118772?
    • joi (npm) (versions >= 17.1.1, < 17.13.9)
    • @hapi/joi (npm) (versions >= 16.0.0, <= 17.1.1)
  4. Is there a fix for CVE-2026-118772? Yes. CVE-2026-118772 is fixed in 17.13.9, 18.3.1. Upgrade to this version or later.
  5. Is CVE-2026-118772 exploitable, and should I be worried? Whether CVE-2026-118772 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2026-118772 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix CVE-2026-118772?
    • Upgrade joi to 17.13.9 or later
    • Upgrade joi to 18.3.1 or later

Other vulnerabilities in joi

Stop the waste.
Protect your environment with Kodem.