Skip to content
Memory corruption Disclosed report Advanced

Malformed NAV file leads to buffer overflow and code execution in Left4Dead2.exe

A buffer overflow in the NAV file parsing routines of Left 4 Dead 2 lets a crafted navigation file overwrite the instruction pointer, so an attacker can take over code execution. Because the game accepts files from servers and the Workshop, a victim loading a malicious map could have arbitrary code run on their machine.

hunterstanton Follow

Originally disclosed on HackerOne

Bounty$10,000incl. $2,000 bonus Critical 9.0 View original
  • Triaged in 20 hours
  • Fixed in 5 months
  • Paid in 5 months
  • Disclosed after 11 months

Summary

In the parsing routines of NAV files (which contain the navigation mesh used by the AI for survivor bots, zombies, and the AI director spawning system) a buffer overflow exists which can be used to control the EIP register and takeover code execution.

Proof-of-Concept

  1. Download the attached c1m1_hotel.nav
  2. Place it in your <steamapps>/Left 4 Dead 2/left4dead2/maps/ directory
  3. Start up Left4Dead 2 and attach a debugger
  4. Enter "map c1m1_hotel" into the developer console
  5. Observe that EIP becomes 0x41414102, indicating that a buffer overflow has occurred and code execution is possible

Operating Systems Tested

  • Windows 10 1809 Build 17763.437

I have not tried this for MacOS or Linux, however I assume it would work on both of those platforms as well if they all share the same codebase as the Windows executable.

Notes

Because Left4Dead 2 ships on Windows with a non-ASLR enabled module (binkw32.dll), it is much easier to write up a working exploit for this vulnerability as you no longer need an additional infoleak of some kind to do serious damage and can just use ROP.

Impact

Impact

If an attacker successfully exploits this vulnerability, the attacker can run arbitrary code on the machine of a victim.

Due to the fact that Source supports sending arbitrary files to clients when connecting to a server, it is possible that you could create a fake dedicated server that does nothing but send the malformed NAV file to clients who are connecting, creating a remote code execution scenario.

Another attack scenario would be an attacker uploading a campaign map with a malformed NAV to the Steam Workshop, and convincing other users to download it. When they download it and load the campaign in game, arbitrary code will be executed on their machines.

The original report as published on HackerOne, by hunterstanton. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 NAV parsing routine copies data from the file into a fixed-size buffer without validating its length, allowing the saved instruction pointer to be overwritten.

Impact

An attacker could run arbitrary code on a victim's machine, either by hosting a fake server that sends the malformed file or by uploading a malicious campaign to the Workshop; the report notes a non-ASLR module makes exploitation easier but does not demonstrate a full working exploit.

What the attacker needed

Crafted NAV file; victim loads the map or joins server; Windows target (tested)

How it was found

  1. Place the crafted NAV file in the game's maps directory.
  2. Start the game and attach a debugger.
  3. Load the map through the developer console.
  4. Observe the instruction pointer being overwritten, showing the overflow.

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 NAV file describes the map layout that the game's computer-controlled characters use to move around. The game reads this file without checking how much data it contains, so a file that is too big spills past the space reserved for it and overwrites the part of memory that tells the processor what to run next. An attacker who controls that value can make the game run their own code instead.

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 from Valve

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.