Live data from Hacker News

Show HN: A CSS Keylogger

github.com

91–100 of 173 posts

Re: Show HN: A CSS Keylogger

#91

Couldn't Content Security Policy (CSP) [1] be used to mitigate this attack? [1]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP

It actually can't. Instagram does use this protect java-script injection from extensions, but clearly injecting CSS is allowed.

But could you use CSP to block the image loading that happens in the CSS with 'img-src' definitions?

Someone else in this thread suggested that as well.

Re: Show HN: A CSS Keylogger

#92
post #39

Earlier quoted context omitted.

If you use React, updating the value on every change is a very common pattern.

Hopefully most are updating the property and not the attribute.

For those that are confused, updating the property would mean:

  this.input.value = 'password'; 
This would be fine. However updating the attribute (the way React recommends it with controlled components) would be something like:

  
This would be vulnerable to the the CSS keylogger.

Re: Show HN: A CSS Keylogger

#93
post #68

Earlier quoted context omitted.

Assuming the server receives the requests in the same order as the requests were sent, which on mobile networks isn't anywhere near so certain.

Even if the attacker got them out of order, it would let them be able to brute force guess in a small number of attempts.

For example, there are about 41,000 possible passwords for a given set of 8 characters, out of around 96^8 possible 8 character passwords (in the ASCII character set).

Re: Show HN: A CSS Keylogger

#94

Earlier quoted context omitted.

Something like conditional formatting maybe? Eg. make negative values red? Make an input field red when it contains an invalid character?

Sounds like the pattern attribute and :invalid selector on will do that. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/in...

What if it's valid? There's a reason we have the phrases "in the red" and "in the black."

Another example where reading the input might be nice:

  input[type="cc-number"][value^="4"]+.cc-system-icon {
    background-image: url('visa.png');
  }input[type="cc-number"][value^="5"]+.cc-system-icon {
    background-image: url('master-card.png');
  }

Re: Show HN: A CSS Keylogger

#95

This is neat but doesn't really work as an attack. The CSS selectors work on the value HtmlNode attribute rather than the Javascript "value" value, which aren't linked normally. The Instagram password field mentioned in the readme.md DOES work this way due to some custom javascript, for reasons that escape me. [edit] Other people pointed this out first. Also, if you are going to all the trouble of making an extension…

Firewalls blocking javascript would let this pass, NoScript users would get their info stolen, CSS injection vulnerabilities may not allow a XSS as well.

If you do control the page, there may not be that many reasons, but if you only have a limited entry-point, this is very interesting.

Re: Show HN: A CSS Keylogger

#96

Earlier quoted context omitted.

No, since it matches only the last character, you watch the requests it makes IN order to get the entire password. As you type "qwerty", it will request "Q", "W", "E", "R", "T", and finally "Y" no permutations needed

Assuming the server receives the requests in the same order as the requests were sent, which on mobile networks isn't anywhere near so certain.

Well it would also not come in the correct order if someone types their password wrong, deletes letters and re-types them, etc. But I assume the idea would be that you'd have a much easier time figuring out the password if you had all the keys they pressed.

Re: Show HN: A CSS Keylogger

#98
post #93
post #68

Earlier quoted context omitted.

Even if the attacker got them out of order, it would let them be able to brute force guess in a small number of attempts.

For example, there are about 41,000 possible passwords for a given set of 8 characters, out of around 96^8 possible 8 character passwords (in the ASCII character set).

Where does 41000 come from?

Re: Show HN: A CSS Keylogger

#99
post #39
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

If you use React, updating the value on every change is a very common pattern.

So with frameworks like React/Vue, every change to a field generates a request? Or are those handled locally in the shadow dom?

Re: Show HN: A CSS Keylogger

#100
post #93

Earlier quoted context omitted.

For example, there are about 41,000 possible passwords for a given set of 8 characters, out of around 96^8 possible 8 character passwords (in the ASCII character set).

Where does 41000 come from?

It's 8! (8 factorial) which is 40320.

This is 127,286,426,869 (~128bn) times smaller than 92^8.

Edit: Note that if you have a repeated character in your 8 charcter password then the number of permutations of the set of 8 (7 distinct) characters is further halved to 20,160.

Post reply on HN