Data Validation & Encoding (VEQ)
Xavier can inject data into a client or device side interpreter because a parameterised interface is not being used, or has not been implemented correctly, or the data has not been encoded, sanitized or escaped correctly for the context, or there is no restrictive policy on code or data includes
This relates to actual exploitation of an injection vulnerability on the client-side (e.g., XSS). See Data Validation & Encoding K (VEK) for the same attack server-side, and other cards in this suit for individual data validation and encoding issues (e.g. missing/by-passable/badly-implemented input/output validation, encoding or sanitization).
Scenario: Xavier’s Client-Side Injection
Visualize a scenario where Xavier capitalizes on vulnerabilities in client-side data handling. He injects malicious data into a client or device side interpreter, exploiting several key oversights:
- Non-use or Incorrect Implementation of Parameterized Interfaces: The system either doesn’t use parameterized interfaces for data inputs or implements them incorrectly.
- Improper Data Encoding for Context: Data is not encoded correctly based on the context in which it is used.
- Lack of Restrictive Policies on Code/Data Includes: The system does not have strict policies governing the inclusion of code or data, allowing potentially harmful content.
Example
Xavier attacks by injecting a script into a web application that lacks proper encoding and parameterization in its data handling. For instance, he enters a script in a text field that is expected to only contain plain text. Since the application does not correctly encode this input for the HTML context, the script is executed when loaded in a user’s browser, leading to a Cross-Site Scripting (XSS) attack.
Threat Modeling
STRIDE
Xavier is modifying the content/behavior of the application delivered to or executed on the client which is classic tampering of data/processing, but the impact can be multiple things (cookie theft → Information Disclosure; session takeover → Elevation of Privilege; forging UI → Spoofing), but the root threat is the attacker tampering with the interpreter’s inputs.
What can go wrong?
This type of vulnerability can lead to client-side attacks like XSS, compromising user data and browser security.
Due a failure of client-side input or output validation, encoding or sanitization, malicious code can be injected and treated as code rather than data, leading to code execution in the client application.
For more things that can go wrong, see the Common Attack Patterns related to this card in the table below.
What are we going to do about it?
- Ensure the use of parameterized interfaces for all data inputs and correctly implement them.
- Apply proper data encoding techniques based on the specific context of use.
- Establish and enforce restrictive policies for code and data inclusion to prevent malicious content injection.
For detailed advice on how to mitigate threats related to the card, see the ASVS and OWASP Developer Guide requirements in the table below.
Mappings
OWASP ASVS (v5.0): 1.1.1,1.2.1,1.2.2,1.2.3,1.3.1,1.3.2,1.3.3,1.3.4,1.3.5,1.3.6,1.3.7,2.1.1,3.1.1,3.2.1,3.2.2,3.2.3,3.4.3,3.4.4,3.4.6,3.4.7,3.4.8,3.5.4,3.5.5,3.5.6,3.5.7,3.5.8,3.6.1,3.7.1,3.7.5,4.1.1,15.3.5,15.3.6,16.3.3
OWASP DevGuide: CEC5,CEC6,COE1,SSV7,LF3,LF4
STRIDE: Tampering
CAPEC™: 19,63,104,152,160,182,267