Closed Bug 2069428 Opened 2 months ago Closed 2 months ago

Zero-width AcroForm causes PDF Viewer content process CPU DoS

Categories

(Firefox :: PDF Viewer, defect)

defect

Tracking

()

RESOLVED FIXED
158 Branch
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)

Attached file zero-width-50k.pdf —

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:

  1. Put the attached files in one directory and run python3 -m http.server 8000 there.
  2. 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>.
  3. Observe the busy PDF tab and measure until rendering completes. On the tested Firefox 155 x86_64 system this took 10.36 seconds.
  4. With another fresh profile, open http://127.0.0.1:8000/width-200-control-50k.pdf and 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.

Flags: sec-bounty?
Component: Security → PDF Viewer

content process (only) DOS hangs don't need to be hidden as security bugs. DOS bugs are out of scope for our bounty program

Group: firefox-core-security
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: sec-bounty? → sec-bounty-
Keywords: csectype-dos
Summary: Zero-width AcroForm causes PDF Viewer CPU DoS → Zero-width AcroForm causes PDF Viewer content process CPU DoS
Whiteboard: [client-bounty-form] → [client-bounty-form][deduped]
Depends on: 2069780
Depends on: 2070003
Depends on: 2070399
Depends on: 2070657
No longer depends on: 2069780
No longer depends on: 2070003
No longer depends on: 2070399
No longer depends on: 2070657
Depends on: 2071136
No longer depends on: 2071136
Depends on: 2071580
Status: NEW → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch
QA Whiteboard: [qa-triage-done-c159/b158]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: