-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
I want to start the discussion of introducing the concept of Subresource Integrity (SRI) into the Gemfile.
Here is an example of what it may look like:
gem 'some_gem', '~> 2.4.4', integrity: ['sha256-sdf...', 'sha384-cxg...']The goal is exactly the same as SRI but translated to gems:
Gem Integrity is a security feature that enables bundler to verify that gems fetched from a source (for example, RubyGems, a private source, or a proxy) are delivered without unexpected manipulation. It works by allowing you to provide a cryptographic hash that a fetched gem must match.
If an attacker gains control of a gem repository, the attacker can inject arbitrary malicious gems and thus can also potentially attack all applications that fetch gems from that repository.
Gem Integrity enables you to mitigate some risks of attacks such as this, by ensuring that the gems have been delivered without without any changes of any kind having been made to it's contents.
Using this technique, it would be more or less impossible for a gem version to be replaced with a malicious one as it will not match the specified hash and therefore will never be installed.
To enable this feature, there will need to be a standardized technique to determining the hash of a gem. Likewise, the hash would need to be made public by gem authors and possibly the gem repositories. E.g RubyGems.
Having Gem Integrity, will help to protect the Ruby community from malicious actors.
Using Gem Integrity as a foundation, we could also provide additional value added features. Some ideas are:
- Gems deemed as containing security vulnerabilities could be added to a blacklist
- Specific gem versions could be marked as trusted by community members building a web of trust
- Tools can be used to evaluate if any gems (or their dependencies) have been blacklisted, or have a low trust value. Developers could then set a minimum trust threshold for gems in their project.
I would love to hear everyone's thoughts on this.