Skip to content

Bug class · Advanced

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.

median public bounty
$4,000

Covers CWE 119, 120, 121, 122, 125, 787, 416, 415, 190, 191 and more.

How it works

Full lesson

The pattern behind every report in this class.

Memory corruption is a class of bug where a program reads or writes memory it should not, usually because it trusted a length, size, offset or object lifetime it should have checked. In the reports behind this lesson it is the single most common kind of finding, and it shows up wherever a program takes input it did not create itself: a file it parses, a request it receives, or a structure passed to a driver. The consequence is rarely just a crash. A write past the end of a buffer or a read of freed memory can let an attacker influence control flow, leak memory to defeat protections, or raise privileges from a low-privileged process to SYSTEM or kernel level.

Programs care because the impact is severe and the reach is wide. The evidence spans desktop file parsers, browser engines, Windows kernel and graphics components, file system drivers, network services and embedded devices. In many cases the bug is reachable by simply opening a crafted document, previewing an attachment, visiting a page, or sending a packet to a service, so the attacker often needs little or no interaction beyond normal use.

It is most often found in parsers for complex or legacy formats, in kernel-mode drivers reachable from a local user, and in services that handle network input. CAD and image formats, Office documents, PDF readers, browser scripting engines, Windows kernel and graphics drivers, and file system drivers all recur heavily. The common thread is code that consumes structured input and has to trust fields inside it.

The first step is always the same: untrusted data enters the program. That might be a file the user opens, a document rendered in a preview pane, a page loaded in a browser, a request sent to a network service, or an IOCTL sent to a driver. The program then interprets that data according to a format, reading fields that describe lengths, sizes, offsets, counts or object references.

Things to try

All 11,510

Each line worked in a disclosed report. Test only what a program's scope allows.

Network protocol and server input 1473

  • Send a crafted job with an out-of-range array index to a Data Node and check for an out-of-bounds write.
  • Send a crafted job to a Data Node with an overlong field and check for a buffer overflow.
  • Send overly long strings in the SetAPClientSettings, SetTriggerPPPoEValidate, SetDeviceSettings, SetIPv6PppoeSettings, SetMyDLinkRegistration, SetWLanRadioSecurity, SetWanSettings, SetSysEmailSettings, SetQuickVPNSettings PSK and password, and SetDynamicDNSSettings HNAP requests to prog.cgi.
  • Run tcpdump over crafted capture files covering IPv6, OTV, ATM, Q.933, BEEP, PPP, IEEE 802.11, IPv6 mobility and IPv6 routing headers and watch for out-of-bounds reads or writes.

Other 1213

  • As an authenticated user, run a Lua script that manipulates garbage collection to free an object still referenced, then reuse the freed memory to escape the sandbox.
  • Open a PostScript file with crafted charstring definitions and check for writes past the end of the allocated buffer.
  • Call unserialize on crafted strings in PHP 7 and look for a use-after-free.
  • Load a crafted GGUF vision projector model file with an oversized length field and check for a heap overflow.

Browser engine and DOM lifetime 1017

  • Load crafted web content in the browser engine and watch for a crash from a memory handling flaw or use-after-free.
  • Exercise malformed CSS, function pointers, event handlers, concurrent Ajax requests and setCapture in a browser and look for memory corruption.
  • Exercise WebRTC call flows and look for a use-after-free.
  • Load crafted pages that stress object lifetime in the browser's DOM and scripting paths and watch for crashes or sanitizer reports.

Image and raster format parsers 825

  • Open a crafted CGM file in IrfanView with the CADImage plugin and look for an out-of-bounds read or write.
  • Render crafted images through Skia to provoke out-of-bounds reads.
  • Render crafted images through Skia to provoke uninitialised resource use.
  • Render crafted images through the graphics library to look for heap overflows, out-of-bounds writes and uninitialised value use.

CAD and 3D model formats 765

  • Pass crafted media and .blend files to the Blender executable as command-line arguments to reach the same parsing paths without the GUI.
  • Import crafted .blend files as a library and instantiate objects to trigger version-upgrade and data-loading code paths.
  • Open a PMF file with an oversized length field in Esri ArcReader and check for a heap buffer overflow.
  • Open a VI file with crafted size values and look for an out-of-bounds write in the parser.

Bypasses and variations

All 756
  • Where a fix or mitigation narrows a timing window, the attack variation is to win the race condition to reach the freed object.
  • Deliver the attack through a file the victim opens or a page they visit, so the parser is reached through normal user interaction.
  • The attack can be delivered either by opening a malicious file or by visiting a malicious page that triggers the parser.
  • Exploitation depends on winning a race window, so repeat attempts and widen the timing window.
  • The Preview Pane is an attack vector, so a document can trigger without a full open.
  • Send crafted graphics data from inside an AppContainer to the isolated compilation service to act outside the attacker's security context.

Typical fixes

All 976
  • Validate the length of supplied data against the destination buffer size before copying.
  • Apple fixed most of these with improved bounds checking, improved input validation or improved memory management.
  • Validate that an object still exists before dereferencing or operating on it, and close race windows between freeing and reuse.
  • Add bounds and length checks before copying input into fixed-size buffers.
  • Add correct length and bounds checks before writing to heap or stack buffers.
  • Validate input length and size before any copy into a heap or stack buffer, and reject values that exceed the destination.

Tips for beginners

All 12
  • Start with parsers you can drive yourself. Desktop viewers and editors that open many legacy formats are the richest ground, because each format is a separate attack surface and the code often trusts fields inside the file. Pick one application and one format, and learn its structure before you mutate anything.
  • Focus on length, size, offset and count fields. These are where bounds checks go missing. Vary one field at a time, make it larger than the actual data, negative, or inconsistent with another field, and watch for crashes or memory errors. A crash alone is a lead, not a finding; you need to show what memory was affected.
  • For local privilege escalation, look at kernel-mode drivers and services reachable from a low-privileged user. Exercise IOCTL handlers and object lifetime paths with crafted input and check whether a use-after-free, double free or heap overflow lets you gain higher privileges. Prove the elevation, not just the crash.
  • For network services, test without credentials first. Send crafted requests to handlers that copy input into fixed buffers and look for overflows. If the service is reachable without authentication, that raises the severity, but confirm the impact rather than reporting a bare crash.
  • Remember the preview pane and reading pane. Many document parsers are reached without the user fully opening the file, which changes the threat model and the impact. Test both the full-open path and the preview path, because some flaws trigger only in one.
  • When you suspect a lifetime bug, look for race conditions. If an advisory or code path mentions concurrency, repeat the operation concurrently to widen the window between free and reuse. A use-after-free that only appears under timing pressure is still valid, but you must show a reliable trigger.

Start here: a reading path

Open the path

Clear reports in order, easiest first.

Guides and techniques

View all

The best explainers, cheat sheets and technique posts on Memory corruption, from around the web.

Newest reports

All 18,300

Most recently disclosed.

New Memory corruption reports by email

Follow Memory corruption and get each week's new disclosures in one short email.

Free. New reports for what you follow, weekly by default. One-click unsubscribe. Privacy