CAPECattack pattern
CAPEC-243 XSS Targeting HTML Attributes
Medium
Official page ↗
- Abstraction
- Detailed
- Status
- Draft
- Typical severity
- Medium
- CAPEC version
- 3.9
Description
An adversary inserts commands to perform cross-site scripting (XSS) actions in HTML attributes. Many filters do not adequately sanitize attributes against the presence of potentially dangerous commands even if they adequately sanitize tags. For example, dangerous expressions could be inserted into a style attribute in an anchor tag, resulting in the execution of malicious code when the resulting page is rendered. If a victim is tricked into viewing the rendered page the attack proceeds like a normal XSS attack, possibly resulting in the loss of sensitive cookies or other malicious activities.
Execution flow
1. [Explore] [Survey the application for user-controllable inputs] Using a browser or an automated tool, an adversary follows all public links and actions on a web site. They record all the links, the forms, the resources accessed and all other potential entry-points for the web application.
2. [Experiment] [Probe identified potential entry points for XSS targeting HTML attributes] The adversary uses the entry points gathered in the "Explore" phase as a target list and injects various malicious expressions as input, hoping to embed them as HTML attributes.
3. [Experiment] [Craft malicious XSS URL] Once the adversary has determined which parameters are vulnerable to XSS, they will craft a malicious URL containing the XSS exploit. The adversary can have many goals, from stealing session IDs, cookies, credentials, and page content from the victim.
4. [Exploit] [Get victim to click URL] In order for the attack to be successful, the victim needs to access the malicious URL.
Prerequisites
• The target application must fail to adequately sanitize HTML attributes against the presence of dangerous commands.
Mitigations
• Design: Use libraries and templates that minimize unfiltered input.
• Implementation: Normalize, filter and use an allowlist for all input including that which is not expected to have any scripting content.
• Implementation: The victim should configure the browser to minimize active content from untrusted sources.
Related
Child of · CAPEC (3)
Weakness · CWE (1)
- CWE-83 Improper Neutralization of Script in Attributes in a Web Page weakness
Referenced by CWE · attack pattern (1)
- CWE-83 Improper Neutralization of Script in Attributes in a Web Page weakness