1765
Nature Type ID Name Page
MemberOf 137 Data Neutralization Issues 2311
Applicable Platforms
Language : Not Language-Specific (Prevalence = Undetermined)
Common Consequences
Scope Impact Likelihood
Integrity
Confidentiality
Availability
Modify Application Data
Execute Unauthorized Code or Commands
An attacker could modify the structure of the message or
data being sent to the downstream component, possibly
injecting commands.
Detection Methods
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: Implementation
Strategy = Output Encoding
Use context-aware encoding. That is, understand which encoding is being used by the
downstream component, and ensure that this encoding is used. If an encoding can be specified,
do so, instead of assuming that the default encoding is the same as the default being assumed
by the downstream component.
Phase: Architecture and Design
Strategy = Output Encoding
Where possible, use communications protocols or data formats that provide strict boundaries
between control and data. If this is not feasible, ensure that the protocols or formats allow the
communicating components to explicitly state which encoding/decoding method is being used.
Some template frameworks provide built-in support.
Phase: Architecture and Design
Strategy = Libraries or Frameworks
Use a vetted library or framework that does not allow this weakness to occur or provides
constructs that make this weakness easier to avoid. For example, consider using the
ESAPI Encoding control [REF-45] or a similar tool, library, or framework. These will help
the programmer encode outputs in a manner less prone to error. Note that some template
mechanisms provide built-in support for the appropriate encoding.
Demonstrative Examples
Example 1:
This code dynamically builds an HTML page using POST data:
CWE Version 4.14
CWE-838: Inappropriate Encoding for Output Context
CWE-838: Inappropriate Encoding for Output Context