Commit 524db87
build: verify gem integrity at install time (CVE-2020-8130 hardening)
The Gemfile/Gemfile.lock fetched gems over plain http://rubygems.org with
BUNDLED WITH 1.11.2 and no CHECKSUMS block, so nothing verified the content of
a downloaded gem. rake executes arbitrary code from the Rakefile at test time,
so a substituted tarball would run as the developer.
Context: CVE-2020-8130 / GHSA-jppv-gw3r-w3q8 is an OS command injection in
Rake::FileList, patched in rake 12.3.3. The old lockfile already pinned 12.3.3
so it was not itself vulnerable; the gap was that the *delivery* of that gem
was unverifiable. This moves to rake 13.4.2 and makes delivery verifiable.
- Gemfile.lock: regenerated with Bundler 2.7.1, adding a CHECKSUMS block with
per-gem SHA-256 digests that Bundler verifies on every bundle install.
- Gemfile: drop `gem "json"`. lib/ only uses JSON.parse/JSON.dump from the
json default gem that ships with Ruby, and the gemspec declares no
dependency on it, so a third-party json was a redundant build-time
component -- and a native extension that fails to compile against
Homebrew ruby@3.2 headers.
- .gitignore: ignore .bundle/ and vendor/bundle/. .bundle/config can carry
disable_checksum_validation, which would silently switch the new
verification off, so it must never be committed.
Verified: every digest matches the SHA-256 rubygems.org publishes for that
version. Flipping one digest makes bundle install abort with "Bundler found
mismatched checksums" (exit 37, nothing installed); with the CHECKSUMS block
removed the same install exits 0 and performs no verification at all.
Suite: 23 runs, 40 assertions, 0 failures, 0 errors, 3 skips.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent ee74327 commit 524db87
3 files changed
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | | - | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
23 | 27 | | |
24 | 28 | | |
0 commit comments