| Impact | Details |
|---|---|
|
Modify Memory; 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.
|
|
Modify Memory; Execute Unauthorized Code or Commands; Bypass Protection Mechanism |
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.
|
|
Modify Memory; 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 |
|---|---|
|
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. |
|
Architecture and Design |
Use an abstraction library to abstract away risky APIs. Not a complete solution.
|
|
Implementation |
Implement and perform bounds checking on input.
|
|
Implementation |
Do not use dangerous functions such as gets. Use safer, equivalent functions which check for boundary errors.
|
|
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 |
| 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, stack-based buffer overflows:
The buffer size is fixed, but there is no guarantee the string in argv[1] will not exceed this size and cause an overflow.
Example 2
This example takes an IP address from a user, verifies that it is well formed and then looks up the hostname and copies it into a buffer.
This function allocates a buffer of 64 bytes to store the hostname, however there is no guarantee that the hostname will not be larger than 64 bytes. If an attacker specifies an address which resolves to a very large hostname, then the function may overwrite sensitive data or even relinquish control flow to the attacker.
Note that this example also contains an unchecked return value (CWE-252) that can lead to a NULL pointer dereference (CWE-476).
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 |
|---|---|
|
Stack-based buffer overflows in SFK for wifi chipset used for IoT/embedded devices, as exploited in the wild per CISA KEV.
|
| 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 |
|
Automated Static Analysis |
Automated 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 searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
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. | 1160 | SEI CERT C Coding Standard - Guidelines 06. Arrays (ARR) |
| 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. | 1365 | ICS Communications: Unreliability |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1366 | ICS Communications: Frail Security in Protocols |
| 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.Other
| Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
|---|---|---|---|
| CLASP | Stack overflow | ||
| Software Fault Patterns | SFP8 | Faulty Buffer Access | |
| CERT C Secure Coding | ARR38-C | Imprecise | Guarantee that library functions do not form invalid pointers |
| CERT C Secure Coding | STR31-C | CWE More Specific | Guarantee that storage for strings has sufficient space for character data and the null terminator |
| Submissions | ||
|---|---|---|
| Submission Date | Submitter | Organization |
|
2006年07月19日
(CWE Draft 3, 2006年07月19日) |
CLASP | |
| Modifications | ||
| Modification Date | Modifier | Organization |
|
2025年09月09日
(CWE 4.18, 2025年09月09日) |
CWE Content Team | MITRE |
| updated Affected_Resources, Functional_Areas, References | ||
|
2025年04月03日
(CWE 4.17, 2025年04月03日) |
CWE Content Team | MITRE |
| updated Applicable_Platforms | ||
| 2023年06月29日 | CWE Content Team | MITRE |
| updated Mapping_Notes, Relationships | ||
| 2023年04月27日 | CWE Content Team | MITRE |
| updated Detection_Factors, Potential_Mitigations, References, Relationships, Time_of_Introduction | ||
| 2022年06月28日 | CWE Content Team | MITRE |
| updated Observed_Examples | ||
| 2021年07月20日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples | ||
| 2021年03月15日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, References | ||
| 2020年06月25日 | CWE Content Team | MITRE |
| updated Common_Consequences | ||
| 2020年02月24日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2019年09月19日 | CWE Content Team | MITRE |
| updated References | ||
| 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 Background_Details, Causal_Nature, Likelihood_of_Exploit, References, Relationships, Taxonomy_Mappings, White_Box_Definitions | ||
| 2014年07月30日 | CWE Content Team | MITRE |
| updated Relationships, Taxonomy_Mappings | ||
| 2012年10月30日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, Potential_Mitigations | ||
| 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年07月27日 | CWE Content Team | MITRE |
| updated Potential_Mitigations, White_Box_Definitions | ||
| 2009年07月17日 | KDM Analytics | |
| Improved the White_Box_Definition | ||
| 2009年01月12日 | CWE Content Team | MITRE |
| updated Common_Consequences, Relationships | ||
| 2008年09月08日 | CWE Content Team | MITRE |
| updated Alternate_Terms, Applicable_Platforms, Background_Details, 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.