Definition

MITRE’s description of CWE-125: The product reads data past the end, or before the beginning, of the intended buffer.

Common consequences MITRE lists

  • Confidentiality: Read Memory
  • Confidentiality: Bypass Protection Mechanism
  • Availability: DoS: Crash, Exit, or Restart
  • Other: Varies by Context

Why it matters

Reading past a buffer leaks adjacent memory, such as keys, session data or pointers that help defeat ASLR, and can crash the process.

How to prevent it

  • Check every length field and offset taken from input against the actual buffer size before reading.
  • Prefer memory-safe languages and bounds-checked accessors for parsers and decoders.
  • Fuzz with sanitizers and keep each crashing input as a regression test.

Guides on this site

Practice

References

  1. CWE-125 in the MITRE CWE list (version 4.20)
  2. 2025 CWE Top 25 Most Dangerous Software Weaknesses (MITRE CWE Program)

List data from MITRE; the name, definition and consequences are from MITRE’s CWE 4.20 catalogue. A guide is listed as the main subject when the weakness is what the guide is about, and as covering it when a dedicated section or worked example addresses it.

CWE content: Copyright © 2006–2026, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation. CWE™ is free to use by any organization or individual for any research, development, and/or commercial purposes, per these CWE Terms of Use. Accordingly, The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. Any copy you make for such purposes is authorized on the condition that you reproduce MITRE’s copyright designation and this license in any such copy. CWE is a trademark of The MITRE Corporation. CWE Terms of Use.