Skip to content

chore: Ruby 3.4 upgrade and full dependency security update#607

Open
jgamblin wants to merge 13 commits intomainfrom
security-update
Open

chore: Ruby 3.4 upgrade and full dependency security update#607
jgamblin wants to merge 13 commits intomainfrom
security-update

Conversation

@jgamblin
Copy link
Copy Markdown
Collaborator

@jgamblin jgamblin commented Mar 28, 2026

Summary

Hey team! I was cleaning up some of my old PRs and noticed this repo hasn't had much dependency love recently. Ruby 3.2 hit EOL back in March 2025, and bundle-audit was flagging a few CVEs, so I figured it was time for a thorough refresh.

Ruby & Gem Updates

  • Ruby 3.2.2 → 3.4.9 — back on a supported, actively maintained version (3.2 has been EOL since March 2025)
  • All gems updated to latest compatible versions (some were years behind — e.g. aws-sdk-core jumped 76 minor versions)
  • Gemfile constraints tightened — added ~> pessimistic operators to all gems to prevent surprise major version bumps on future bundle install runs

Security Fixes

  • httparty 0.21.0 → 0.24.2 — fixes SSRF / API key leakage (High severity)
  • faraday 2.13.1 → 2.14.1 — fixes SSRF via protocol-relative URL (Medium)
  • rexml 3.3.9 → 3.4.4 — fixes DoS via malformed XML (Low)
  • CWE-22 path traversal — added input sanitization to write_file and write_file_stream in lib/helpers.rb (flagged by CodeQL)

Bug Fixes

  • JSON.dump segfault — replaced JSON.dump(obj, file) with File.write(path, JSON.generate(obj)) in write_file_stream to fix a segfault caused by json gem's C extension interacting with ActiveSupport's to_json monkey-patches on large objects
  • simplecov-cobertura 2.1.0 → 3.1.0 — fixes crash when generating Cobertura XML coverage reports with rexml 3.4

CI & Infrastructure

  • Containerfile — updated base image to ruby:3.4, removed stale CVE workarounds for uri/time gems
  • actions/checkout v4 → v5 — fixes Node.js 20 deprecation warnings ahead of June 2026 deadline
  • Bundler Audit workflow — replaced third-party forked action (pinned to Ruby 3.2.2) with direct bundle-audit invocation via ruby/setup-ruby
  • Rubocop 1.42 → 1.86 — regenerated .rubocop_todo.yml for new cops

Test Results

All CI checks pass:

  • 234 rspec examples, 0 failures
  • bundle-audit check --update — no vulnerabilities
  • bundle exec rubocop — no offenses
  • Docker container builds and runs cleanly
  • CodeQL — clean

Test plan

  • bundle exec rspec — 234 examples, 0 failures
  • bundle exec ruby toolkit.rb task=help — smoke test passes
  • bundle-audit check --update — no vulnerabilities found
  • bundle exec rubocop — no offenses detected
  • CI checks pass (Native-Ruby-Test, Bundler Audit, Lint)
  • Container builds: docker build -t toolkit-test .

🤖 Generated with Claude Code

jgamblin and others added 8 commits March 27, 2026 19:21
Ruby 3.2.2 reached EOL in March 2025. Upgrading to 3.4.9,
the latest actively supported Ruby release.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Key security updates:
- httparty 0.21.0 → 0.24.2 (fixes SSRF vulnerability)
- faraday 2.13.1 → 2.14.1 (fixes SSRF via protocol-relative URL)
- rexml 3.3.9 → 3.4.4 (fixes DoS via malformed XML)
- sanitize 6.0.2 → 6.1.3

Also updates all other gems to latest compatible versions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
….4 compat

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rubocop 1.42 → 1.86 introduces many new cops. Regenerated the
todo file to capture pre-existing offenses. No code changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Node.js 20 actions are deprecated and will be forced to Node.js 24
starting June 2026. Updating checkout action across all workflows.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
JSON.dump triggers a fallback code path in the json gem's C extension
that interacts badly with ActiveSupport's to_json monkey-patches when
serializing large objects. JSON.generate avoids this path and is the
recommended approach for data serialization.

This fixes a segfault in the AWS Inspector2 tests where 19 batches
of vulnerability data accumulated in memory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jgamblin and others added 2 commits March 27, 2026 19:46
simplecov-cobertura 2.1.0 crashes with rexml 3.4.4 when generating
Cobertura XML coverage reports ("Malformed XML: No root element").
Version 3.1.0 fixes this compatibility issue.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CodeQL flagged write_file and write_file_stream as vulnerable to path
traversal via user-provided directory/filename parameters. Added
safe_output_path helper that uses File.basename to strip directory
components from filenames and File.expand_path to verify the resolved
path stays within the intended output directory.

Fixes https://github.com/KennaSecurity/toolkit/security/code-scanning/20

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 35.56%. Comparing base (62c3825) to head (9630ab5).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #607      +/-   ##
==========================================
+ Coverage   35.47%   35.56%   +0.09%     
==========================================
  Files         128      128              
  Lines        8465     8463       -2     
==========================================
+ Hits         3003     3010       +7     
+ Misses       5462     5453       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

jgamblin and others added 3 commits March 27, 2026 19:52
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Covers the new path sanitization logic to satisfy codecov/patch check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add tests for write_file method (was untested)
- Mark the defensive raise in safe_output_path as :nocov: since
  File.basename already prevents traversal from reaching it

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant