Closed Bug 2086012 Opened 1 month ago Closed 1 month ago

Unbounded Memory Growth in FireFox PDF Viewer(pdf.js) and Affects Firefox Desktop and Android

Categories

(Firefox :: PDF Viewer, defect, P3)

defect

Tracking

()

VERIFIED FIXED
161 Branch
Tracking Status
firefox161 --- verified
firefox162 --- verified

People

(Reporter: biveshsec1, Unassigned)

References

()

Details

(Keywords: reporter-external, Whiteboard: [client-bounty-form][nosec][deduped][b-noted])

Attachments

(7 files, 1 external file)

Attached file poc_type4.pdf —

Short Description

A 733-byte PDF makes Firefox's PDF worker consume memory without bound until the tab, the browser or (on Android) the device runs out of RAM. No user interaction beyond opening the file is required.

Affected

  • Firefox 158.0.1 desktop: bundles pdf.js 6.4.195; tab memory reached ~5 GB.
  • Firefox for Android 158.0.1: same file exhausted device RAM
  • pdfjs 6.4.299 (Tested Deploying Locally as well as Official Online Demo provided in pdf.js repo)

STEPS TO REPRODUCE

  1. Save the attached poc_type4.pdf or run attached make_type4_pdf.py to create the malicious pdf.
  2. Open it in Firefox 158 from local storage (desktop or Android).
  3. Watch memory in the Browser Task Manager(Shift+Esc) or OS task manager.

Expected: the one-page PDF renders in milliseconds (see attached valid_type4.pdf control).
Actual: The PDF worker never completes; memory grows continuously. On desktop it reaches ~5 GB and the machine swaps. On Android the device runs out of RAM and other apps are killed. Closing the tab is the only way out and the viewer cannot cancel the worker.

Root Cause

In src/core/postscript/lexer.js, Lexer._getNumber() may return a number token without advancing this.pos when the numeric regex fails to match or matches a non-finite literal such as 1e999. In these cases, next() rewinds on +, -, and ., causing the parser to repeatedly process the same character. Each iteration allocates a new PsNumber, resulting in an infinite loop and unbounded memory consumption.

Trigger inputs: {+}, {-}, {.}, and {1e999}. The provided PoC uses {+}.

Note:

I would like to submit more Attachments(Andriod, Windows, Locally Deployed Pdf.js Video POC) but the form allows single attachment submission, so i have attached the main Malicious pdf poc_type4.pdf in initial report.

What would you suggest me to use to share these POC Videos as well as the Python script to create this Malicious PDF?

Flags: sec-bounty?
Attached file make_type4_pdf.py —

Script to Create Malicious PDF

Attached video 1. FireFox Linux.webm —

Used make_type_pdf.py to create malicious pdf and Opened it on Latest Linux FireFox Browser

Attached video 3.Windows Firefox.mp4 —
Attached video Android Firefox.mp4 —
Attachment #9668391 - Attachment mime type: video/mp4 → video/webm
Component: Security → PDF Viewer

Automatic triage (under development): deduplication, sec-rating
No validation or verification has been performed.

Security rating: nosec

The PostScript (Type 4) function lexer in pdf.js returns a number token without advancing when '+', '-', '.' or an overflowing literal fails to parse. The parser then loops forever, appending nodes. A web page can trigger this by serving or linking a crafted PDF. The impact is that one pdf.js worker spins and grows memory in the content process until the tab is closed or the process runs out of memory. There is no memory corruption and no data exposure. Any web page can already use unbounded CPU and memory with plain JavaScript, so this gives an attacker nothing new. This is a resource-exhaustion bug, not a security vulnerability.

Whiteboard: [client-bounty-form] → [client-bounty-form][nosec][deduped]
Group: firefox-core-security
Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3

Thank you for reviewing the report and providing your assessment. I understand that the current reproduction does not demonstrate memory corruption or data exposure. However, I would like to request further consideration of the potential availability impact.

The issue is triggered by an exceptionally small, approximately 733-byte PDF file. When opened in an affected Firefox client, the PDF.js worker continuously consumes memory until the tab is closed or the process exhausts its available memory. This is not simply a large document requiring substantial resources for rendering; it is a minimal input triggering disproportionate and potentially unbounded resource consumption.

