Skip to content
Memory corruption Disclosed report Advanced

Truncation in nsScanner

On 64-bit builds, the nsScanner class truncates a 64-bit size_t value into 32-bit member variables, which could cause incorrect behaviour when parsing strings larger than 4 GB. The reporter does not know the security impact.

q1 Follow

Originally disclosed on Mozilla

  • Fixed in 22 days
  • Paid in 27 days
  • Disclosed after 22 days
Text
On x64 builds, nsScanner (parser\htmlparser\nsScanner.cpp) truncates the 64-bit |size_t| quantity Distance() into the 32-bit member variables |mCountRemaining| and |mFirstNonWhitespacePosition|. This matters if the nsScanner object represents a string > 4 GB [1].

I do not know the security import of this bug.

[1] This can occur; see, e.g., https://bugzilla.mozilla.org/show_bug.cgi?id=1334246 .

The original report as published on Mozilla's Bugzilla, by q1. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a type-width mismatch where a 64-bit size_t result is stored in 32-bit integer members without checking for overflow.

Impact

The text does not establish a security impact; it only notes that the truncation matters if the scanner handles a string larger than 4 GB.

What the attacker needed

A string larger than 4 GB; 64-bit build

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A program uses a number to track how much text is left to read. On 64-bit systems that number can be very large, but the program stores it in a smaller box that cannot hold values above about 4 billion. If the text is bigger than that, the number wraps around and the program may misread the text. The person who found it is not sure whether an attacker can use this.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by q1

View all

71 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.