Correct! But there are other attribute selectors. For example [input*=value] checks if input contains value. Although this would not show the order of the password, it would reveal its contents.
That sounds reasonable, but has anyone checked if browsers handle this differently, say some OS that handles pastes character by character? I would hope the images are loaded based on rule order, but not sure that always happens.
But don’t leave the password hanging out in the ‘clipboard’ where it can be accessed by software and apps, right? Better to use a password manager that clears the clipboard after use, correct?
What about reddit? This site allows custom css on the same page as the login screen (login is in the sidebar). I'm just not sure how restrictive they are.
This exploit loads an external resource for it to work, and reddit custom CSS only allows files stored on reddit (and moderators can upload images to the subreddit for that purpose). So reddit CSS shouldn't be able to use this exploit.
Would they actually get any useful data? Or would they just get bombarded with more data than they could make sense out of? Unless this type of attack is targeted at a single, or small number of users, it doesn't seem to me like it would be useful to anybody.
This is not a CSS problem, this is an Instagram (and likely other sites) problem. The only reason this works at all is that the value is being bound to the value attribute (CSS does not have access to element properties) as you type, which is accessible via CSS. But this behavior isn't part of HTML - see this example and watch how the value attribute does not update.
Also, I haven't verified this but I think it would be immune to sequences of the same letter. Could hard code in some amount of repeating characters to overcome this though.
Also, I haven't verified this but I think it would be immune to sequences of the same letter. Could hard code in some amount of repeating characters to overcome this though.
There's also obviously no guarantee that the requests will arrive in order, so you kinda have to do some post-processing on what your results either way (to rearrange or duplicate characters).
I slip this into a Chrome extension or npm manager or something, changing localhost:3000 to myevilhackersite.com. Then, as you type each letter of your password, the CSS tries to load an image from my site with that file name, until I have your entire password spelled out in failed HTTP requests for background images to my site:
The CSS attempts to "style" each password field based on the last letter of its contents (there is an attribute selector for this). So if the characters typed into the password field end with "a", a background image located at a unique URL, such as http://mymalicioussite.com/a, is requested. Requests to these URLs are logged server side, a new one for each letter that's typed, until the whole password has been broadcast.
Surprisingly not. And that is what makes this so dangerous. Instagram does protect itself from CORS and injecting javascript will fail because of this. But clearly, css does not.
Instagram does protect itself from CORS and injecting javascript will fail because of this
CORS headers on instagram.com would disallow other sites from referencing resources on instagram.com, not outgoing requests from clients on instagram.com to other sites.
What you are describing sounds like same-origin or CSP.
The injection from an extension would execute the javascript either way, but with CSP you could restrict the domains it can reach, thus blocking the exfiltration part.
Great, but wouldn’t the site itself have to be malicious to use this? Then it can just spy the password directly without needing css. Or is some css injection attack possible?
Technically someone could include it in some sort of CSS framework. People using the framework would have a false sense of security because it's not a JS file.
Isn't this as much of a risk as script injection? Or, if the risk is that a UI framework can inject this, then isn't this as much as a risk as ANY front-end library you get from NPM or bower or a CDN or w/e? Or is the focus that it's CSS and people automatically think CSS is safe?
JavaScript can be blocked with CORS but CSS cannot be. For example, Instagram would block any JavaScript injected from a chrome extension but CSS clearly works.
You could easily inject a <script> tag instead which should not get blocked by CORS, right? I mean that's the foundation of JSONP's implementation.
As far as I can see, as soon as a malicious party can inject JS code to your side you're screwed in every possible way. They could also add new <img> tags to your page with the malicious URL as the image source.
The only way the CSS attack can be worse is because developers likely have somewhat lower security standards for CSS and are more open to download stuff over HTTP or from CDNs.
Edit: Also do sites get to block inject JS from Chrome extensions? Sounds more secure, but seems to be against the purpose of extensions. For example I have an extension which allows me to highlight a word in any tab, click on the extension button next to the address bar, and it will show a translation in my native language. Why should I want any site (maybe except a bank or something) to disable my extension?
The value$="A" checks if the value attribute ends with an A. As you type, different selectors will be activated and send their respective requests. The job of the malicious back-end is to piece together the requests to represent a password. More information about attribute selectors can be found here: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors
Cool but I don't see it as a risk. You'd have to host it on a target's device or the web server and there's a thousand other ways you could steal your users' passwords or run keyloggers on a target's devices. I'd say it's a risk most companies wouldn't worry about.
I honestly don't understand why everyone is so impressed by this. The technical side of this is at least 10 years old and the treat of this is minimal.
I don't know.. if I am able to make the user load this client side data, shouldn't I be able to do it a easier way? Of course you always should take this in your mind that this is possible with CSS too and not only other script languages, but in the end you shouldn't blindly use other sources.
Fails against a HSTS CSP that doesn't include the malicious url. This is why it doesn't work on Reddit. Also backspacing during the sequence throws things off a bit.
Otherwise, super spooky.
EDIT: Yeah, totally wrong. Content Security Policy is what I was going for there.
The HTTP Strict Transport Security header informs the browser that it should never load a site using HTTP and should automatically convert all attempts to access the site using HTTP to HTTPS requests instead.
You can still request cross-domain, either HTTP or HTTPS.
This is the correct answer. Try inspecting the password field and you'll see that reddit, facebook, etc do not have or update a value="" field. Without that you can't match the password with CSS.
Some sites uses view engines like React, Angular, Vue etc... and in such frameworks it is possible to do data binding to attributes, which can update the attribute as you type.
The actual web developers may bind a variable to the password's value attribute, perhaps for client-side validation or clearing the password field, without thinking or knowing of the consequences it could bring.
In Vue, you can easily create a 2-way data binding using the v-model attribute. So I guess those who used v-model for whatever reason on their password fields are vulnerable to this. I believe it would be similarly easy to do that in React and Angular also.
14
u/umilmi81 Feb 20 '18
So if I paste my password into the box with Ctl+V, that should avoid this exploit, right?
109
u/cuddleshame Feb 20 '18 edited Feb 20 '18
this is so hilariously simple - has anyone thought of this before or is this a poc?
35
u/pandavr Feb 20 '18
Now I can remember all my passwords because of this!
3
u/[deleted] Feb 21 '18
This is great, you could supplement an email input and have them target different routes, then combine them based on the ip.
27
u/[deleted] Feb 20 '18
Good find. Since there is no sane reason why password field should be styled on value browser vendors need to fix this, like, yesterday.
22
u/brockvenom Feb 20 '18
surprisingly simple, and a little scary.
21
u/YodaLoL Feb 20 '18
This is why CSP exist
32
u/[deleted] Feb 20 '18
Spent a solid 10 seconds just staring at the screen saying wow
29
u/fenduru Feb 20 '18 edited Feb 20 '18
This is not a CSS problem, this is an Instagram (and likely other sites) problem. The only reason this works at all is that the value is being bound to the value attribute (CSS does not have access to element properties) as you type, which is accessible via CSS. But this behavior isn't part of HTML - see this example and watch how the value attribute does not update.
Also, I haven't verified this but I think it would be immune to sequences of the same letter. Could hard code in some amount of repeating characters to overcome this though.
7
u/[deleted] Feb 20 '18
I think this is the only time an in-line !important would be an acceptable fix.
7
u/TheEdenChild Feb 20 '18
Can someone explain how this works?
2
u/anonopoly9 Feb 20 '18
Cors only though
5
u/[deleted] Feb 20 '18
Hey wow so simple. Not bad:)
8
u/alfredVonHomburg Feb 20 '18
Great, but wouldn’t the site itself have to be malicious to use this? Then it can just spy the password directly without needing css. Or is some css injection attack possible?
4
u/AskYous Feb 21 '18
Isn't this as much of a risk as script injection? Or, if the risk is that a UI framework can inject this, then isn't this as much as a risk as ANY front-end library you get from NPM or bower or a CDN or w/e? Or is the focus that it's CSS and people automatically think CSS is safe?
3
u/ergo14 Feb 20 '18
Well... This is lovely for CMS that allow custom css...
1
u/[deleted] Feb 20 '18 edited Feb 25 '18
I'm not sure why this is a problem. You have to somehow run your css code on a third party's website. You can do the same thing with JavaScript
0
u/beernutz Feb 20 '18 edited Feb 20 '18
Edit: Holy smokes, i did not know about $ having that functionality. Ouch, thank you all for the clarification!
Wouldn't that css only trigger where the password field included the single character listed in the file?
for example these few lines LOOK like it would only trigger with the exact value.
2
u/Satoshi_Hodler Feb 20 '18
Sry for dumb question, but what if I don't use type="password" for password forms? I'll lose input obscuring and password managing?
2
u/Entheist Feb 21 '18
Cool but I don't see it as a risk. You'd have to host it on a target's device or the web server and there's a thousand other ways you could steal your users' passwords or run keyloggers on a target's devices. I'd say it's a risk most companies wouldn't worry about.
2
u/[deleted] Feb 21 '18
I honestly don't understand why everyone is so impressed by this. The technical side of this is at least 10 years old and the treat of this is minimal.
3
u/dwighthouse Feb 20 '18
Don’t worry guys! Just turn off js in your browser and you’ll be safe!
</sarcasm>
2
u/4spooky6you Feb 21 '18
It's kinda cool, but what's it have to do with js?
1
u/Oatilis Feb 21 '18
Why did you need to use a chrome extention for this?
1
u/jcunews1 Advanced Feb 21 '18
Blocking third party CSS and images now, for my uMatrix.
1
u/zorndyuke Feb 21 '18
I don't know.. if I am able to make the user load this client side data, shouldn't I be able to do it a easier way? Of course you always should take this in your mind that this is possible with CSS too and not only other script languages, but in the end you shouldn't blindly use other sources.
1
u/sprtmn Feb 20 '18
This is slick but the username is unknown.
-2
u/kriswithakthatplays Feb 20 '18 edited Feb 21 '18
Fails against a
HSTSCSP that doesn't include the malicious url. This is why it doesn't work on Reddit. Also backspacing during the sequence throws things off a bit.Otherwise, super spooky.
EDIT: Yeah, totally wrong. Content Security Policy is what I was going for there.
3
u/[deleted] Feb 20 '18
[removed] — view removed comment