13 ms·
Harvesting credit card numbers and passwords from websites
- program_whiz 9y agoEasy Solution: on login and payment forms, go to a plain HTML page, use a standard form to submit without JS (or only JS you write). Forget client-side validation and/or write it yourself.
- pmlnr 9y agoHalf the internet could go static html with css animations without an js and do bacis analytics from server logs. The rest could do webassembly, compiled from another language, missing and npm-dependecy-hell.
- gcornut 9y agoI'm sometimes frustrated by uMatrix blocking every requests to third party website and forcing me to accept each of them when needed. But when I see exploits like this I'm happy that I haven't uninstalled it :D. You still have to be vigilant when whitelisting requests in the uMatrix panel though.
- moreless 9y agoNote that uMatrix doesn't protect you (by default) from sending data out. It also depends on the page you are visiting. If it's just some random post on net I actually don't care much if they do manage to post data elsewhere (the risk in that case is actually higher if I allow ajax.googleapis.com than some random non-google page), but with banking sites and credit card forms you need to be careful.
- pmlnr 9y agoThe trouble with the approach in the article is that by adding a npm dependency, it may as well be the script served by 1st party, buried in their react monster.
- sam_goody 9y agoA perfect example of this is the Hot Pockets deal. Some guy made a cookie session middleware called node-yummy, which eventually became a dependency of Express. Express has a bajillion downloads, so yummy up and brokered a deal by which on every install they tweeted a like for Hot Pockets. So, Hot Pockets really started soaring, with no one having any idea what they were tweeting by installing and updating Express, until someone ruined all the fun by posting it on Medium, and getting picked up by HN [2] IMO the really not acceptable part is that the open souce projects are not being pulled from Github. When something claims to be open source, we should have a gaurantee from NPM that we can see the source. The current setup implies the opposite [1] https://github.com/defunctzombie/node-yummy/issues/7 https://github.com/defunctzombie/node-yummy/issues/7 [2] https://medium.com/friendship-dot-js/i-peeked-into-my-node-modules-directory-and-you-wont-believe-what-happened-next-b89f63d21558 https://medium.com/friendship-dot-js/i-peeked-into-my-node-m...
- kw71 9y agoYeah, and Call Manager has a bug that lets incoming callers transfer themselves to intercom. Keep an eye on that Cisco phone on your doctor's desk while he discusses your HIV test results with you. I could be recording it.
- spiznnx 9y agoThe best part is when you get caught, you can just play dumb and say your npm credentials were compromised (assuming precautions were taken in not using a collection domain tied to you).
- ehsankia 9y agoIn this example situation, the author states: > I’ve now made several hundred PRs (various user accounts, no, none of them as “David Gilbertson”). Also > I go through all the passwords and credit card numbers I’ve collected and bundle them up to be sold on the dark web. So if you get caught, you don't actually exist and you've already sold it all without any traces.
- deleted 9y ago[deleted]
- deckard1 9y agoWorse than that, I think. You can claim the npm account that published the package has zero relation to your github page that hosts the untainted source. The amount of times I've gone to npmjs.com, looked for the "official" version of a package only to get lost in a web of conflicting version and ownership "signals" is staggering. And yet... if it's on npmjs.com, then it's going into your package.json. No one audits that thing. Unless there is an obvious bloat issue. And dependencies of dependencies? NEVER. We have something like 400MB of shit in our node_modules folder. There is no human on earth that could go through that. This is a few times the size of the entire Linux kernel, for context. And it's minified.
- Shoothe 9y agoSo it seems developers are in fact responsible for dependencies that they use... Who would've thought...
- dkersten 9y agoI was going to say the following: Except that being responsible for your dependencies (and the dependencies of your dependencies...) is impossibly hard. You would need to build everything yourself after auditing the code. But then I thought about it some more and its likely that you don’t need to audit the code, since the malware probably isn’t in the public git repo. Yes, its still a risk, but the probability of malware is much lower (and at least you CAN audit the code if you wanted to). You still need to get the source for all your dependencies and all of their dependencies and so on and build it yourself, but you should probably do that anyway and host the artifacts in your own private repo. That’s good practice and avoids issues like the left-pad thing.
- Silhouette 9y agoIt's only impossibly hard to audit this kind of thing if you have an insanely large and deep tree of transitive dependencies in the first place. This seems to be a particularly bad problem in the JS world, for this and many other reasons, but most programming languages and their communities don't work that way. Auditing a small number of larger dependencies, when most of them are probably widely used and from reasonably trustworthy sources, is much more achievable.
- Shoothe 9y agoHa, what an excellent timing with another related story on top of the HN: https://news.ycombinator.com/item?id=16087024 https://news.ycombinator.com/item?id=16087024
- dmitriid 9y agoThe other languages have the same problem. It's only spread over different places. For example, JS doesn't have a standard library. Many languages do. So when JS downloads loads of transitive dependencies, many are there because there's no stdlib. Have you audited your C++, or Java, or Ruby, or... stdlib lately? Especially those that come preinstalled with your OS of choice? Same goes for anything that you download via Maven, or gems, or easy_install, or include as direct GitHub references in your Go code.
- codedokode 9y agoThe author mentions that Chrome Extensions are a bad distribution method. I think he is wrong. First, there are more users of Chrome Extensions than the users of npm, second, most of them don't care what those extensions send over the network. And I guess CSP doesn't apply to browser extensions. So if you want to steal passwords, make some extension like "Mp3 Youtube Downloader" or "Ad Blocker" and get access to millions of happy users' browsers. CSP looks like an ugly hack rather than a good solution. Why would you need to specify allowed sources for scripts if you control your HTML code? I don't understand why the author praises it. What a stupid time-wasting technology.
- throwaway2048 9y agoyou dont always control your html due to XSS and CSRF.
- dkersten 9y ago> CSP look like an ugly hack rather than a good solution ... I don’t understand why the author praises it. Because it appears to be the ONLY solution to the problem described, unless you never use any third party code that you didn’t build from source and audit.
- prh8 9y agoI think you misunderstand the role of NPM in this concept. Using NPM ensures that web sites distribute the code to their users. So it doesn't matter if there's only a few hits using NPM, if they are good hits. As the article mentions, neither Amazon nor eBay are protecting against this. If they somehow added the package to their app, that provides access to every credit card added to those sites. That is much broader than user's installing Chrome extensions.
- sdamodharan 9y agoWhat could be the npm package the author of this article is referring to?
- jbg_ 9y agoThe article is fictional - but designed to sound plausible in order to make web developers think about a problem.
- GoToRO 9y ago"This post is entirely fictional, but altogether plausible, and I hope at least a little educational. Although this is all made up, it worries me that none of this is hard."
- mulmen 9y agoLiterally any of them, that's the point.
- btown 9y agoOne of the biggest problems here is that there is no “chain of custody” from Github source to uploaded NPM module; otherwise one of the developers using the malicious package could have audited the source code before including it in their own code. ‘npm publish’ would ideally insist on reproducible builds, enforce this by minifying or compiling packages itself, and finally encourage the community to always audit the code associated with a module. Of course, people are lazy, NPM has no incentive to incur that server and engineering overhead, and someone could sneak in code anyways with a minor version update... There’s no clear solution here, and I think the only thing keeping up this house of cards is that there are much easier ways for black hats to make money.
- djsumdog 9y agoEven if you had that, no one is going to inspect all that code. npm is a cluster-farkle of insane amounts of packages. The whole point of the article is you should implement CSP.
- altstar 9y agoHe actually has a work-around to CSP. He updated his post.
- deleted 9y ago[deleted]
- mulmen 9y agoSure but why not implement CSP and also get your packages from somewhere trustworthy and audit the code you actually run? Just because "most people are lazy" doesn't mean you have to be. "Audit the code you run" is still good advice right?
- asaph 9y agoIt's often impractical to audit the source code for all your 3rd party dependencies even if they are open source. When was the last time you or anyone you know reviewed every line of your web framework or DI framework? How about the dependencies of your dependencies? Many organizations don't even review all the code their developers write internally. Does your organization code review 100% of releases? Since inception? Like it or not, we're all placing a lot of trust in our dependencies.
- jarofgreen 9y ago> Our penetration testers would see it in their HTTP request monitoring tools! > What hours do they work? My code doesn’t send anything between 7am and 7pm. Which Time Zone? Hah! (Not that this one nit pick takes away from the general very well made point of the article, I just love how TimeZone problems infect everything)
- nallerooth 9y agoOne could run the site's selenium tests every hour or so and then look at the network log (use a proxy while testing). It'd then be easy to catch any request that is not white listed by you. Of course, we all do this. /sarcasm
- nikanj 9y agoThe browser’s? People do tend to keep their PC in the local timezone.
- jarofgreen 9y agoI wonder how much pen testing is done by hand and how much by automatic tools? Anyway, I'm being pedantic. There are a lot of great points in this article.
- ehsankia 9y agoSure, the night build fails, then in the morning the engineer comes in, looks at it, can't replicate, marks as fixed.
- mulmen 9y agoThat makes sense but then the article's claim of losing half the credit cards is only true if we assume even distribution of user activity which seems far fetched at best.
- bubble_boi 9y agoI originally wrote "about half" but there was one too many words in the sentence. Also I figure for an eCommerce site max-traffic might be 7-9pm or something so even though there's more sleeping happening outside 7am-7pm, there might be equal traffic. Anyway ... close enough.
- fny 9y agoCouldn't one circumvent CSP by sending the data to a legitimate analytics service that everyone uses like Google Analytics?
- saryant 9y agoThis is why, when I recently built a credit card form, we didn't include any trackers or third-party code (beyond our vendor's). No dependencies at all—our vendor also has no dependencies in the JS we use to implement the CC form. That did mean no jQuery, no Google Analytics, no NPM modules and we had to build it as a standalone page outside our React setup, but it's worth it to be able to definitively inspect every line of code and provide a CSP that locks that page down tight to just our subdomain and our vendor's.
- monokrome 9y agoHere's hoping you do the same for your login form! :D
- awq123 9y agoIncredible
- aristeol2000 9y agovery interesting!
- asd1 9y agof
- SherPahlavan 9y agoGhbdtn rfr ltkf
- deleted 9y ago[deleted]
- cesarb 9y agoThat's the same as protecting just the login page with https. What prevents code outside the form page from replacing the link which goes to the form page?
- systematical 9y agoThis is a problem for the PHP composer ecosystem as well. I took a look at how many vendor packages our core has and its about 20...
- mkopinsky 9y agoThe difference with composer is that in most cases you're getting the exact version from github, including the full .git directory. No minification, no "the tarball doesn't match the source". And most composer packages have 0-5 dependencies, whereas most npm packages seem to have 10-20. But too-many-dependencies is a problem there too.
- slayer_birden 9y agonot exactly, actually. composer allows you to pull "dist" version - which is an archive that can be whatever really. you can of course set "prefer-source", but I think theoretically you can have a package without source provided at all.
- beams_of_light 9y agoWell-written, educational, incites action. Thank you.
- nailer 9y agoIf this prompts you to action, and you need a quick and efficient way to build a CSP policy for the various services you use: https://www.npmjs.com/package/csp-by-api https://www.npmjs.com/package/csp-by-api
- 0xmohit 9y agoAmazon has no CSP at all, nor does eBay.
- danschumann 9y agoWhat if the author snuck his code into frontend modules, and also snuck his code into backend modules? If CSP is enabled, the frontend checks to see if the backend code has opened up the particular port or route on the backend. The back-end code could sniff through require.cache to see if he could hook into the existing server instance ( same port ), or open a new port ( depending on CSP ). I suppose the CSP equivalent on the backend is some sort of firewall. I also suppose servers have better monitoring of requests. Still, this method would circumvent CSP!!! Also, hooking into the existing server instance would throw red flags if the instance was ever console.logged. You might also do an audit of your ports and see a suspicious one opened in that method. And a firewall likely would block other ports. But, still, it's feasible even with a CSP, until discovered.
- danschumann 9y agoActually, a main question is this: can npm modules read require.cache? If so, why? Can they require code outside of the npm modules folder. Again, why? Couldn't any npm module steal your credentials, and suffer from the same source minification/github custody stuff? Take an npm module. It does setInterval and every minute, it checks require.cache for any file with 'config' in it, and sends it to the crook. Is this possible currently? I would think npm modules should be require-sandboxed to their own directory. Even then, there is compiled code, etc. Oy vey.
- vjeux 9y agoYou don’t need to do such complex things. You can just require(‘child_process’).execSync(‘any shell command’) with all the user credentials.
- saryant 9y agoHe'd have to somehow make outbound requests from the server. IIRC, the default AWS VPC config would prevent this. Not sure about other cloud environments. Where I work, outbound requests must be made through proxy servers which have a whitelisted set of allowed domains, which is only allowed after a security review.
- z3t4 9y agoThere is this trade-off between usability and security. For example being able to load data from other domains, now with origin policy we have do fetch the data server side. One nice thing about web apps is that they do not require a server to work. But due to xxs injections we cant have nice things.
- FLUX-YOU 9y agoI know it's just trendy to hate on node/npm, but these are really turning into bad products and services. You need usability before there's a trade-off. Reputation is still important.
- mulmen 9y agoIt's almost like the browser is being abused to do something it fundamentally should not be doing. If you need to do that much client side heavy lifting maybe a web browser is not the place for it? The ship has probably sailed on that line of thinking but in my opinion a lot of the pain we experience in web security today comes from people trying to do things they really should not be doing.
- z3t4 9y agoThere's this vision for the web that we should be able to access public "data", not only web sites "guarding" it.
- mulmen 9y agoMaybe you and I have different definitions of Internet and web then. You can still access data without javascript or webapps.
- z3t4 9y agoAccessing data either require's identification to a database or you access the data over the web/http. Do you have any examples where you can access public data without logging in ? I can only think of FTP servers that lets you access anonymously ...
- jmadsen 9y agoI'm more of a back-end dev who doesn't know all the ins and outs of the actual software used - can someone explain to me why this is an npm problem, and not an excessive dependencies problem? I thought npm was simply a package manager - I don't see anything in the article that is specific to npm, except he happens to say that word.
- ufmace 9y agoIt's kind of an excessive dependencies problem, except exacerbated by two things. One is Javascript's poor stdlib. This means that not only are you tempted to include lots of little packages to do basic things, but so are all of the big packages that you include to do big things for you, and all of the packages they include, etc. Often there are a bunch of different packages for doing the same basic things, and nobody agrees on which one, so you may end up with 5 different packages that do the same thing required by various packages you use. Two is that much of it is expected to be served to the browser, so it's minified. Who audits that the minified code is actually the same as the published Github code? At least in Ruby and Python, the code from Rubygems/Pip should exactly match that version on Github. Not that anyone necessarily audits that either, but at least it's easier.
- alceta 9y agoIn Ruby, the exact same problem applies since you can publish gems in one version and tag them in another - in the very same fashion as the article describes.
- agumonkey 9y agoI guess it's not npm per se, but js crowdsourcing factor multiplies the attack surface by large powers of ten. In other languages, having the security libs centralized and vetted "might" (you'd need an decent amount of work to ensure that it is safe) avoid getting MITM'd so easily.
- mundungus_a 9y agoThe root of the problem is that a dependency can be downloaded and installed from only it's minified/obfuscated form, and without any verification that the code matches what is in the non-minified/obfuscated codebase. This is just exploited through people being dependency-happy and that no one really verifies that a package isn't doing more than what is advertised. This same problem would exist if any server-side dependency repositories allow for code to be delivered in a pre-compiled form without any verification, similar to npmjs.
- drdrey 9y agoReminds me of Writing Worms for Fun and Profit by lcamtuf: https://www.darknet.org.uk/2006/12/writing-worms-for-fun-or-profit/ https://www.darknet.org.uk/2006/12/writing-worms-for-fun-or-...
- bmease 9y agoI've gotta post the obligatory Ken Thompson hacking the compiler story http://wiki.c2.com/?TheKenThompsonHack http://wiki.c2.com/?TheKenThompsonHack
- macawfish 9y agoI recently had a problem with a package that doesn't have its npm releases tagged in git. It surprised me how hard it was to figure out which git revisions corresponded to specific npm releases. I had tracked down the npm version of the package that introduced the bug I was trying to fix, but without getting in and doing some real diffing, I couldn't figure out which commit introduced the bug. At the time, I'd never added anything to npm, but since then, I have. It dawns on me that npm versions aren't tied to git revisions at all!
- rmrfrmrf 9y agoYep, only authors who are good about using `npm version` and pushing the resulting git tag to origin are going to have the proper linkage.
- MollyR 9y agoWow thats a rough read. Could something similar be done to django sites ?
- rollcat 9y agoYes. There are basically three steps here... 1. Use social engineering to get your package included as a dependency; 2. Use obfuscation techniques to hide the real intent of the package; 3. Capture data and send it off to a remote server. First can be pulled off, but really depends on the community / maintainers doing their job right. In case of Django, I imagine that would be pretty hard - while the codebase is giant, by itself it has no other dependencies (except stdlib and pytz). Then 3 could be either much easier or much harder on the backend, depending on how well the box is secured (e.g. outgoing firewall rules). However the impact could be much more severe, since you're executing code on the server - at the very least you can inject any malicious JS you like, rewrite the CSP headers (if present), just dump the entire DB right away, and a lot of other bad things. This basic recipe has a chance to work regardless of the target language/package manager. It's all up to your dev process and security regime to catch it.
- shaneos 9y agowhile this post is about the more general attack vector, its worth pointing out that if you use a modern credit card tool like Stripe Elements it is impossible to steal credit card numbers as they are embedded in an iframe and your page just gets a token that is meaningless to anyone else
- Qerub 9y agoThe attacker could inject code that replaces the Stripe integration with something that looks identical to the end-user but harvests the CCs.
- shaneos 9y agoTrue, but this is easily detected. It’d have to provide tokens to the page, which would fail 100% of the time when sent to the Stripe API. These types of attacks are really only effective when difficult to detect, and therefore allowed to run for more than a very short time
- wahnfrieden 9y agoThe Stripe frames are set up by JS. What’s stopping an attacker from wrapping it in their own form, collecting, and having it still submit the details to Stripe?
- antsar 9y agoThe attacker's code isn't hosted on Stripe's domain. It could render the real Stripe iframe, but could not interact with it (ie. populate form values and submit). An attacker could try to POST the values directly to Stripe instead, but Stripe presumably uses CSRF-prevention techniques (eg. a token in the form) to stop this as well.
- adbachman 9y agoThe article addressed that objection, though. 1. Only activate on sessions where it’s never activated before. 2. Only activate one in, say, seven times. 3. Sniff form once, fail to submit, show user "unexpected error, try again", allow normal behavior, success, user moves on 4. pull the numbers It’s nice to imagine we follow up every single JS or user reported “it fails sometimes?” error, but a clever malicious script author knows we don’t check 100% of the time. We are required to expect transient and potential errors from third party services, not even Stripe has 100% uptime. This kind of theft looks like a transient and unexplainable error.
- SuperNinKenDo 9y agoSeems particularly prescient given https://news.ycombinator.com/item?id=16087024 https://news.ycombinator.com/item?id=16087024
- noxecanexx 9y agoExactly, most especially after seeing this comment https://news.ycombinator.com/item?id=16087079 https://news.ycombinator.com/item?id=16087079