| Impact | Details |
|---|---|
|
DoS: Crash, Exit, or Restart; DoS: Resource Consumption (CPU); DoS: Resource Consumption (Memory) |
Scope: Availability
Buffer overflows generally lead to crashes. Other attacks leading to lack of availability are possible, including putting the program into an infinite loop.
|
|
Execute Unauthorized Code or Commands; Bypass Protection Mechanism; Modify Memory |
Scope: Integrity, Confidentiality, Availability, Access Control
Buffer overflows often can be used to execute arbitrary code, which is usually outside the scope of a program's implicit security policy. Besides important user data, heap-based overflows can be used to overwrite function pointers that may be living in memory, pointing it to the attacker's code. Even in applications that do not explicitly use function pointers, the run-time will usually leave many in memory. For example, object methods in C++ are generally implemented using function pointers. Even in C programs, there is often a global offset table used by the underlying runtime.
|
|
Execute Unauthorized Code or Commands; Bypass Protection Mechanism; Other |
Scope: Integrity, Confidentiality, Availability, Access Control, Other
When the consequence is arbitrary code execution, this can often be used to subvert any other security service.
|
| Phase(s) | Mitigation |
|---|---|
|
Pre-design: Use a language or compiler that performs automatic bounds checking.
|
|
|
Architecture and Design |
Use an abstraction library to abstract away risky APIs. Not a complete solution.
|
|
Operation; Build and Compilation |
Strategy: Environment Hardening 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 [REF-1334] discusses canary-based detection in detail. Effectiveness: Defense in Depth Note:
This is not necessarily a complete solution, since these mechanisms only detect certain types of overflows. In addition, the result is still a denial of service, since the typical response is to exit the application. |
|
Operation; Build and Compilation |
Strategy: Environment Hardening 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 (PIE) [REF-64]. Imported modules may be similarly realigned if their default memory addresses conflict with other modules, in a process known as "rebasing" (for Windows) and "prelinking" (for Linux) [REF-1332] using randomly generated addresses. ASLR for libraries cannot be used in conjunction with prelink since it would require relocating the libraries at run-time, defeating the whole purpose of prelinking. For more information on these techniques see D3-SAOR (Segment Address Offset Randomization) from D3FEND [REF-1335]. Effectiveness: Defense in Depth |
|
Implementation |
Implement and perform bounds checking on input.
|
|
Implementation |
Strategy: Libraries or Frameworks Do not use dangerous functions such as gets. Look for their safe equivalent, which checks for the boundary.
|
|
Operation |
Use OS-level preventative functionality. This is not a complete solution, but it provides some defense in depth.
|
| Nature | Type | ID | Name |
|---|---|---|---|
| ChildOf | Base Base - a weakness that is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource. | 787 | Out-of-bounds Write |
| ChildOf | Base Base - a weakness that is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource. | 788 | Access of Memory Location After End of Buffer |
| Phase | Note |
|---|---|
| Implementation |
C (Often Prevalent)
C++ (Often Prevalent)
Example 1
While buffer overflow examples can be rather complex, it is possible to have very simple, yet still exploitable, heap-based buffer overflows:
The buffer is allocated heap memory with a fixed size, but there is no guarantee the string in argv[1] will not exceed this size and cause an overflow.
Example 2
This example applies an encoding procedure to an input string and stores it into a buffer.
The programmer attempts to encode the ampersand character in the user-controlled string, however the length of the string is validated before the encoding procedure is applied. Furthermore, the programmer assumes encoding expansion will only expand a given character by a factor of 4, while the encoding of the ampersand expands by 5. As a result, when the encoding procedure expands the string it is possible to overflow the destination buffer if the attacker provides a string of many ampersands.
Note: this is a curated list of examples for users to understand the variety of ways in which this weakness can be introduced. It is not a complete list of all CVEs that are related to this CWE entry.
| Reference | Description |
|---|---|
| Ordinality | Description |
|---|---|
|
Primary
|
(where the weakness exists independent of other weaknesses)
|
| Method | Details |
|---|---|
|
Fuzzing |
Fuzz 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, or resource consumption. Fuzzing effectively produces repeatable test cases that clearly indicate bugs, which helps developers to diagnose the issues.
Effectiveness: High |
| Nature | Type | ID | Name |
|---|---|---|---|
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 970 | SFP Secondary Cluster: Faulty Buffer Access |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1161 | SEI CERT C Coding Standard - Guidelines 07. Characters and Strings (STR) |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1399 | Comprehensive Categorization: Memory Safety |
Rationale
This CWE entry is at the Variant level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.Comments
Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.Relationship
| Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
|---|---|---|---|
| CLASP | Heap overflow | ||
| Software Fault Patterns | SFP8 | Faulty Buffer Access | |
| CERT C Secure Coding | STR31-C | CWE More Specific | Guarantee that storage for strings has sufficient space for character data and the null terminator |
| ISA/IEC 62443 | Part 4-2 | Req CR 3.5 | |
| ISA/IEC 62443 | Part 3-3 | Req SR 3.5 | |
| ISA/IEC 62443 | Part 4-1 | Req SI-1 | |
| ISA/IEC 62443 | Part 4-1 | Req SI-2 | |
| ISA/IEC 62443 | Part 4-1 | Req SVV-1 | |
| ISA/IEC 62443 | Part 4-1 | Req SVV-3 |
| CAPEC-ID | Attack Pattern Name |
|---|---|
| CAPEC-92 | Forced Integer Overflow |
| Submissions | ||
|---|---|---|
| Submission Date | Submitter | Organization |
|
2006年07月19日
(CWE Draft 3, 2006年07月19日) |
CLASP | |
| Contributions | ||
| Contribution Date | Contributor | Organization |
|
2023年11月14日
(CWE 4.14, 2024年02月29日) |
participants in the CWE ICS/OT SIG 62443 Mapping Fall Workshop | |
| Contributed or reviewed taxonomy mappings for ISA/IEC 62443 | ||
| Modifications | ||
| Modification Date | Modifier | Organization |
|
2025年09月09日
(CWE 4.18, 2025年09月09日) |
CWE Content Team | MITRE |
| updated Functional_Areas, References | ||
|
2025年04月03日
(CWE 4.17, 2025年04月03日) |
CWE Content Team | MITRE |
| updated Applicable_Platforms | ||
|
2024年02月29日
(CWE 4.14, 2024年02月29日) |
CWE Content Team | MITRE |
| updated Observed_Examples, Taxonomy_Mappings | ||
| 2023年10月26日 | CWE Content Team | MITRE |
| updated Observed_Examples | ||
| 2023年06月29日 | CWE Content Team | MITRE |
| updated Mapping_Notes | ||
| 2023年04月27日 | CWE Content Team | MITRE |
| updated Detection_Factors, Potential_Mitigations, References, Relationships, Time_of_Introduction | ||
| 2021年07月20日 | CWE Content Team | MITRE |
| updated Observed_Examples | ||
| 2021年03月15日 | CWE Content Team | MITRE |
| updated References | ||
| 2020年02月24日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2019年01月03日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2018年03月27日 | CWE Content Team | MITRE |
| updated References | ||
| 2017年11月08日 | CWE Content Team | MITRE |
| updated Causal_Nature, Likelihood_of_Exploit, Observed_Examples, References, Relationships, Taxonomy_Mappings, White_Box_Definitions | ||
| 2014年07月30日 | CWE Content Team | MITRE |
| updated Relationships, Taxonomy_Mappings | ||
| 2014年06月23日 | CWE Content Team | MITRE |
| updated Observed_Examples | ||
| 2013年02月21日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, Potential_Mitigations | ||
| 2012年10月30日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples | ||
| 2012年05月11日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, References, Relationships | ||
| 2011年06月01日 | CWE Content Team | MITRE |
| updated Common_Consequences | ||
| 2010年02月16日 | CWE Content Team | MITRE |
| updated References | ||
| 2009年10月29日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2009年01月12日 | CWE Content Team | MITRE |
| updated Common_Consequences, Relationships | ||
| 2008年11月24日 | CWE Content Team | MITRE |
| updated Common_Consequences, Other_Notes, Relationship_Notes | ||
| 2008年09月08日 | CWE Content Team | MITRE |
| updated Applicable_Platforms, Common_Consequences, Relationships, Other_Notes, Taxonomy_Mappings, Weakness_Ordinalities | ||
| 2008年08月01日 | KDM Analytics | |
| added/updated white box definitions | ||
| 2008年07月01日 | Eric Dalci | Cigital |
| updated Potential_Mitigations, Time_of_Introduction | ||
Use of the Common Weakness Enumeration (CWE™) and the associated references from this website are subject to the Terms of Use. CWE is sponsored by the U.S. Department of Homeland Security (DHS) Cybersecurity and Infrastructure Security Agency (CISA) and managed by the Homeland Security Systems Engineering and Development Institute (HSSEDI) which is operated by The MITRE Corporation (MITRE). Copyright © 2006–2025, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation.