Data Validation & Encoding (VEQ)

DATA VALIDATION & ENCODING
Q

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

How to play?

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:

  1. Non-use or Incorrect Implementation of Parameterized Interfaces: The system either doesn’t use parameterized interfaces for data inputs or implements them incorrectly.
  2. Improper Data Encoding for Context: Data is not encoded correctly based on the context in which it is used.
  3. 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?

  1. Ensure the use of parameterized interfaces for all data inputs and correctly implement them.
  2. Apply proper data encoding techniques based on the specific context of use.
  3. 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

STRIDE: Tampering

OWASP ASVS: 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

CAPEC: 19,63,104,152,160,182,267

OWASP DevGuide: CEC5,CEC6,COE1,SSV7,LF3,LF4

SAFECode: 2,17

CAPEC™ Map

ASVS (5.0) Cheat Sheet Series Index

Attacks

Cross-Site Scripting (XSS)

OWASP Cornucopia

OWASP Cornucopia is a mechanism in the form of a card game to assist software development teams identify security requirements in Agile, conventional and formal development processes. It is language, platform and technology-agnostic, and is free to use. OWASP Cornucopia is licensed under the Creative Commons Attribution-ShareAlike 4.0 license, so you can copy, distribute and transmit the work, and you can adapt it, and use it commercially, but all provided that you attribute the work and if you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar licence to this one.

© 2012-2025 OWASP Foundation. The Open Worldwide Application Security Project (OWASP) is a nonprofit foundation that works to improve the security of software.