| Impact | Details |
|---|---|
|
Modify Memory; DoS: Crash, Exit, or Restart |
Scope: Integrity, Availability
Out of bounds memory access will very likely result in the corruption of relevant memory, and perhaps instructions, possibly leading to a crash.
|
|
Execute Unauthorized Code or Commands; Modify Memory; Bypass Protection Mechanism; Other |
Scope: Integrity, Confidentiality, Availability, Access Control, Other
If the corrupted memory can be effectively controlled, it may be possible to execute arbitrary code. If the corrupted memory is data rather than instructions, the system will continue to function with improper changes, possibly in violation of an implicit or explicit policy. The consequences would only be limited by how the affected data is used, such as an adjacent memory location that is used to specify whether the user has special privileges.
|
|
Bypass Protection Mechanism; Other |
Scope: Access Control, Other
When the consequence is arbitrary code execution, this can often be used to subvert any other security service.
|
| Phase(s) | Mitigation |
|---|---|
|
Requirements |
Choose a language that is not susceptible to these issues.
|
|
Implementation |
All calculated values that are used as index or for pointer arithmetic should be validated to ensure that they are within an expected range.
|
| 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. | 786 | Access of Memory Location Before Start of Buffer |
| 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 |
| CanFollow | 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. | 839 | Numeric Range Comparison Without Minimum Check |
| Nature | Type | ID | Name |
|---|---|---|---|
| MemberOf | Category Category - a CWE entry that contains a set of other entries that share a common characteristic. | 1218 | Memory Buffer Errors |
| Phase | Note |
|---|---|
| Implementation |
C (Undetermined Prevalence)
C++ (Undetermined Prevalence)
Example 1
In the following C/C++ example, a utility function is used to trim trailing whitespace from a character string. The function copies the input string to a local character string and uses a while statement to remove the trailing whitespace by moving backward through the string and overwriting whitespace with a NUL character.
However, this function can cause a buffer underwrite if the input character string contains all whitespace. On some systems the while statement will move backwards past the beginning of a character string and will call the isspace() function on an address outside of the bounds of the local buffer.
Example 2
The following is an example of code that may result in a buffer underwrite. This code is attempting to replace the substring "Replace Me" in destBuf with the string stored in srcBuf. It does so by using the function strstr(), which returns a pointer to the found substring in destBuf. Using pointer arithmetic, the starting index of the substring is found.
In the case where the substring is not found in destBuf, strstr() will return NULL, causing the pointer arithmetic to be undefined, potentially setting the value of idx to a negative number. If idx is negative, this will result in a buffer underwrite of destBuf.
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 |
|---|---|
|
buffer underwrite in firmware verification routine allows code execution via a crafted firmware image
|
|
|
Unchecked length of SSLv2 challenge value leads to buffer underflow.
|
|
|
Buffer underflow from a small size value with a large buffer (length parameter inconsistency, CWE-130)
|
|
|
Buffer underflow from an all-whitespace string, which causes a counter to be decremented before the buffer while looking for a non-whitespace character.
|
|
|
Buffer underflow resultant from encoded data that triggers an integer overflow.
|
|
|
Product sets an incorrect buffer size limit, leading to "off-by-two" buffer underflow.
|
|
|
Negative value is used in a memcpy() operation, leading to buffer underflow.
|
|
|
Buffer underflow due to mishandled special characters
|
| Ordinality | Description |
|---|---|
|
Primary
|
(where the weakness exists independent of other weaknesses)
|
| 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. | 1399 | Comprehensive Categorization: Memory Safety |
Rationale
This CWE entry is at the Base 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 |
|---|---|---|---|
| PLOVER | UNDER - Boundary beginning violation ('buffer underflow'?) | ||
| CLASP | Buffer underwrite | ||
| Software Fault Patterns | SFP8 | Faulty Buffer Access |
| Submissions | |||
|---|---|---|---|
| Submission Date | Submitter | Organization | |
|
2006年07月19日
(CWE Draft 3, 2006年07月19日) |
PLOVER | ||
| Contributions | |||
| Contribution Date | Contributor | Organization | |
| 2023年02月06日 | Muchen Xu | Naive Systems | |
| Pointed out that the demonstrative example #2 was incorrect and instead demonstrated a Buffer Under-read. | |||
| Modifications | |||
| Modification Date | Modifier | Organization | |
|
2025年09月09日
(CWE 4.18, 2025年09月09日) |
CWE Content Team | MITRE | |
| updated Affected_Resources, Functional_Areas | |||
|
2024年02月29日
(CWE 4.14, 2024年02月29日) |
CWE Content Team | MITRE | |
| updated Demonstrative_Examples | |||
| 2023年06月29日 | CWE Content Team | MITRE | |
| updated Mapping_Notes | |||
| 2023年04月27日 | CWE Content Team | MITRE | |
| updated References, Relationships, Time_of_Introduction | |||
| 2023年01月31日 | CWE Content Team | MITRE | |
| updated Description | |||
| 2022年04月28日 | CWE Content Team | MITRE | |
| updated Research_Gaps | |||
| 2021年10月28日 | CWE Content Team | MITRE | |
| updated Observed_Examples | |||
| 2021年03月15日 | CWE Content Team | MITRE | |
| updated Potential_Mitigations | |||
| 2020年02月24日 | CWE Content Team | MITRE | |
| updated Relationships | |||
| 2017年11月08日 | CWE Content Team | MITRE | |
| updated Causal_Nature, Demonstrative_Examples, References | |||
| 2014年07月30日 | CWE Content Team | MITRE | |
| updated Relationships, Taxonomy_Mappings | |||
| 2012年05月11日 | CWE Content Team | MITRE | |
| updated Demonstrative_Examples, References, Relationships | |||
| 2011年06月01日 | CWE Content Team | MITRE | |
| updated Common_Consequences | |||
| 2011年03月29日 | CWE Content Team | MITRE | |
| updated Demonstrative_Examples, Relationships | |||
| 2009年10月29日 | CWE Content Team | MITRE | |
| updated Description, Name, Relationships | |||
| 2009年01月12日 | CWE Content Team | MITRE | |
| updated Common_Consequences | |||
| 2008年09月08日 | CWE Content Team | MITRE | |
| updated Alternate_Terms, Applicable_Platforms, Common_Consequences, Description, Relationships, Relationship_Notes, Taxonomy_Mappings, Weakness_Ordinalities | |||
| 2008年07月01日 | Eric Dalci | Cigital | |
| updated Time_of_Introduction | |||
| Previous Entry Names | |||
| Change Date | Previous Entry Name | ||
| 2009年10月29日 | Boundary Beginning Violation ('Buffer Underwrite') | ||
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.