Security weaknessCWE Top 25 · #8
CWE-125 Out-of-bounds read
Software reads memory outside the area it should, which can leak secrets or crash the program.
- Senior security engineers
- 540+ projects delivered
- Reply within one business day
Quick answer
What is CWE-125?
Out-of-bounds Read: The product reads data past the end, or before the beginning, of the intended buffer.
Business impact
What CWE-125 could cost your business
MITRE documents what this weakness can do. Here is what that means for a website, store or app.
Confidentiality
Private data exposed
Customer records, credentials, orders or internal files can be read by people who should never see them.
- Read Memory
- Bypass Protection Mechanism
Availability
Downtime and lost sales
Crashes, slowdowns or exhausted resources can take your site, store or app offline.
- DoS: Crash, Exit, or Restart
In plain English
What Out-of-bounds read means for your business
- 540+projects delivered
- 9+years in business
- 23+certified experts
A senior engineer replies within one business day.
An out-of-bounds read happens when a program reads past the end of a block of memory, or before its start. The program expected a certain amount of data and trusted a length or position that turned out to be wrong. Instead of stopping, it keeps reading whatever sits nearby. That nearby memory can hold anything the program was working with at the time, including data from other users.
The main risk is information exposure. Memory next to a buffer may contain passwords, session tokens, encryption keys or personal data, and a crafted request can cause the program to send it back. It can also reveal memory addresses that help an attacker exploit a second flaw. For a website owner, this matters when it affects the server software, encryption library or file parsers your site relies on. A crash is the other common outcome.
Where it shows up
- Encryption, compression and networking libraries on your server that parse length fields in data sent by a remote client.
- Image, font and document parsers written in C or C++ that process files uploaded by customers or fetched from other sites.
- Native mobile apps and games that read binary data, such as media files or network messages, using C or C++ code.
- Embedded and IoT firmware, and outdated web server, proxy or database software running underneath an otherwise up-to-date website.
Free security check
Is CWE-125 hiding in your site?
A senior engineer checks your site, store or app for this weakness and the rest of the CWE Top 25, then sends a prioritized fix plan within one business day. No obligation.
Official definition
How MITRE defines CWE-125
Out-of-bounds Read
The product reads data past the end, or before the beginning, of the intended buffer.
Also known as: OOB read
Fix it
How to fix Out-of-bounds read
Practical steps in priority order. Share them with your developer or agency.
Keep server software and libraries patched
Update the operating system, web server, TLS library, language runtime and file-processing libraries as security releases arrive. Remove components you no longer use, so there is less native code exposed to outside input.
Validate lengths and indexes
In native code, check every length, offset and index from outside input against the real buffer size before reading. Do not assume a terminator or sentinel value is present. Reject input whose declared size does not match its actual size.
Use memory-safe languages and types
Write parsers and network code in a language with bounds checking, such as Rust, Go, Java or C#. In C++, prefer containers and span types with checked access over raw pointers and manual arithmetic.
Isolate file and data parsing
Process untrusted files in a sandboxed, low-privilege worker or container with no access to secrets. If a parser reads out of bounds, there is then little sensitive memory nearby to leak.
Fuzz parsers with sanitizers
Run fuzz testing against every parser and protocol handler with AddressSanitizer enabled, so out-of-bounds reads are reported instead of passing silently. Add static analysis to continuous integration to flag unchecked lengths early.
Signs you may be affected
- Your hosting stack includes native libraries or server software that no longer receive security updates.
- A service returns garbled or unexpected data, or crashes, when given malformed files or requests.
- Vulnerability scans report information disclosure or memory read advisories in components you depend on.
Questions to ask your developer
- Which native libraries handle uploads and encrypted connections on our server?
- After a library patch, do we rotate keys and passwords that may have leaked?
- Is file processing separated from the main application and its secrets?
Prevention
What MITRE recommends, phase by phase
Every mitigation from the CWE entry, in the order a project runs: plan, build, test, operate.
- 01
Architecture and Design
- Use a language that provides appropriate memory abstractions.
- 02
Implementation
- Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of.
Detection and evidence
How CWE-125 is found, and where it has hit
The testing methods MITRE recommends, and real vulnerabilities this weakness has caused.
How it is detected
- FuzzingFuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs – either randomly or algorithmically – and dynamically invoking the code with those inputs. Even with random inputs, it is often capable of generating unexpected results such as crashes, memory corruption.
- Automated Static AnalysisAutomated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then.
- Automated Dynamic AnalysisUse tools that are integrated during compilation to insert runtime error-checking mechanisms related to memory safety errors, such as AddressSanitizer (ASan) for C/C++ [REF-1518].
Real vulnerabilities it caused
- CVE-2026-7320Out-of-bounds read in audio processor used in a common web browser, allowing a read of the global data section
- CVE-2023-1018The reference implementation code for a Trusted Platform Module does not implement length checks on data, allowing for an attacker to read 2 bytes past the end of a buffer.
- CVE-2020-11899Out-of-bounds read in IP stack used in embedded systems, as exploited in the wild per CISA KEV.
- CVE-2014-0160Chain: "Heartbleed" bug receives an inconsistent length parameter (CWE-130) enabling an out-of-bounds read (CWE-126), returning memory that could include private cryptographic keys and other sensitive data.
- CVE-2021-40985HTML conversion package has a buffer under-read, allowing a crash
- CVE-2018-10887Chain: unexpected sign extension (CWE-194) leads to integer overflow (CWE-190), causing an out-of-bounds read (CWE-125)
How we fix it
From finding to fixed: how Codefreex closes CWE-125
Scan and confirm
We test your site, store or app for this weakness and the rest of the CWE Top 25 with automated scanning and manual review, and confirm what is actually exploitable.
Fix at the source
We change the code, configuration or dependency that causes it, not just the symptom, and plan the changes to avoid downtime.
Verify the fix
We retest every finding, check that nothing else broke and hand you a short report you can share with your team, client or auditor.
Keep it fixed
Updates, monitoring and maintenance so the weakness does not return with the next plugin, theme, app or code change.
Website SecurityPenetration TestingMalware Removal & Hack RepairWordPress Maintenance
Related weaknesses
Weaknesses related to CWE-125
FAQ
CWE-125: FAQs
Short answers for owners and developers. Not sure whether your site is affected? Ask us to check.
Why does an out-of-bounds read matter if nothing is changed?
Because reading is enough to cause harm. Memory beside a buffer can hold session tokens, passwords, keys or personal data. A flaw that returns that memory to a remote user exposes it without leaving obvious traces. It can also reveal memory layout details that make a separate code-execution flaw easier to exploit. It can crash the program too.
What should I do if a library my site uses has this flaw?
Update the library to a fixed version and restart the services that load it. Then consider what may have been in memory. If the affected component handled logins or encrypted traffic, rotate secrets such as keys, passwords and session tokens. Check with your host or developer that every server and container image received the update.
How are out-of-bounds reads prevented?
Validate every length and position before reading, and never trust size values supplied in a file or message. Use languages and data types that check bounds automatically. Test parsers with fuzzing and memory sanitizers. For software you do not maintain yourself, stay on supported versions and apply security updates without long delays.
What is CWE-125?
CWE-125, “Out-of-bounds Read”, is a software weakness catalogued by MITRE in the Common Weakness Enumeration. The product reads data past the end, or before the beginning, of the intended buffer.
How serious is CWE-125?
It can affect confidentiality, availability, other, with impacts such as read memory, bypass protection mechanism, dos: crash, exit, or restart. It ranks number 8 on the 2025 CWE Top 25 Most Dangerous Software Weaknesses. The real risk depends on where the weakness sits and what data or functions it exposes.
How do you prevent CWE-125?
Assume all input is malicious. Use an “accept known good” input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into. Use a language that provides appropriate memory abstractions.
Can Codefreex check my site for CWE-125?
Yes. A senior engineer reviews your site, store or app for CWE-125 and the rest of the CWE Top 25, confirms what is exploitable and sends a prioritized fix plan within one business day. Start with the free security check form on this page.
Free security check
Find out if CWE-125 affects your site
Send your URL. A senior engineer checks for this weakness and the rest of the CWE Top 25, and replies within one business day with what to fix first.
- A senior strategist reviews your request, not a sales bot
- Clear scope, timeline and estimate within one business day
- Free 30-minute discovery call, no obligation
- NDA available on request
- Emailhello@codefreex.com
- CallUSA +1 (209) 375-3475 · India +91 790 3375 530
- Prefer to talk?Book a 30-minute call
Weakness data from the Common Weakness Enumeration (CWE®) version 5.0, Copyright © 2006–2026, The MITRE Corporation. CWE is free to use by any organization or individual for any research, development, and/or commercial purposes under the CWE Terms of Use. CWE is a registered trademark of The MITRE Corporation. The business impact, risk profile and plain-English guidance on this page are written by Codefreex and are general information, not a security assessment of your system.