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.
Show HN: A CSS Keylogger
161–170 of 173 posts
Re: Show HN: A CSS Keylogger
#162This has nothing to do with vulnerabilities in CSS or Javascript. It has to do with ill-conceived authentication implementations, written in Javascript, that save passwords in the DOM using attributes that are then accessible via CSS. That is a vulnerability on the website itself. It is also an idiotic thing to do.
Re: Show HN: A CSS Keylogger
#163Earlier quoted context omitted.
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.
That being said, you might be thinking about this incorrectly if you're doing this. You can use a form and grab the values on submission. this.handleSubmission = event => { // access to event.target.password.value }
Re: Show HN: A CSS Keylogger
#164Earlier quoted context omitted.
You can still do form validation on submit though, according to dimgl's earlier comment: https://news.ycombinator.com/item?id=16426131
Very good point! With that method you can still display validation errors in a “Reacty” way. But you still don’t get pre-submit validation, like marking an input invalid on blur, or displaying real-time password strength.
The only thing it affects is your ability to change the input's data via a state change, but for a password field would you ever want to do anything but get its current value or clear it?
Re: Show HN: A CSS Keylogger
#165Earlier quoted context omitted.
Very good point! With that method you can still display validation errors in a “Reacty” way. But you still don’t get pre-submit validation, like marking an input invalid on blur, or displaying real-time password strength.
You can still capture an uncontrolled input's data `onChange` and `onBlur` for validation, password strength checking, later submission etc., you just don't reflect it back into the input on every render. The only thing it affects is your ability to change the input's data via a state change, but for a password field would you ever want to do anything but get its current value or clear it?
And yes, for password inputs, I can’t think of a case where you would absolutely need to control the value via React. Things like password confirmation validation and password strength indicators can be implemented via onChange and onBlur. It’s more tedious than the normal controlled input pattern, but given vulnerabilities like this one, it’s likely worth creating reusable uncontrolled inputs.
Re: Show HN: A CSS Keylogger
#166Earlier quoted context omitted.
If you use React, updating the value on every change is a very common pattern.
This is speculative as I haven't tested out this vulnerability or attempted to avoid it (yet), but I imagine this means it would be a good idea to make password fields "uncontrolled"[1] if you're using react. 1: https://reactjs.org/docs/uncontrolled-components.html
Re: Show HN: A CSS Keylogger
#167What might be a problem is developers not treating it as such.
Re: Show HN: A CSS Keylogger
#168To some limited degree (you can detect presence, not position or number of occurences of character), you can do CSS only 'keylogging' even for non-reactive (sans JavaScript) input: you don't have to use attribute selector (which does't work without physical updates), but can exploit webfont with single letter `unicode-range` chunks. Posted it [1] to CrookedStyleSheets [2] some time ago: css keylogger @font-face { fon…
Re: Show HN: A CSS Keylogger
#169Earlier quoted context omitted.
...What?
just the first stage of 'I hate JS because it's cool to hate JS' second stage is 'OMFG this website doesn't work for me. How could developer not think about my entitled ass and not spend 2x time to make it work without JS?'
It's the only reasonable response to the user-hostile dumpster fire that is the current web. Javascript has made the web better in a small handful of ways, and made the web significantly worse in every other way.
Re: Show HN: A CSS Keylogger
#170Earlier quoted context omitted.
This is speculative as I haven't tested out this vulnerability or attempted to avoid it (yet), but I imagine this means it would be a good idea to make password fields "uncontrolled"[1] if you're using react. 1: https://reactjs.org/docs/uncontrolled-components.html
Or just use correctly defined CSP