1279
Nature Type ID Name Page
MemberOf 1006 Bad Coding Practices 2422
Weakness Ordinalities
Indirect :
Primary :
Applicable Platforms
Language : C (Prevalence = Undetermined)
Language : C++ (Prevalence = Undetermined)
Common Consequences
Scope Impact Likelihood
Availability
Integrity
Confidentiality
Read Memory
Modify Memory
Execute Unauthorized Code or Commands
DoS: Crash, Exit, or Restart
If the returned stack buffer address is dereferenced after
the return, then an attacker may be able to modify or read
memory, depending on how the address is used. If the
address is used for reading, then the address itself may
be exposed, or the contents that the address points to. If
the address is used for writing, this can lead to a crash and
possibly code execution.
Detection Methods
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
Potential Mitigations
Phase: Testing
Use static analysis tools to spot return of the address of a stack variable.
Demonstrative Examples
Example 1:
The following function returns a stack address.
CWE Version 4.14
CWE-563: Assignment to Variable without Use
CWE-563: Assignment to Variable without Use