Module: Parse::Stack::RackAdvisory

Defined in:
lib/parse/stack/rack_advisory.rb

Overview

Load-time check for Rack releases affected by the 2026 Rack security advisories. The fixes are per branch (2.2.25, 3.1.23, 3.2.8, with no fixed 3.0 release). The gemspec floor covers the 2.2 line; RubyGems limits a requirement string to 255 characters, which is too short to exclude each vulnerable 3.x release by name, so a vulnerable 3.x release is reported here instead of being refused at install time.

Constant Summary collapse

FIXED_3X =

Lowest fixed release per Rack 3.x minor line; nil means no fix exists on that line.

{ "3.0" => nil, "3.1" => "3.1.23", "3.2" => "3.2.8" }.freeze

Class Method Summary collapse

Class Method Details

.check!(version = nil) ⇒ Boolean

Warn once when the loaded Rack release is vulnerable.

Parameters:

  • version (String, Gem::Version, nil) (defaults to: nil) —

    defaults to the activated rack gem's version.

Returns:

  • (Boolean) —

    true when a warning was printed



36
37
38
39
40
41
42
43
44
45
# File 'lib/parse/stack/rack_advisory.rb', line 36

def check!(version = nil)
  version ||= Gem.loaded_specs["rack"]&.version
  return false if version.nil? || @warned
  return false unless vulnerable?(version)
  @warned = true
  warn "[parse-stack-next] Rack #{version} is affected by the 2026 Rack " \
       "security advisories. Upgrade to Rack 3.2.8 or later (or 3.1.23 or later " \
       "on the 3.1 line; the 3.0 line has no fixed release)."
  true
end

.vulnerable?(version) ⇒ Boolean

Whether a Rack version is on a 3.x line with a known-vulnerable release below its fix.

Parameters:

  • version (String, Gem::Version)

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
# File 'lib/parse/stack/rack_advisory.rb', line 23

def vulnerable?(version)
  v = Gem::Version.new(version.to_s)
  return false unless v.segments.first == 3
  line = v.segments.first(2).join(".")
  return false unless FIXED_3X.key?(line)
  fixed = FIXED_3X[line]
  fixed.nil? || v < Gem::Version.new(fixed)
end