Skip to content
Memory corruption Disclosed report Advanced CVE-2017-5445

Uninitialized value in nsDirIndexParser::ParseFormat

The directory index parser in Firefox could leave entries of an internal integer array uninitialised when the http-index-format content had no format values or contained invalid ones. Running under Valgrind showed the uninitialised value being used, which the reporter frames as a memory-safety defect rather than a demonstrated exploit.

Chamal De Silva Follow

Originally disclosed on Mozilla

  • Fixed in 30 days
  • Paid in 37 days
  • Disclosed after 30 days
Text
Created attachment 8843567
httpindex1.php

Steps to reproduce:
--------------------
1. Build firefox with valgrind using instructions mentioned in
   https://developer.mozilla.org/en-US/docs/Mozilla/Testing/Valgrind
2. Download and copy httpindex1.php and httpindex2.php to local web server.
   Web server should support PHP.
3. Start firefox
   * Enable Multi-process option should be disabled in firefox.
     Otherwise firefox tab crash due to some other valgrind errors.
   export VALGRIND_OPTIONS="--smc-check=all-non-file --vex-iropt-register-updates=allregs-at-mem-access --show-mismatched-frees=no --read-inline-info=yes"
  ./mach run --debugger="valgrind" --debugger-args="$VALGRIND_OPTIONS"
4. Visit httpindex1.php or httpindex2.php

Valgrind will display error. Valgrind output is attached under Crash Signature.

Cause of bug
-------------
Bug is in nsDirIndexParser::ParseFormat method of netwerk\streamconv\converters\nsDirIndexParser.cpp file.
"mFormat" int array created by this method can contain uninitialized value due to 2 reasons.

1. "http-index-format" content does not contain any format values.
    ex: 200:\r\n
        201:a\r\n
   nsDirIndexParser::ParseFormat method creates an int array with 2 elements for "mFormat", even though there are no values in format line. 
2. "http-index-format" content contains invalid values. 
   ex: 200:a a a
       201:a a a
   nsDirIndexParser::ParseFormat method creates an int array with 4 elements for "mFormat", even though there are invalid values in format line.

The original report as published on Mozilla's Bugzilla, by Chamal De Silva. 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 the parser allocates the format array based on the number of tokens it expects but does not initialise or validate every element when the format line is empty or contains invalid tokens.

Impact

The uninitialised value is used by the parser, which could cause unpredictable behaviour; the report shows a Valgrind finding rather than a working exploit.

What the attacker needed

Local PHP web server; Firefox built and run under Valgrind; multi-process mode disabled

How it was found

  1. Build Firefox with Valgrind support and start it with the debugger options.
  2. Place the provided PHP test pages on a local PHP-capable web server.
  3. Disable multi-process mode so the tab does not crash from unrelated Valgrind errors.
  4. Visit either test page and observe the Valgrind error output.

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.

Firefox can read a special directory listing format from a web server. A parser turns the format line into a list of numbers, but in some cases it never fills in every slot, so the program later reads leftover memory. Reading uninitialised memory is a bug because the value is unpredictable and can lead to crashes or worse.

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 Chamal De Silva

View all

3 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.