An attacker could distribute this file through an email attachment or website and rely on a user opening it. Depending on available resources and process limits, this could render the PDF viewer unresponsive, crash the affected process, or potentially affect overall system responsiveness.

Regarding the comparison with ordinary JavaScript, I acknowledge that web content can consume substantial memory. However, I believe the relevant question is whether this specific PDF.js processing behavior introduces a distinct and reproducible availability impact, and whether existing browser safeguards adequately contain it. The ability to consume resources through JavaScript does not, by itself, establish that every resource-exhaustion issue in another processing path is equivalent in impact or exploitability.

I am not claiming memory corruption, code execution, or data disclosure. My concern is specifically the potential denial-of-service impact arising from a tiny, attacker-controlled document that triggers sustained memory growth.

I would also like to note that the report has progressed from UNCONFIRMED to NEW, with Severity S3 and Priority P3. I understand that these classifications do not automatically establish security impact, but I would appreciate clarification on whether the potential availability impact has been evaluated specifically under Mozilla's security triage criteria.

I have also reviewed Mozilla's current "Client Bug Bounty Program" (https://www.mozilla.org/en-US/security/client-bug-bounty/). I understand that denial-of-service-only issues are generally ineligible for a bounty. However, my question about a potential CVE is separate from financial reward. Could this issue still be considered for security classification and possible CVE assignment if it meets the applicable vulnerability-disclosure criteria, independently of bounty eligibility?

If the issue remains classified as non-security, I would appreciate clarification on whether the decision is based on the limited impact, effective process isolation, or the conclusion that the behavior is equivalent to ordinary web-content resource consumption. I would also appreciate clarification on whether this classification necessarily rules out CVE consideration.

Thank you for your time and consideration.

This bug is public with a downloadable PoC and no fix. I filed it through the bounty form, which should have kept it private, but it was marked "nosec" and left public. Can you restrict it until a fix ships? I can't do that myself.

If it stays public, is it OK to write about it on X or Medium?

Flags: needinfo?(cdenizet)

(In reply to Bivesh Thakur from comment #9)

This bug is public with a downloadable PoC and no fix. I filed it through the bounty form, which should have kept it private, but it was marked "nosec" and left public. Can you restrict it until a fix ships? I can't do that myself.

You can find on the web a large variety of pdf "bombs" which are valid (from a spec point of view) and well-formed.
Here it's just a simple bug nothing else.

If it stays public, is it OK to write about it on X or Medium?

Yes.

Flags: needinfo?(cdenizet)
Depends on: 2086866
No longer depends on: 2086866
Depends on: 2087181
Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 161 Branch
Flags: sec-bounty? → sec-bounty-
Whiteboard: [client-bounty-form][nosec][deduped] → [client-bounty-form][nosec][deduped][b-noted]

Hello,

I noticed that my report has been marked as deduped, but I haven't received a link or Bugzilla ID referencing the original report.

Could you please provide the corresponding duplicate report so I can understand which existing issue my submission duplicates?

Thank you for your time.

Flags: needinfo?(cdenizet)
Depends on: 2087223
No longer depends on: 2087223

(In reply to Bivesh Thakur from comment #13)

Hello,

I noticed that my report has been marked as deduped, but I haven't received a link or Bugzilla ID referencing the original report.

Could you please provide the corresponding duplicate report so I can understand which existing issue my submission duplicates?

If it was a dupe, the corresponding bug field would have been filed with the bug number.

Flags: needinfo?(cdenizet)
QA Whiteboard: [qa-triage-done-c162/b161]
QA Whiteboard: [qa-triage-done-c162/b161] → [qa-triage-done-c162/b161][qa-ver-needed-c162/b161]
Flags: qe-verify+

I was able to reproduce the issue on Win11x64 using FF build 159.0a1(20261006194415).
Verified as fixed on Win11x64 using FF build 162.0a1 and 161.0b4.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-triage-done-c162/b161][qa-ver-needed-c162/b161] → [qa-triage-done-c162/b161][qa-ver-done-c162/b161]
Flags: qe-verify+
QA Contact: mchiorean
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: