Dependency Confusion: How I Hacked Into Apple, Microsoft and Other Companies
11–20 of 412 posts
Re: Dependency Confusion: How I Hacked Into Apple, Microsoft and Other Companies
#12Re: Dependency Confusion: How I Hacked Into Apple, Microsoft and Other Companies
#13solution: use nix as your package manager
Helps in this specific case, but will not eliminate the broader issue. The broader issue is how can you trust 3rd party code to not do anything harmful, and it’s not like we can even perfectly trust our own fingers in that regard.
Nix package managers/repositories have a level of scrutiny to get into, and highly dedicated people in charge of. Random github repos (or npm packages) are extremely low effort/risk to set up.
Of course the former can be abused, but the incentives are at least in its favor to likely be more trustworthy. And we have to make assumptions of trust everytime we sit down in our chair or turn on our computer, or plug in a space heater. We will never get around trust, but there are differences in levels of trust and trustworthiness.
Re: Dependency Confusion: How I Hacked Into Apple, Microsoft and Other Companies
#14[1] https://github.com/pan-net-security/artifactory-pypi-scanner
Re: Dependency Confusion: How I Hacked Into Apple, Microsoft and Other Companies
#15That is, given a Gemfile.lock like, e.g.
GIT
remote: https://github.com/thoughtbot/appraisal
revision: 5675d17a95cfe904cc4b19dfd3f1f4c6d54d3502
specs:
appraisal (2.1.0)
bundler
rake
thor (>= 0.14.0)
How would Bundler ever try and download the `appraisal` gem from RubyGems?The Gemfile section is more explicable. While newer Gemfiles look like this:
source "http://our.own.gem.repo.com/the/path/to/it" do
gem 'gemfromourrepo'
end
# or
gem 'gemfromourrepo', source: "http://our.own.gem.repo.com/the/path/to/it"
Older Gemfiles apparently looked like the following: source 'https://rubygems.org'
source 'http://our.own.gem.repo.com/the/path/to/it'
gem 'gemfromrubygems1'
gem 'gemfromrubygems2'
gem 'gemfromourrepo'
Which seems obviously vulnerable to the dependency confusion issue mentioned.So is the understanding that Shopify's CI systems were running `bundle upgrade` or another non-lockfile operation? (possibly as a greenkeeper-like cron job?) Or is `--pure-lockfile` itself more subtly vulerable?
Re: Dependency Confusion: How I Hacked Into Apple, Microsoft and Other Companies
#16Re: Dependency Confusion: How I Hacked Into Apple, Microsoft and Other Companies
#17Re: Dependency Confusion: How I Hacked Into Apple, Microsoft and Other Companies
#18This is not as amendable to CI, but that's the point.
Re: Dependency Confusion: How I Hacked Into Apple, Microsoft and Other Companies
#19That is insane that any company allowed this to happen. ""That said, we consider the root cause of this issue to be a design flaw (rather than a bug) in package managers that can be addressed only through reconfiguration," a Microsoft spokesperson said in the email." No, npm has scopes for a reason, why would that not fix this issue?
Maybe the bug wasn't explained correctly but if it prefers public over private that seems like a bug.
OTOH, it certainly is an issue that if you forget and happen to test some code without being configured to have the private package server as your default then you'd get public repos.
Maybe instead of named packages companies should be using private URLs for packages. That way you always get what you ask for?
Re: Dependency Confusion: How I Hacked Into Apple, Microsoft and Other Companies
#20Fixed versions for as many things as you can (including OS images, apt packages, Docker images, etc) lead to changes in your CI under your control.
Sure, you have to upgrade manually or by a script. But isn't plain build stability worth it? Not even talking about security.