WSTG-v42-CLNT-05 / GUIDANCE

Testing for CSS Injection

A CSS Injection vulnerability involves the ability to inject arbitrary CSS code in the context of a trusted web site which is rendered inside a victim's browser. The impact of this type of vulnerability varies based on the supplied CSS payload. It may lead to cross site scripting or data exfiltration. This vulnerability occurs when the application allows user-supplied CSS to interfere with the application's legitimate style sheets. Injecting code in the CSS context may provide an attacker with the ability to execute JavaScript in certain conditions, or to extract sensitive values using CSS selectors and functions able to generate HTTP requests. Generally, allowing users the ability to customize pages by supplying custom CSS files is a considerable risk. The following JavaScript code shows a possible vulnerable script in which the attacker is able to control the location.hash (source) which reaches the cssText function (sink). This particular case may lead to DOM-based XSS in older browser versions; for more information, see the DOM-based XSS Prevention Cheat Sheet. The attacker could target the victim by asking them to visit the following URLs: - www.victim.com/#red;-o-link:' ';-o-link-source:current; (Opera \[8,12\]) - www.victim.com/#red;-:expression(alert(URL=1)); (IE 7/8) The same vulnerability may appear in the case of reflected XSS, for example, in the following PHP code: Further attack scenarios involve the ability to extract data through the adoption of pure CSS rules. Such attacks can be conducted through CSS selectors, leading to the exfiltration of data, for […]

Category
OWASP assurance
Version / scope
OWASP WSTG pinned commit dd33419
Affected / relevant technologies
Web applications
Evidence
Documentation: pinned-source excerpt checked. Execution: not tested. Editorial: curated reference.

Defensive analysis and explicitly authorized assessment only. This website performs no scans, exploitation, model calls or infrastructure changes. Indicators below are investigation opportunities, not proof of compromise or guaranteed detectors.

Mechanism and prerequisites

Apply only to authorized systems and select the relevant scope and verification level. This publisher reference is not evidence of a completed assessment.

Potential impact

The publisher describes a verification objective; applicability does not establish a local defect or a compliance result.

Versioned source scope

This record contains normalized, sometimes shortened source excerpts with editorial safety context. Markup and executable example blocks are omitted. Source-field verification does not establish device testing, a working detector or local applicability.

Publisher: OWASP. Release: OWASP WSTG pinned commit dd33419. Source checked: 2026-11-18.

Source object: document/4-Web_Application_Security_Testing/11-Client-side_Testing/05-Testing_for_CSS_Injection.md.

Attribution and source terms (OWASP contributors · CC BY-SA 4.0)

Detection and investigation

Preserve source timestamps, asset identity and collection context. Correlate independent evidence before attributing malicious intent. In OT, review passive evidence with the process owner; do not induce failures, replay commands or write to controllers to test a hypothesis.

Mitigation and response

Apply changes through the asset owner's approved change and recovery process. Documentation review is separate from successful testing or verified production protection.

Related technical context

No protocol-specific mapping is asserted for this entry.

Authoritative sources and attribution

Identifiers and source titles belong to OWASP, MITRE, the CVE Program, CISA, NIST or the cited vendor. Source excerpts are attributed and adapted under the linked publisher license; editorial context is separate. This is not an official framework mirror. Review baseline: 2026-11-18. Live documents can change; check exact current applicability.

Source review supports bounded reference text. It is not execution evidence, a completeness claim, a CVSS assessment, a compliance certification or verification of production security.