November 18, 2026
How I found a DoS bug in an email parser with 17M+ weekly downloads
CVE-2026-124016 walkthrough: the bug, the mistake I made fixing it, and what the verification actually looked like
By Connect Arjunjain
4 min read
I spend a lot of time right now hunting for real, reportable vulnerabilities in widely used npm packages. This is my fifth CVE, and the package this time is postal-mime, a MIME email parser currently pulling 17 million downloads a week, used in Node.js and in Cloudflare's Email Workers. Not a niche target. Something sitting in production pipelines across a lot of infrastructure right now.
The bug in plain terms
Emails can have nested sections, basically boxes inside boxes, up to 256 deep by spec. Each section is marked off by a divider line. The parser's job on every line is simple: does this start with --, and if so, does it match one of the dividers currently open?
Here's the problem. Nest 250 boxes, give every divider a long shared prefix, then fill the body with lines that look almost like a divider but don't quite match any of them. Every one of those near-miss lines now forces the parser to walk almost the entire way through a comparison against all 250 open dividers before it can give up. Do that across thousands of lines and a few megabytes of email takes multiple seconds of CPU instead of milliseconds. The file stays completely valid MIME the whole time. Nothing about it looks malformed.
The actual code
In src/postal-mime.ts, the function processLine() looped over every open boundary for each -- line with no index and no early exit past a cheap length check:
for (let i = 0; i < boundaries.length; i++) {
let boundary = boundaries[i];
if (line.length < boundary.value.length + 2) continue;
let boundaryMatches = true;
for (let j = 0; j < boundary.value.length; j++) {
if (line[j + 2] !== boundary.value[j]) {
boundaryMatches = false;
break;
}
}
// ...
}for (let i = 0; i < boundaries.length; i++) {
let boundary = boundaries[i];
if (line.length < boundary.value.length + 2) continue;
let boundaryMatches = true;
for (let j = 0; j < boundary.value.length; j++) {
if (line[j + 2] !== boundary.value[j]) {
boundaryMatches = false;
break;
}
}
// ...
}Cost per line: depth times shared prefix length. Total parse cost: depth times size instead of just size. CWE-407, inefficient algorithmic complexity.
Ruling out something worse first
Before settling on this, I wanted to know if there was something more severe sitting in the same codebase. Checked for dangerous sinks across the whole thing, eval, fs, child_process, require, zero hits. No filesystem or execution surface at all, which caps how bad anything here can get no matter what you find. Checked for prototype pollution, already guarded. Checked a ReDoS lead in the HTML-to-text converter that looked real at first, the source literally had comments admitting a known quadratic bug, but the fix was already shipped, confirmed by throwing 80,000-repetition adversarial payloads at it directly instead of trusting the comment.
Conclusion: this is a pure parser with no dangerous sinks, which means a CPU-DoS bug is roughly the severity ceiling here. Said that plainly instead of manufacturing drama that wasn't there.
Verifying it, and getting it wrong once
First timing pass showed roughly a 13 to 16 times slowdown at depth 250. Redone properly with JIT warmup, discarding a throwaway parse before timing, the real number came out higher: 27 to 33 times. Without warmup, a constant startup overhead gets added to both the attack and control measurement, and the same constant added to both sides of a ratio pulls it toward 1. I reported the corrected, larger number rather than the smaller one I'd already written down.
The strongest piece of evidence came from instrumenting the actual parser to count real byte comparisons, not just timing it. At depth 1, about 755,000 comparisons on a fixed workload. At depth 250, about 181.7 million. Clean linear scaling with depth, holding at a constant 62 bytes compared per boundary per line the entire way, matching the proof-of-concept's own boundary length almost exactly. That's not an inference from noisy timing, that's a direct count of the operation the bug does too many of.
Building the fix, and the mistake in it
The fix: replace the linear scan with a trie built from the open boundaries' bytes, so matching a line costs time proportional to the line's own length, not the number of open boundaries.
First version of this patch cached the trie keyed by the array's identity: rebuild only if the reference changes. Wrong. The boundaries array is one object, mutated in place via push and splice, so the reference never changes across a parse. The cache went stale after the first build and stayed stale.
Ran the project's own test suite against this. 14 failures, all in nested-multipart test cases, exactly where you'd expect this class of bug to break something. Before trusting that number I'd already confirmed the clean baseline passed 1040 out of 1040, so I knew the failures were mine and not pre-existing flakiness.
Fixed it with an explicit version counter bumped at both mutation sites instead of trusting the array reference. Reran: 1040 out of 1040.
Then ran an 8,000-case differential fuzzer, original parser against patched parser, generating nested multipart messages with randomized boundary values, deliberately forcing exact boundary reuse between a parent and child section in about 30% of cases, since that's the exact scenario a separate correctness rule in the codebase exists to handle. Zero differences across 325 distinct outputs.
Reporting it
Filed through VulnCheck with the full writeup, PoC script, patch, and verification results. Named the project's own README advice (bound your input size before parsing untrusted mail) directly in the submission instead of waiting for the maintainer to point it out as a reason to dispute it.
The outcome
Maintainer shipped 4.2.1. CVE-2026-124016 published. CWE-407. CVSS 5.3 on v3.1, 6.9 on v4.0. Checked the npm page after the fix landed, the fixed version is live and showing as current, zero open issues, pulling close to 17 million downloads a week. The published CVSS score landed almost exactly on the number I'd estimated before submitting, which is a decent sign the severity framing held up under independent review rather than just my own.
Full advisory: https://github.com/postalsys/postal-mime/security/advisories/GHSA-q8wm-54mj-r36p CVE Record: https://www.cve.org/CVERecord?id=CVE-2026-124016
What I'd carry forward
Your first measurement is often wrong in a small, fixable way, run the cheap version before trusting the expensive one. A patch that typechecks and looks reasonable can still be broken, run the actual test suite and confirm the baseline first. Counting the real operation beats timing it. And naming your own weak points in the report up front works better than hoping nobody notices them.