Security weakness
CWE-119 Improper Restriction of Operations within the Bounds of a Memory Buffer
A class-level weakness that can lead to private data exposed, data, pages or code changed and downtime and lost sales. Here is what it is, what it can cost you and how to close it.
- Senior security engineers
- 540+ projects delivered
- Reply within one business day
Quick answer
What is CWE-119?
Improper Restriction of Operations within the Bounds of a Memory Buffer: The product performs operations on a memory buffer, but it reads from or writes to a memory location outside the buffer’s intended boundary.
Business impact
What CWE-119 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.
- Execute Unauthorized Code or Commands
- Modify Memory
- Read Memory
Integrity
Data, pages or code changed
Prices, orders, content or the code your site runs can be altered without your approval.
- Execute Unauthorized Code or Commands
- Modify Memory
Availability
Downtime and lost sales
Crashes, slowdowns or exhausted resources can take your site, store or app offline.
- Execute Unauthorized Code or Commands
- Modify Memory
- Read Memory
Free security check
Is CWE-119 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-119
Improper Restriction of Operations within the Bounds of a Memory Buffer
The product performs operations on a memory buffer, but it reads from or writes to a memory location outside the buffer’s intended boundary.
Also known as: Buffer Overflow, buffer overrun, memory safety
Prevention
How to fix CWE-119, phase by phase
Every mitigation from the CWE entry, in the order a project runs: plan, build, test, operate.
- 01
Requirements
- Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, many languages that perform their own memory management, such as Java and Perl, are not subject to buffer overflows. Other languages, such as Ada and C#, typically provide overflow protection, but the protection can be disabled by the.
- 02
Architecture and Design
- Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. Examples include the Safe C String Library (SafeStr) by Messier and Viega [REF-57], and the Strsafe.h library from Microsoft [REF-56]. These libraries provide safer versions of overflow-prone string-handling functions.
- 03
Implementation
- Consider adhering to the following rules when allocating and managing an application’s memory: Double check that the buffer is as large as specified. When using functions that accept a number of bytes to copy, such as strncpy(), be aware that if the destination buffer size is equal to the source buffer size, it may not NULL-terminate the string. Check buffer boundaries if.
- Replace unbounded copy functions with analogous functions that support length arguments, such as strcpy with strncpy. Create these if they are not available.
- 04
Build and Compilation
- Use automatic buffer overflow detection mechanisms that are offered by certain compilers or compiler extensions. Examples include: the Microsoft Visual Studio /GS flag, Fedora/Red Hat FORTIFY_SOURCE GCC flag, StackGuard, and ProPolice, which provide various mechanisms including canary-based detection and range/index checking. D3-SFCV (Stack Frame Canary Validation) from D3FEND.
- Run or compile the software using features or extensions that randomly arrange the positions of a program’s executable and libraries in memory. Because this makes the addresses unpredictable, it can prevent an attacker from reliably jumping to exploitable code. Examples include Address Space Layout Randomization (ASLR) [REF-58] [REF-60] and Position-Independent Executables.
- 05
Operation
- Use a CPU and operating system that offers Data Execution Protection (using hardware NX or XD bits) or the equivalent techniques that simulate this feature in software, such as PaX [REF-60] [REF-61]. These techniques ensure that any instruction executed is exclusively at a memory address that is part of the code segment. For more information on these techniques see D3-PSEP.
Detection and evidence
How CWE-119 is found, and where it has hit
The testing methods MITRE recommends, and real vulnerabilities this weakness has caused.
How it is detected
- Automated Static AnalysisThis weakness can often be detected using automated static analysis tools. Many modern tools use data flow analysis or constraint-based techniques to minimize the number of false positives. Automated static analysis generally does not account for environmental considerations when reporting.
- Automated Dynamic AnalysisThis weakness can be detected using dynamic tools and techniques that interact with the software using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The software’s operation may slow down, but it should not become unstable.
- 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].
- Automated Static Analysis – Binary or BytecodeAccording to SOAR [REF-1479], the following detection techniques may be useful: Binary / Bytecode Quality Analysis Bytecode Weakness Analysis – including disassembler + source code weakness analysis Binary Weakness Analysis – including disassembler + source code weakness analysis
- Manual Static Analysis – Binary or BytecodeAccording to SOAR [REF-1479], the following detection techniques may be useful: Binary / Bytecode disassembler – then use manual analysis for vulnerabilities & anomalies
Real vulnerabilities it caused
- CVE-2021-22991Incorrect URI normalization in application traffic product leads to buffer overflow, as exploited in the wild per CISA KEV.
- CVE-2025-47153Chain: build process for JavaScript runtime environment can have inconsistent sizes for off_t (CWE-1102), allowing out-of-bounds access / segmentation fault (CWE-119)
- CVE-2020-29557Buffer overflow in Wi-Fi router web interface, as exploited in the wild per CISA KEV.
- CVE-2009-2550Classic stack-based buffer overflow in media player using a long entry in a playlist
- CVE-2009-2403Heap-based buffer overflow in media player using a long entry in a playlist
- CVE-2009-0689large precision value in a format string triggers overflow
How we fix it
From finding to fixed: how Codefreex closes CWE-119
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-119
FAQ
CWE-119: FAQs
Short answers for owners and developers. Not sure whether your site is affected? Ask us to check.
What is CWE-119?
CWE-119, “Improper Restriction of Operations within the Bounds of a Memory Buffer”, is a software weakness catalogued by MITRE in the Common Weakness Enumeration. The product performs operations on a memory buffer, but it reads from or writes to a memory location outside the buffer’s intended boundary.
How serious is CWE-119?
MITRE rates the likelihood of exploit as High. It can affect integrity, confidentiality, availability, with impacts such as execute unauthorized code or commands, modify memory, read memory. The real risk depends on where the weakness sits and what data or functions it exposes.
How do you prevent CWE-119?
Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, many languages that perform their own memory management, such as Java and Perl, are not subject to buffer overflows. Other. Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. Examples include the Safe C String Library (SafeStr) by.
Can Codefreex check my site for CWE-119?
Yes. A senior engineer reviews your site, store or app for CWE-119 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.
Which technologies does CWE-119 affect?
MITRE lists it as applicable to Memory-Unsafe, C, C++, Assembly. In practice any software that matches the weakness description can be affected, including custom code, plugins, themes and third-party libraries.
Free security check
Find out if CWE-119 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.