CAPECattack pattern
CAPEC-18 XSS Targeting Non-Script Elements
Very High
Official page ↗
- Abstraction
- Detailed
- Status
- Draft
- Likelihood of attack
- High
- Typical severity
- Very High
- CAPEC version
- 3.9
Description
This attack is a form of Cross-Site Scripting (XSS) where malicious scripts are embedded in elements that are not expected to host scripts such as image tags (<img>), comments in XML documents (< !-CDATA->), etc. These tags may not be subject to the same input validation, output validation, and other content filtering and checking routines, so this can create an opportunity for an adversary to tunnel through the application's elements and launch a XSS attack through other elements. As with all remote attacks, it is important to differentiate the ability to launch an attack (such as probing an internal network for unpatched servers) and the ability of the remote adversary to collect and interpret the output of said attack.
Execution flow
1. [Explore] [Survey the application for user-controllable inputs] Using a browser or an automated tool, an adversary records all entry points for inputs that happen to be reflected in a client-side non-script element. These non-script elements can be located in the HTML content (head, body, comments), in an HTML tag, XML, CSS, etc.
2. [Experiment] [Probe identified potential entry points for XSS vulnerability] The adversary uses the entry points gathered in the "Explore" phase as a target list and injects various common script payloads to determine if an entry point actually represents a vulnerability and to characterize the extent to which the vulnerability can be exploited.
3. [Experiment] [Create malicious XSS content] Once the adversary has determined which entry points are vulnerable to XSS, they will interact with the web application to store the malicious content. Because of the nature of this attack, it is mostly carried out through stored XSS, although it is possible to perform this attack using reflected XSS. The adversary can have many goals, from stealing session IDs, cookies, credentials, and page content from a victim.
4. [Exploit] [Get victim to view stored content] In order for the attack to be successful, the victim needs to view the stored malicious content on the webpage.
Prerequisites
• The target client software must allow the execution of scripts generated by remote hosts.
Skills required
• [Low] To achieve a redirection and use of less trusted source, an adversary can simply edit content such as XML payload or HTML files that are sent to client machine.
• [High] Exploiting a client side vulnerability to inject malicious scripts into the browser's executable process.
Consequences
• Confidentiality, Integrity, Availability: Execute Unauthorized Commands
• Confidentiality: Read Data
Mitigations
• In addition to the traditional input fields, all other user controllable inputs, such as image tags within messages or the likes, must also be subjected to input validation. Such validation should ensure that content that can be potentially interpreted as script by the browser is appropriately filtered.
• All output displayed to clients must be properly escaped. Escaping ensures that the browser interprets special scripting characters literally and not as script to be executed.
Related
Child of · CAPEC (3)
Weakness · CWE (1)
- CWE-80 Improper Neutralization of Script-Related HTML Tags in a Web Page weakness
Referenced by CWE · attack pattern (1)
- CWE-80 Improper Neutralization of Script-Related HTML Tags in a Web Page weakness