8 ms·
Unauthorized gem takeover for some gems
- intunderflow 5y ago> An audit of gem changes for the last 18 months did not find any examples of this vulnerability being used in a malicious way. A deeper audit for any possible use of this exploit is ongoing, and we will update this advisory once it is complete. How would folks do that with strong enough guarantees? Surely they can't review every gem change by hand?
- hkolk 5y agoFrom what I understand, they only have to review/audit the times a gem was yanked, to see if it was a legitimate action. I reckon there is a lot less occurrences
- dragonwriter 5y ago> Surely they can’t review every gem change by hand? Given the nature of the vulnerability, they only have to audit yanks of gems with a dash in the name that were either not updated in the 100 days prior to the yank or created 30 or fewer days before the yank, which is a much smaller universe than “all gem changes”.
- pjmlp 5y agoThat is why many companies forbid installing packages from the Internet, they have to be reviewed, accepted by the legal team, made available into the internal package server, and only then you can make use of them on the respective application. An update triggers the whole process again. Yes, it is a pain to deal with, and the only way to make sure 3rd party dependencies are actually valid, and also keep working no matter what happens to upstream.
- mrtweetyhack 5y ago
- brasic 5y agoThis test seems to be a good example of the vulnerability: https://github.com/rubygems/rubygems.org/commit/58c755a7a62a46d971753ec15d4ee3a72ad0ab5d https://github.com/rubygems/rubygems.org/commit/58c755a7a62a...
- AviationAtom 5y agoThis goes to show: no matter how great your network defenses, you have to be prepared for WHEN you get breached. Supply chain vulnerabilities are becoming a greater problem by the day. I think Solarwinds demonstrated this greatly.
- judofyr 5y agoI agree with your point, but this is maybe a bad example since there’s no indication that anyone was breached by this?
- xmprt 5y agoOne of my college professors joked about/discussed a potential attack where someone sneaks a change into the Linux kernel or distributes a binary that's different from the open source code and I remember the class dismissing it as if it was a joke. Turns out it wasn't as much of a joke as it seemed at the time.
- lamontcg 5y agoPut it into the compiler so it re-inserts itself when it sees that the compiler is being recompiled... Reflections on Trusting Trust: https://dl.acm.org/doi/pdf/10.1145/358198.358210 https://dl.acm.org/doi/pdf/10.1145/358198.358210
- pabs3 5y agoBootstrappable Builds solves the compiler backdoor problem; start with only 512 of machine code and lots of source code, then build a whole distro. https://bootstrappable.org/ https://bootstrappable.org/
- ccheney 5y agoYou may be interested in reading about the Linux incident[1] perpetrated by some University of Minnesota researchers[2]. Previous discussion: https://news.ycombinator.com/item?id=26887670 https://news.ycombinator.com/item?id=26887670 [1] https://lkml.org/lkml/2021/4/21/454 https://lkml.org/lkml/2021/4/21/454 [2] https://cse.umn.edu/cs/linux-incident https://cse.umn.edu/cs/linux-incident
- 3ds 5y agoI love the transparency! Even if no one was affected.
- thenerdhead 5y ago2020 - The year of secure supply chain. 2021 - THE year of secure supply chain. 2022 - THE YEAR OF SECURE SUPPLY CHAIN. Working in this general space, I can say that this is only going to get worse before it gets better. Many people are rallying behind pushing towards best security practices however. The dash requirement is interesting given it's somewhat of a pseudo prefix/namespace. Good that this was caught now and looks to not be exploited.
- d4mi3n 5y ago100% this. My CSIO has been harping on this since 2018. I’ve been harping on this since 2019. Security vendors are JUST now starting to provide SCA offerings (software composition analysis, for those not in infosec). Events like these don’t surprise anyone who’s been following this space. It’s been a rough ride that will get rougher. Consider: 1. NPM just recently started enforcing 2FA for some packages. The NPM has yet to support mechanisms like package signing. Post install scripts are still a thing. 2. Rubygems does not support package signing. 3. Go dependency management is a hot mess. 4. Clojure dependency management is still a hot mess. Initiatives like Google’s SLSA will help here, but there’s a whole ecosystem of stuff across multiple technical ecosystems they need to mature, and fast.
- roblabla 5y agoI agree with most of your post, but I do not understand this: > Post install scripts are still a thing I cannot find a situation where post-install script actually pose a security issue. I find that you'll always end up running the code you just installed on your machine (either through running unit tests, or running the actual code, or whatever). Hence, the only scenario where post-install scripts are a problem is: - You install deps on a machine that has access to security sensitive resources (think: your ssh keys) - BUT you do not run the resulting code on that machine. Are there really any use-case that satisfies those requirement where post-install scripts would actually result in a security issue?
- dec0dedab0de 5y ago
- jfoster 5y agoThe most secure supply chain is no supply chain, but the relationship is linear or better. A thousand dependencies is more than 100x worse than ten dependencies.
- tgv 5y agoI don't think so. Or what's the unit in this case? If you think of it as "the probability that a problem with at least some given severity occurs", then you can model it as the combined independent probability of N dependencies and you end up with the classic 1 - (1 - p) ^ N, so asymptotic behavior for large N.
- danielheath 5y agoI think the number of maintainers is more relevant than dependency count. Some languages just tend to have more smaller packages written by a few people, and that’s fine; the situation in javascript is troubling because there are so many contributors whose access lets them push bad changes.
- chrismarlow9 5y agoAssume everything is compromised and construct internal architecture accordingly. The best you can ultimately do is try to limit the impact. Proper firewall, TLS, strong crypto, secrets management, 2FA and regular audits. Zero trust stuff
- nine_k 5y agoYou cannot zero-trust to your web framework. You cannot zero-trust your data access library, to which you have to give credentials to your production database. You have to trust the database itself, and the operating system that runs your whole stack. Zero-trust requires certain scale and is expensive; the most successful high-stakes zero-trust system I know is Bitcoin.
- mikepurvis 5y agoBut you can still do things like not allow your DB to make connections to the outside world, or receive connections other than from the application and authorized admins. And similarly for the app, it can be prevented from talking to anyone it doesn’t need to be talking to. They can still be badly behaved, but you are least control the blast radius.
- zomgwat 5y agoDefault deny egress is an important step in limiting impact. It can be tough though.
- mschuster91 5y agoThe biggest problem in "default deny egress" is CDNs. It's a colossal waste of time to set up firewall access lists for your build agents, but even for your production environments - as soon as you have one external API that is hosted behind Cloudflare, Anypoint, Cloudfront, Akamai or one of the hundred other similar services, you may as well give up. Simply because it's extremely annoying to keep up tabs with changing IP addresses.
- jtaft 5y agoSignature verification of releases would of prevented this.
- semiquaver 5y agoVerification against what public key? Surely not one stored in rubygems.org, since an attacker who compromises an account could just upload a new key and sign a malicious release with that. Besides, if rubygems can write a bug that allows someone to publish to a package namespace they don’t own, it’s perfectly realistic that they could also write a bug allowing an attacker to upload a key to an account they don’t own.
- yardstick 5y agoThere’s no perfect solution but let’s not let perfect be the enemy of good. SSH is a good example where the host key is trust on first use. It would be nice to have this option for supply chain dependencies too (npm, ruby, etc). So your local client would reject any updates to a package if it wasn’t signed by the original key. Like SSH, if the key had to be rotated due to compromise, you’d have to reset that trust. But at least that would be a manual process and changes would be picked up as an error by build servers.
- semiquaver 5y agoSSH is such a different use case that the analogies break down. With respect, thinking about this for a few minutes should convince you that while TOFU works fine for immutable artifact signatures, it is unworkable for a system where you ever upgrade packages. Consider that most nontrivial projects on rubygems have multiple maintainers that can publish a version. Normal collaboration models would imply that they each have a personal signing key; sharing a single signing key per project isn’t realistic (as you mentioned, rotation is another reason for this). And TOFU doesn’t work when there are multiple possible keys, such a system requires an external trust chain. Assume for the sake of argument the above is solved. What exactly do you do when tooling alerts you that an upgraded dependency has changed keys since the last version? Either you blindly accept the new key or you investigate. If the latter hopefully you have a way to directly contact the author to verify that the rotation was legitimate. Since you probably don’t you should just compare the diff of the published artifacts. But you should have been doing this anyway, so what has the signature bought you here except false security? Imagine a system like npm, where hundreds of transitive dependencies are upgraded all the time. Would you really want a key change in a 3rd-level dep you didn’t even know you were using to block you from installing a security fix to a primary dependency until you could somehow vet the new key? Such a system would change very quickly to Trust On First Use But Also Trust On Any Change… I’m all for pragmatic solutions that measurably improve supply chain security. I just think changes like https://github.com/rubygems/rubygems.org/pull/2499 https://github.com/rubygems/rubygems.org/pull/2499 and https://github.com/rubygems/rubygems.org/pull/2242 https://github.com/rubygems/rubygems.org/pull/2242 which recognize the social aspect of the problem qualify to a much greater extent than thinking of crypto as magic dust that can be sprinkled on a system to increase its security.
- acchow 5y agoWhy don’t we have the actual gems themselves contain a signature from the developer?
- semiquaver 5y agoThat’s been well supported for years. It’s also possible to set a security policy so only signed gems are allowed. But signatures are worthless without a way to safely trust them and that is a more difficult problem since it’s not purely technical. Vendoring all gems, manually verifying diffs on upgrade, and manually verifying signatures where possible is still the best practice here.
- feross 5y agoI see a lot of people suggesting solutions that, while helpful, wouldn’t actually solve the key problem in supply chain security. - You can’t trust the package registry because of security flaws in the registry itself (as seen here as well as in NPM just a few months ago[1]). The CDN can be hacked, or an insider can attack the infrastructure. - You can’t rely on code signing since a maintainer can go rogue and sabotage a package at any time (as happened with colors.js and faker NPM packages in January[2]) or a new maintainer could be added to the project and possess a valid signing key but turn out to be a bad actor (as happened with the event-stream NPM package in 2018[3]). - You can’t audit every line of code in every dependency because the cost in terms of time and expertise is prohibitive to all but the biggest organizations (e.g. Google) and the most security sensitive applications (e.g. certain crypto projects and financial applications). The two solutions I’m most excited about are (1) auditing package behavior with static analysis to detect when package behavior changes (e.g. new network connections, filesystem accesses, install scripts) like we do at https://socket.dev https://socket.dev (disclosure: I am the founder) or (2) package sandboxing of which Lavamoat is the best example (however the performance impact is too high to apply this to every package in an app at present, and it also requires maintaining a policy configuration for each package). [1]: https://www.theregister.com/2021/11/16/github_npm_flaw/ https://www.theregister.com/2021/11/16/github_npm_flaw/ [2]: https://www.theregister.com/2022/01/10/npm_fakerjs_colorsjs/ https://www.theregister.com/2022/01/10/npm_fakerjs_colorsjs/ [3]: https://www.theregister.com/2018/11/26/npm_repo_bitcoin_stealer/ https://www.theregister.com/2018/11/26/npm_repo_bitcoin_stea...
- staticassertion 5y agoThere are multiple different problems with different solutions of varying impact. I think you can probably split the two areas of interest into: 1. A package maintainer's credentials are compromised 2. A package repository is compromised And the two attack vectors into: 1. The build script(s) 2. The runtime library You can cut off the "repository is compromised" path with signing. An attacker doesn't have the maintainer's private key so even if they can modify source/packages on the server they can't "trick" the client into verifying it. (1) is harder. Let's assume we have package signing, we know that any package we have was signed with a key that we hope only the maintainer has access to. At this point, either the maintainer is compromised or malicious. We can make compromise harder in a few ways, but should ultimately assume compromise. One way to reduce compromise is to have the signing key stored on a hardware token that requires proof-of-presence for signatures. Still, at this point we have "build script bad" and "library bad". Both are much harder problems, with solutions that you've alluded to to some extent - that is, sandboxing behaviors. What this requires is a way to say "this code can do these things". This is how browser extensions / mobile apps work - they have to declare their permissions and you have to ack them any time they change. Doing this for build scripts isn't too hard. You can run the scripts in a "hermetic" build system and have each script execute serially in a restricted environment - if one needs networking, give it networking, etc. There's no native support for this but imo it wouldn't be that hard to add it in. Doing this for libraries is much harder. You'd need a native capabilities system in the language, and changes to capabilities would break the API. But sandboxing entire processes isn't that hard. The vast majority of services don't require egress to the public internet, meaning that an attacker is already going to have a hell of a time if they just get a shell into some box that they can't even communicate with. So I'd say start there - limit processes to what they can do and that limits the impact of a compromised library. So altogether, none of these approaches seem super hard. We have signing, sandboxed builds (they can be pretty loosely sandboxed tbh - do a 'fetch', and then cut off internet for build scripts/ limit fs access), sandboxed services. It'd be nice to have something more robust, but today you can do everything above without a ton of effort.
- vermilingua 5y agoI don’t understand why the package registries/managers haven’t yet provided options to compile-in dependancies of dependancies on release. E.g. package A depends on B, if you install A, B is baked into it at the install step. That way, your active dependancies are only that which you purposely install, and some compromised package X dependancies down the chain won’t bite you when you do an automatic upgrade.
- caiob 5y ago
- midislack 5y agoStop saying "supply chain" when you mean remote dependencies. It's not a supply "chain" it's a centralized resource. Whoever started this trend can come to my house for a free ass kicking. It's not cute and it makes it difficult to search for things.
- tgv 5y agoBad naming seems pervasive in our industry. So many frameworks aren’t frameworks, to mention another example. But one thing gets associated with another, names get mixed, and most people will get what it’s about, and the new name persists. Don’t worry: in a few years, it’ll have a different name.
- ghoward 5y agoI don't think this will be solved until there is a radical rethinking of package managers, build systems, and programming languages. Like the founder of socket.dev, I think that static analysis will play a role. However, I don't agree that that's the entire answer. The static analysis has to be in the programming language used in the build. The language must have fine-grained permissions built into it, and those permissions should be able to be used both at compile time and runtime. The build system should take advantage of the programming language's fine-grained permissions to allow the user building the software to restrict what the software can do at build time. It should be possible to decide, for example, that the build can only access files in a particular directory, and if that is violated, the build system will error. Same thing with network access. The package manager should take advantage of the build system to build all software from source as far as possible, and to ensure that the package uses the build system and programming language to ensure the package cannot stomp on the user's computer at build time. That is the minimum before these issues have any hope of being resolved. But I still think that is not enough. Say you have a dependency that you do not trust. If you could compile it into a form that could be interpreted by the same interpreter that the programming language mentioned above uses to enforce permissions at runtime, and if that interpreter had a way to transfer data to and from the code it was running, then you could have a system where you embed the interpreter in your code and use it to run your untrusted dependency. Then the untrusted dependency can be properly sandboxed. Yes, you'll pay in performance, but you won't pay whatever you might pay if a dependency goes rogue. That is the only way to "fix" these supply-chain issues until everyone actually vets their dependencies. Disclaimer: yes, I'm working on a language, build system, and package manager with the above features.
- Hendrikto 5y ago> It should be possible to decide, for example, that the build can only access files in a particular directory, and if that is violated, the build system will error. (How) does that work for dynamic file access? I.e. the files are often not known at build time.
- ghoward 5y agoThat is an excellent question. I don't know if my current design is good, so it is subject to change. The current design is to allow the user to give the interpreter a predicate (function that returns a Boolean) to run whenever something asks for access to a file. It would return true for allowing access, false otherwise, and its arguments would include what package (module, library, etc.) is asking for access, what kind of access, and exactly what file it's being asked for. The predicate can do all sorts of wild and wonderful things to figure out if the package should be allowed access. It could even pop up a dialog box for the user in the cases it can't figure out, which would also have the benefit of alerting the user that there's a package that might have gone rogue. In fact, in those cases where it denies access, it can still alert the user, who can then do something about it. I like this design (so far), and I think it's best because if you're going to enforce runtime permissions, you need runtime abilities to make judgments. It can't be a simple static list of files, as you rightly figured out, although it could use such static lists for the easy cases.
- inopinatus 5y ago“New feature: rubygems now supports ownership scopes using a hyphen separator”
- shaicoleman 5y agoRelated: there is a scoped gems proposal, that would allow to explicitly specify the author, e.g. @tenderlove/nokogiri https://github.com/rubygems/rfcs/pull/40 https://github.com/rubygems/rfcs/pull/40
- jacques_chester 5y agoThe title that was chosen is unfortunate. There was no actual takeover of any gem. A vulnerability was found that made it possible, but after audit no such case was found.
- strzibny 5y agoI built a RubyGems plugin[0] that can help you vet gem version changes. Not that it would save you from this CVE, but though others might appreciate it to have in their toolbox. [0] https://github.com/fedora-ruby/gem-compare https://github.com/fedora-ruby/gem-compare