Name |
Buffer Overflow via Parameter Expansion |
|
Likelyhood of attack |
Typical severity |
Medium |
High |
|
Summary |
In this attack, the target software is given input that the adversary knows will be modified and expanded in size during processing. This attack relies on the target software failing to anticipate that the expanded data may exceed some internal limit, thereby creating a buffer overflow. |
Prerequisites |
The program expands one of the parameters passed to a function with input controlled by the user, but a later function making use of the expanded parameter erroneously considers the original, not the expanded size of the parameter. The expanded parameter is used in the context where buffer overflow may become possible due to the incorrect understanding of the parameter size (i.e. thinking that it is smaller than it really is). |
Execution Flow |
Step |
Phase |
Description |
Techniques |
1 |
Explore |
[Identify target application] The adversary identifies a target application or program to perform the buffer overflow on. Adversaries often look for applications that accept user input and that perform manual memory management. |
|
2 |
Experiment |
[Find injection vector] The adversary identifies an injection vector to deliver the excessive content to the targeted application's buffer. |
- In this attack, the normal method of providing large user input does not work. The program performs bounds checking on the user input, but not the expanded user input. The adversary needs to provide input that they believe will be expanded by the program to overflow a buffer. To identify where this is possible, an adversary either needs to have knowledge of the inner workings of the program or use a disassembler and other reverse engineering tools to guide the search.
|
3 |
Experiment |
[Craft overflow content] The adversary crafts the input to be given to the program. If the intent is to simply cause the software to crash, the input needs only to expand to an excessive quantity of random data. If the intent is to leverage the overflow for execution of arbitrary code, the adversary will craft input that expands in a way that not only overflows the targeted buffer but does so in such a way that the overwritten return address is replaced with one of the adversaries' choosing which points to code injected by the adversary. |
- Create specific files and directories on the system and then give input using path traversal shortcuts to those directories that could expand past an input buffer.
|
4 |
Exploit |
[Overflow the buffer] Using the injection vector, the adversary gives the crafted input to the program, overflowing the buffer. |
|
|
Solutions | Ensure that when parameter expansion happens in the code that the assumptions used to determine the resulting size of the parameter are accurate and that the new size of the parameter is visible to the whole system |
Related Weaknesses |
CWE ID
|
Description
|
CWE-20 |
Improper Input Validation |
CWE-74 |
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') |
CWE-118 |
Incorrect Access of Indexable Resource ('Range Error') |
CWE-119 |
Improper Restriction of Operations within the Bounds of a Memory Buffer |
CWE-120 |
Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') |
CWE-130 |
Improper Handling of Length Parameter Inconsistency |
CWE-131 |
Incorrect Calculation of Buffer Size |
CWE-680 |
Integer Overflow to Buffer Overflow |
CWE-697 |
Incorrect Comparison |
|
Related CAPECS |
CAPEC ID
|
Description
|
CAPEC-100 |
Buffer Overflow attacks target improper or missing bounds checking on buffer operations, typically triggered by input injected by an adversary. As a consequence, an adversary is able to write past the boundaries of allocated buffer regions in memory, causing a program crash or potentially redirection of execution as per the adversaries' choice. |
|