Closed Bug 2083229 Opened 1 month ago Closed 21 days ago

Malformed address-group transitions cause quadratic JSMime parsing during message display

Categories

(Thunderbird :: Security, defect)

Thunderbird 160
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 2081101

People

(Reporter: tjddbdud1, Unassigned)

Details

Attachments

(1 file)

Summary

Thunderbird's current JSMime address parser repeatedly reallocates and copies the accumulated address array when it encounters a colon after a pending address. A remote email can use repeated malformed-but-accepted ,: transitions in one folded To/From/Cc/Bcc/Reply-To/Sender field. Opening the message causes quadratic main-thread work before the recipient row is ready.

Verified current target

Official source HEAD/origin/main b73b6c419d08c583d9ac32ed9f79b080c17856b6; official Thunderbird Daily 160.0a1 BuildID 20261016104433; thunderbird.exe SHA-256 04C83C5BC7BDF592EA6AE2AC6864C24A0F2EDF3B38252ACC739B2ADDF994BAC0.

The same affected concat markers are present on freshly fetched beta 159 (e6d630d0630977419914105993da19066e651c83), release 158.0.1 (52c36bbe81950c112a40483d5501451edc41f636), and ESR 153.5.1 (3707712331a12286d13e554fb62a22991371bc5f).

Root cause and display path

mail/base/content/msgHdrView.js:1595-1603 sends the message header to parseEncodedHeaderW. MimeJSComponents.sys.mjs:262-269 and mimeParser.sys.mjs:282-286 route it to jsmime.headerparser.parseAddressingHeader. At mailnews/mime/jsmime/jsmime.mjs:986-990, each colon with a pending address executes results = results.concat(addrlist), copying the entire accumulated result. Repeated address,:address,:... transitions therefore copy at least n(n+1)/2 references. A similar growing concat exists in the no-group semicolon recovery branch at line 1069.

Reproduction and results

The attached local-only PoC generates an actual .eml, opens it through Thunderbird's real message window, and waits for the real To recipient row. Target and control contain the same ordered addresses, are exactly the same byte size, and use identical folding every 20 addresses so all physical header lines remain below 600 octets. Only the two-byte separator differs: target ,:, control , .

Three 160,000-address targets (4,344,250-byte EMLs) took 9,079.017-9,085.111 ms; paired controls took 1,052.344-1,056.666 ms. Three 80,000-address targets took 2,160.257-2,162.179 ms; controls took 546.496-551.835 ms. Doubling input increased target time about 4.2x and control time about 1.9x. All runs reached the real recipient row and rendered five recipients plus the More button.

The isolated shipped parser at 160,000 addresses took 8,100 ms versus 189 ms for the same-address control and returned all 160,000 addresses in order. The target performs at least 12,800,080,000 reference copies.

A fresh extraction of the final ZIP reproduced 9,422.757 ms versus 1,001.579 ms through the real EML display path and 8,227 ms versus 191 ms through the shipped parser; all four commands passed.

Impact and severity

A sender can cause seconds of main-thread unresponsiveness with a few-megabyte message header; the cost scales quadratically. Only availability impact is claimed, and displaying the crafted message is treated as required user interaction.

Suggested Moderate, CVSS 3.1 6.5 (AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H), CWE-407 primary and CWE-400 secondary. Suggested component: MailNews Core / MIME.

Duplicate review

No matching public report was found. Bug 1411720/CVE-2018-5161 concerned an older repeated-@ escaping algorithm. Bug 1389975 concerns rendering of a different space-separated malformed header. Bug 1858208 only notes normal-folder hot code and has no ,: trigger, concat sink, or quadratic scaling. Private Bug 2083198 concerns repeated physical From fields and the outer concat at jsmime.mjs:143; this report uses one folded field and a separate inner concat at line 990, so the fixes are independent. Private reports remain for Mozilla triage.

Suggested fix and safety

Append addrlist elements iteratively in the colon and no-group semicolon recovery branches instead of replacing results with results.concat(addrlist). Avoid an unbounded spread call. Add a scaling regression test.

All inputs and execution were synthetic and local. No mail was sent and no third-party service or account was used. AI assistance was used for source review and drafting; every measurement was executed and verified locally.

Duplicate of bug 2081101.

Group: mail-core-security
Status: UNCONFIRMED → RESOLVED
Closed: 21 days ago
Duplicate of bug: 2081101
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: