Zero-width AcroForm causes PDF Viewer content process CPU DoS
Categories
(Firefox :: PDF Viewer, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox158 | --- | fixed |
People
(Reporter: kq5y, Unassigned)
References
Details
(Keywords: csectype-dos, reporter-external, Whiteboard: [client-bounty-form][deduped])
Attachments
(3 files, 1 external file)
Description
Overview:
An untrusted PDF can make PDF.js repeatedly scan a long form value while synthesizing the appearance of a read-only multiline text widget. The attached 50,850-byte PDF needs no PDF JavaScript or user interaction and can be loaded automatically in an iframe.
On Firefox 155 over ordinary HTTP, the trigger used 10.36 seconds of load time versus 0.67 seconds for a matched control that changes only the widget width. A visible current Nightly test confirmed one busy tab content process while other tabs and the browser UI remained responsive, so the demonstrated impact is a recoverable tab/content-process CPU denial of service rather than a browser-wide freeze.
Tested version:
- Firefox 155.0 (Build ID
20260826195058) on Linux x86_64: attached 50,850-byte trigger over HTTP, 10.36 seconds; width-200 control, 0.67 seconds. - Firefox Nightly 157.0a1 (Build ID
20260903215730) on macOS arm64: the trigger drove the affected tab content process to 101.7% CPU after three seconds; a second tab remained usable and the affected tab closed normally. - Firefox ESR 153.2 (Build ID
20260826022508) on Linux x86_64: a 200,849-byte fixed-height variant took 15.43 seconds; its width-200 control took 1.24 seconds. - Current main, Firefox 155.0.1, current ESR 153, ESR 140.15, and ESR 115.40/current ESR115 retain the affected calculation. Firefox 155.0.1 and the ESR branches were source-confirmed, not runtime-tested.
Steps to reproduce:
- Put the attached files in one directory and run
python3 -m http.server 8000there. - Start Firefox with a fresh profile and open
http://127.0.0.1:8000/zero-width-50k.pdf. A webpage can also load it without a click using<iframe src="zero-width-50k.pdf"></iframe>. - Observe the busy PDF tab and measure until rendering completes. On the tested Firefox 155 x86_64 system this took 10.36 seconds.
- With another fresh profile, open
http://127.0.0.1:8000/width-200-control-50k.pdfand repeat. The matched control completed in 0.67 seconds.
The supplied generator reproduces both inputs:
python3 generate_pdf.py --output zero-width-50k.pdf --length 50000 --width 0 --height 75000 --read-only
python3 generate_pdf.py --output width-200-control-50k.pdf --length 50000 --width 200 --height 75000 --read-only
Actual results:
The zero-width PDF spends seconds at full CPU in the affected tab's content process before rendering completes. The width-200 control with the same value and form structure completes close to baseline.
The trigger is a syntactically valid PDF according to qpdf --check. It contains a normal /Fields array, /NeedAppearances true, no /AP, auto font size, a read-only multiline /Ff, a 50,000-character /V, and /Rect [0 0 0 75000].
Expected results:
Degenerate widget geometry should be rejected or clamped, and appearance auto-sizing should have a bounded work limit rather than repeatedly scanning the complete field value.
Root cause:
TextWidgetAnnotation._getAppearance subtracts two points of padding on each side before calling _computeFontSize. A zero-width rectangle therefore supplies an effective width of -4.
_computeFontSize calls _splitLine over the complete cached value for each candidate line count, then increases numberOfLines by only one and repeats while the calculated height is too large. With negative width, _splitLine treats every positive-width glyph as overflowing and emits approximately one chunk per glyph. Because the PDF controls both value length and rectangle height, making height proportional to value length creates linearly many complete scans before the fit condition succeeds.
Clamping or rejecting non-positive effective widths and adding an explicit auto-size work/iteration cap would remove this amplification.
Related public issue:
Bug 2056164 / CVE-2026-84138 is another PDF Viewer denial of service, but its public fix breaks a cyclic /Parent chain in PDFEditor.#fixFields while reconstructing a missing /Fields array. This report uses a normal non-cyclic /Fields array and reaches TextWidgetAnnotation._computeFontSize during rendering; it continues to reproduce in current Nightly.
| Reporter | ||
Comment 1•2 months ago
|
||
| Reporter | ||
Comment 2•2 months ago
|
||
Updated•2 months ago
|
Comment 3•2 months ago
|
||
content process (only) DOS hangs don't need to be hidden as security bugs. DOS bugs are out of scope for our bounty program
Updated•2 months ago
|
Comment 4•2 months ago
|
||
Updated•2 months ago
|
Updated•1 month ago
|
Description
•