Version in base suite: 7.2.2.2+dfsg-2~deb13u2 Base version: rails_7.2.2.2+dfsg-2~deb13u2 Target version: rails_7.2.2.2+dfsg-2~deb13u3 Base file: /srv/ftp-master.debian.org/ftp/pool/main/r/rails/rails_7.2.2.2+dfsg-2~deb13u2.dsc Target file: /srv/ftp-master.debian.org/policy/pool/main/r/rails/rails_7.2.2.2+dfsg-2~deb13u3.dsc changelog | 29 + patches/CVE-2026-122006.patch | 577 +++++++++++++++++++++++++++++++++++++ patches/CVE-2026-126067.patch | 643 ++++++++++++++++++++++++++++++++++++++++++ patches/CVE-2026-126068.patch | 69 ++++ patches/CVE-2026-126069.patch | 146 +++++++++ patches/CVE-2026-126070.patch | 97 ++++++ patches/CVE-2026-126072.patch | 171 +++++++++++ patches/CVE-2026-126073.patch | 161 ++++++++++ patches/CVE-2026-126074.patch | 126 ++++++++ patches/CVE-2026-126076.patch | 249 ++++++++++++++++ patches/CVE-2026-126077.patch | 240 +++++++++++++++ patches/CVE-2026-126078.patch | 149 +++++++++ patches/CVE-2026-126079.patch | 129 ++++++++ patches/CVE-2026-126080.patch | 84 +++++ patches/CVE-2026-126081.patch | 92 ++++++ patches/CVE-2026-126084.patch | 136 ++++++++ patches/CVE-2026-126085.patch | 228 ++++++++++++++ patches/CVE-2026-126186.patch | 114 +++++++ patches/CVE-2026-126188.patch | 274 +++++++++++++++++ patches/series | 18 + 20 files changed, 3732 insertions(+) dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmp4wwe3ga5/rails_7.2.2.2+dfsg-2~deb13u2.dsc: no acceptable signature found dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmp4wwe3ga5/rails_7.2.2.2+dfsg-2~deb13u3.dsc: no acceptable signature found diff -Nru rails-7.2.2.2+dfsg/debian/changelog rails-7.2.2.2+dfsg/debian/changelog --- rails-7.2.2.2+dfsg/debian/changelog 2026-10-04 21:13:12.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/changelog 2026-11-20 18:56:24.000000000 +0000 @@ -1,3 +1,32 @@ +rails (2:7.2.2.2+dfsg-2~deb13u3) trixie-security; urgency=high + + * Team upload. + * Backport fixes for 18 CVEs from Rails 8.0.5.2 (Closes: #1154301): + - CVE-2026-126188: Restrict the formats ffprobe and ffmpeg may open. + - CVE-2026-126186: Keep an extension only when it matches the media type. + - CVE-2026-126084: Sign GCS direct uploads with V2 when cache_control is + set. + - CVE-2026-126085: Bind the declared byte size on a GCS direct upload. + - CVE-2026-126081: Return the parameters object from each_key. + - CVE-2026-126080: Match safe_constantize load errors as a literal string. + - CVE-2026-126078: Escape each match substituted into highlight's + :highlighter. + - CVE-2026-126079: Escape "<" and ">" inside attribute values before + highlight and simple_format split the string. + - CVE-2026-126077: Keep a proxy from resending an upgraded session cookie. + - CVE-2026-126076: Do not write back a cache session deleted mid-request. + - CVE-2026-126074: Take a filename base and extension from the sanitized + name. + - CVE-2026-126073: Vary on every header that content negotiation reads. + - CVE-2026-126072: Close a live stream when its buffer is already closed. + - CVE-2026-126070: Encode quotation marks in strip_tags output. + - CVE-2026-126069: Skip a tag attribute name that is blank as a string. + - CVE-2026-126068: Reject a Mailgun timestamp more than two minutes ahead. + - CVE-2026-126067: Apply the SameSite policy on every session store. + - CVE-2026-122006: Apply an ImageMagick policy to every MiniMagick process. + + -- Simon Quigley Fri, 20 Nov 2026 12:56:24 -0600 + rails (2:7.2.2.2+dfsg-2~deb13u2) trixie-security; urgency=high * CVE-2026-66066: disable libvips unfuzzed loaders and savers when diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-122006.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-122006.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-122006.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-122006.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,577 @@ +Description: Apply an ImageMagick policy to every MiniMagick process. + CVE-2026-122006. Active Storage now prepends its own policy.xml to + MAGICK_CONFIGURE_PATH through MiniMagick.cli_env; it denies MSL, the + Ghostscript coders and gs delegate, and @filename indirection. + . + Backported to 7.2.2.2. The new image fixtures are not in this tarball, so + the policy test exercises the fixtures 7.2.4 already ships. +Author: Mike Dalessio +Origin: backport, https://github.com/rails/rails/commit/ea8c40121ce53a3d0255cd4eb6d13bfe3bc01776 +Bug: https://github.com/rails/rails/security/advisories/GHSA-f3w6-w445-fwh9 +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/activestorage/lib/active_storage/analyzer/image_analyzer/image_magick.rb ++++ b/activestorage/lib/active_storage/analyzer/image_analyzer/image_magick.rb +@@ -1,5 +1,7 @@ + # frozen_string_literal: true + ++require "active_storage/image_magick" ++ + module ActiveStorage + # This analyzer relies on the third-party {MiniMagick}[https://github.com/minimagick/minimagick] gem. MiniMagick requires + # the {ImageMagick}[http://www.imagemagick.org] system library. +@@ -17,6 +19,8 @@ module ActiveStorage + return {} + end + ++ ActiveStorage.require_securable_mini_magick! ++ + download_blob_to_tempfile do |file| + image = instrument("mini_magick") do + MiniMagick::Image.new(file.path) +--- a/activestorage/lib/active_storage/engine.rb ++++ b/activestorage/lib/active_storage/engine.rb +@@ -90,6 +90,13 @@ module ActiveStorage + ActiveStorage.variant_processor = app.config.active_storage.variant_processor || :mini_magick + ActiveStorage.previewers = app.config.active_storage.previewers || [] + ActiveStorage.analyzers = app.config.active_storage.analyzers || [] ++ ++ if ActiveStorage::MINIMAGICK_AVAILABLE && !ActiveStorage::MINIMAGICK_UNSECURABLE ++ ActiveStorage::ImageMagick.apply_policy ++ end ++ ++ ActiveStorage.require_securable_mini_magick! if ActiveStorage.variant_processor == :mini_magick ++ + ActiveStorage.paths = app.config.active_storage.paths || {} + ActiveStorage.routes_prefix = app.config.active_storage.routes_prefix || "/rails/active_storage" + ActiveStorage.draw_routes = app.config.active_storage.draw_routes != false +--- /dev/null ++++ b/activestorage/lib/active_storage/image_magick.rb +@@ -0,0 +1,63 @@ ++# frozen_string_literal: true ++ ++# :markup: markdown ++ ++require "active_storage" ++require "active_support/core_ext/object/blank" ++require "active_support/core_ext/string/filters" ++ ++begin ++ gem "mini_magick" ++ require "mini_magick" ++ ActiveStorage::MINIMAGICK_AVAILABLE = true # :nodoc: ++rescue LoadError => error ++ ActiveStorage::MINIMAGICK_AVAILABLE = false # :nodoc: ++ raise error unless error.message.include?("mini_magick") ++end ++ ++module ActiveStorage ++ # Adds Active Storage's ImageMagick security policy to every ImageMagick process MiniMagick spawns. ++ # ++ # ImageMagick reads every `policy.xml` on its configuration search path and applies all of them, ++ # so the shipped policy adds to the operator's policy rather than replacing it. `MAGICK_CONFIGURE_PATH` ++ # prepends to that search path; a value the operator has already set, in the environment or in ++ # `MiniMagick.cli_env`, is kept after the shipped directory. ++ module ImageMagick ++ POLICY_DIRECTORY = File.expand_path("image_magick", __dir__) ++ ++ # Called when Active Storage loads, and again after the application initializes, so that a ++ # `MAGICK_CONFIGURE_PATH` or `MiniMagick.cli_env` set by an initializer or dotenv keeps the policy. ++ def self.apply_policy # :nodoc: ++ operator_paths = operator_paths(MiniMagick.cli_env["MAGICK_CONFIGURE_PATH"]).presence || ++ operator_paths(ENV["MAGICK_CONFIGURE_PATH"]) ++ ++ MiniMagick.cli_env = MiniMagick.cli_env.merge("MAGICK_CONFIGURE_PATH" => configure_path(operator_paths)).freeze ++ end ++ ++ def self.configure_path(operator_path) ++ [ POLICY_DIRECTORY, *operator_paths(operator_path) ].join(File::PATH_SEPARATOR) ++ end ++ ++ def self.operator_paths(path) ++ Array(path).flat_map { |entry| entry.split(File::PATH_SEPARATOR) } - [ POLICY_DIRECTORY, "" ] ++ end ++ private_class_method :operator_paths ++ end ++end ++ ++ActiveStorage::MINIMAGICK_UNSECURABLE = ActiveStorage::MINIMAGICK_AVAILABLE && !MiniMagick.respond_to?(:cli_env=) # :nodoc: ++ ++module ActiveStorage ++ # Raises when the installed mini_magick cannot apply the shipped ImageMagick security policy. ++ # Called before Active Storage hands untrusted content to ImageMagick. ++ def self.require_securable_mini_magick! # :nodoc: ++ if MINIMAGICK_UNSECURABLE ++ raise <<~ERROR.squish ++ Active Storage's ImageMagick security policy requires mini_magick 5.1 or later. Please add ++ `gem "mini_magick", "~> 5.1"` to your Gemfile, or use the :vips variant processor. ++ ERROR ++ end ++ end ++end ++ ++ActiveStorage::ImageMagick.apply_policy if ActiveStorage::MINIMAGICK_AVAILABLE && !ActiveStorage::MINIMAGICK_UNSECURABLE +--- /dev/null ++++ b/activestorage/lib/active_storage/image_magick/policy.xml +@@ -0,0 +1,68 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +--- a/activestorage/test/analyzer/image_analyzer/image_magick_test.rb ++++ b/activestorage/test/analyzer/image_analyzer/image_magick_test.rb +@@ -6,6 +6,16 @@ require "database/setup" + require "active_storage/analyzer/image_analyzer" + + class ActiveStorage::Analyzer::ImageAnalyzer::ImageMagickTest < ActiveSupport::TestCase ++ test "analyzing raises when mini_magick cannot apply the security policy" do ++ analyze_with_image_magick do ++ blob = create_file_blob(filename: "racecar.jpg", content_type: "image/jpeg") ++ ++ stub_const(ActiveStorage, :MINIMAGICK_UNSECURABLE, true) do ++ assert_raises(RuntimeError, match: /requires mini_magick 5.1 or later/) { extract_metadata_from(blob) } ++ end ++ end ++ end ++ + test "analyzing a JPEG image" do + analyze_with_image_magick do + blob = create_file_blob(filename: "racecar.jpg", content_type: "image/jpeg") +--- /dev/null ++++ b/activestorage/test/image_magick_test.rb +@@ -0,0 +1,268 @@ ++# frozen_string_literal: true ++ ++require "test_helper" ++require "database/setup" ++require "active_storage/image_magick" ++require "active_storage/analyzer/image_analyzer/image_magick" ++ ++class ActiveStorage::ImageMagickTest < ActiveSupport::TestCase ++ SHIPPED_POLICY = File.read(File.join(ActiveStorage::ImageMagick::POLICY_DIRECTORY, "policy.xml")) ++ SHIPPED_RULES = SHIPPED_POLICY.scan(/]*pattern="([^"]+)"/) ++ DENIED_CODERS = %w[ MSL EPHEMERAL TEXT MPC SHOW WIN PLT URL HTTP HTTPS FTP FILE PS PS2 PS3 EPS EPS2 EPS3 EPI EPSF EPSI EPT EPT2 EPT3 PDF AI EPDF PDFA POCKETMOD XPS PCL ].freeze ++ GHOSTSCRIPT_MODULES = %w[ PS PS2 PS3 EPT PDF ].freeze ++ ++ # 7.2.4 has no PNG, AVIF, HEIC, or HEIF fixture in this tarball. ++ VARIABLE_FIXTURES = { ++ "image/gif" => "image.gif", ++ "image/jpeg" => "racecar.jpg", ++ "image/tiff" => "racecar.tif", ++ "image/bmp" => "colors.bmp", ++ "image/vnd.adobe.photoshop" => "icon.psd", ++ "image/vnd.microsoft.icon" => "favicon.ico", ++ "image/webp" => "valley.webp", ++ }.freeze ++ ++ test "every rule in the shipped policy is loaded" do ++ loaded = policy_listing.split(/^Path: /).find { |section| section.start_with?(ActiveStorage::ImageMagick::POLICY_DIRECTORY) } ++ ++ assert_not_nil loaded ++ assert_equal SHIPPED_RULES.size, loaded.scan(/^ Policy: /).size ++ end ++ ++ test "the shipped policy denies exactly the expected coders, the Ghostscript delegate, and @filename indirection" do ++ assert_equal DENIED_CODERS, SHIPPED_RULES.filter_map { |domain, pattern| pattern if domain == "coder" } ++ assert_equal [ [ "delegate", "gs" ], [ "path", "@*" ] ], SHIPPED_RULES.reject { |domain, _| domain == "coder" } ++ end ++ ++ test "every Ghostscript-backed coder is denied by coder" do ++ assert_empty gs_backed_coders - DENIED_CODERS ++ end ++ ++ DENIED_CODERS.each do |coder| ++ test "the shipped policy denies the #{coder} coder" do ++ if coder_registered?(coder) ++ error = assert_raises(MiniMagick::Error) { invoke_coder(coder) } ++ assert_match(/security policy/, error.message) ++ else ++ force_skip "this ImageMagick has no #{coder} coder" ++ end ++ end ++ end ++ ++ test "the shipped policy refuses @filename indirection" do ++ error = assert_raises(MiniMagick::Error) do ++ MiniMagick.identify { |identify| identify << "@#{file_fixture("racecar.jpg")}" } ++ end ++ assert_match(/security policy .@/, error.message) ++ end ++ ++ test "exercised fixtures are variable content types" do ++ assert_empty VARIABLE_FIXTURES.keys - ActiveStorage.variable_content_types ++ end ++ ++ VARIABLE_FIXTURES.each do |content_type, fixture| ++ test "#{content_type} still analyzes and transforms under the shipped policy" do ++ coder = coder_for(fixture) ++ skip "#{content_type}: this ImageMagick has no #{coder} coder" unless coder_registered?(coder) ++ ++ blob = create_file_blob(filename: fixture, content_type: content_type) ++ metadata = ActiveStorage::Analyzer::ImageAnalyzer::ImageMagick.new(blob).metadata ++ assert_operator metadata[:width], :>, 0 ++ assert_operator metadata[:height], :>, 0 ++ ++ with_mini_magick do ++ transformer = ActiveStorage::Transformers::ImageProcessingTransformer.new(resize_to_limit: [ 8, 8 ]) ++ transformer.transform(file_fixture(fixture).open, format: "png") do |output| ++ assert_operator output.size, :>, 0 ++ end ++ end ++ end ++ end ++ ++ test "image/svg+xml still analyzes under the shipped policy" do ++ skip "this ImageMagick has no SVG coder" unless coder_registered?("SVG") ++ ++ blob = create_file_blob(filename: "icon.svg", content_type: "image/svg+xml") ++ metadata = ActiveStorage::Analyzer::ImageAnalyzer::ImageMagick.new(blob).metadata ++ ++ assert_equal 792, metadata[:width] ++ assert_equal 584, metadata[:height] ++ end ++ ++ test "the shipped policy directory is added to the search path, not substituted for it" do ++ paths = policy_listing.scan(/^Path: (.+)$/).flatten ++ ++ assert_includes paths, "#{ActiveStorage::ImageMagick::POLICY_DIRECTORY}#{File::SEPARATOR}policy.xml" ++ assert_includes paths, "[built-in]" ++ end ++ ++ test "the shipped policy directory comes before an operator's own" do ++ assert_equal ActiveStorage::ImageMagick::POLICY_DIRECTORY, ActiveStorage::ImageMagick.configure_path(nil) ++ assert_equal ActiveStorage::ImageMagick::POLICY_DIRECTORY, ActiveStorage::ImageMagick.configure_path("") ++ assert_equal "#{ActiveStorage::ImageMagick::POLICY_DIRECTORY}#{File::PATH_SEPARATOR}/etc/magick", ++ ActiveStorage::ImageMagick.configure_path("/etc/magick") ++ end ++ ++ test "applying the policy again keeps the shipped directory first, once" do ++ with_cli_env("MAGICK_CONFIGURE_PATH" => ActiveStorage::ImageMagick.configure_path("/etc/magick")) do ++ ActiveStorage::ImageMagick.apply_policy ++ ++ assert_equal ActiveStorage::ImageMagick.configure_path("/etc/magick"), MiniMagick.cli_env["MAGICK_CONFIGURE_PATH"] ++ end ++ end ++ ++ test "applying the policy after initialization picks up a MAGICK_CONFIGURE_PATH set after Active Storage loaded" do ++ with_cli_env("MAGICK_CONFIGURE_PATH" => ActiveStorage::ImageMagick::POLICY_DIRECTORY) do ++ with_env("MAGICK_CONFIGURE_PATH" => "/etc/magick") do ++ ActiveStorage::ImageMagick.apply_policy ++ ++ assert_equal ActiveStorage::ImageMagick.configure_path("/etc/magick"), MiniMagick.cli_env["MAGICK_CONFIGURE_PATH"] ++ end ++ end ++ end ++ ++ test "applying the policy after initialization restores it to a MiniMagick.cli_env an initializer replaced" do ++ previous, MiniMagick.cli_env = MiniMagick.cli_env, { "OMP_NUM_THREADS" => "1" } ++ ++ ActiveStorage::ImageMagick.apply_policy ++ ++ assert_equal({ "OMP_NUM_THREADS" => "1", "MAGICK_CONFIGURE_PATH" => ActiveStorage::ImageMagick::POLICY_DIRECTORY }, MiniMagick.cli_env) ++ ensure ++ MiniMagick.cli_env = previous ++ end ++ ++ test "an operator's policy after the shipped one can allow a coder we deny" do ++ with_operator_policy %() do ++ assert_no_match(/security policy/, coder_error_message("TEXT")) ++ end ++ end ++ ++ test "the shipped policy allows label: text rendering" do ++ skip "this ImageMagick has no LABEL coder" unless coder_registered?("LABEL") ++ ++ assert_no_match(/security policy/, coder_error_message("LABEL")) ++ end ++ ++ test "an operator's policy after the shipped one can deny a coder we allow" do ++ with_operator_policy %() do ++ error = assert_raises(MiniMagick::Error) do ++ MiniMagick.identify { |identify| identify << file_fixture("racecar.jpg").to_s } ++ end ++ assert_match(/security policy/, error.message) ++ end ++ end ++ ++ private ++ def policy_listing ++ MiniMagick.identify { |identify| identify.list "policy" } ++ end ++ ++ def registered_formats ++ @registered_formats ||= MiniMagick.identify { |identify| identify.list "format" } ++ .scan(/^\s*(\w+)\*?\s+(\w+)\s+([rw+-]{3})/) ++ .select { |_token, _module, rights| rights.match?(/[rw]/) } ++ end ++ ++ def registered_coders ++ registered_formats.map { |token, _module, _rights| token } ++ end ++ ++ def gs_backed_coders ++ registered_formats.filter_map { |token, mod, _rights| token if GHOSTSCRIPT_MODULES.include?(mod) } ++ end ++ ++ def with_mini_magick ++ previous_processor, ActiveStorage.variant_processor = ActiveStorage.variant_processor, :mini_magick ++ yield ++ ensure ++ ActiveStorage.variant_processor = previous_processor ++ end ++ ++ def coder_registered?(coder) ++ registered_coders.include?(coder) ++ end ++ ++ def coder_for(fixture) ++ { "jpg" => "JPEG", "tif" => "TIFF", "ico" => "ICO" }.fetch(File.extname(fixture).delete("."), File.extname(fixture).delete(".").upcase) ++ end ++ ++ def invoke_coder(coder) ++ case coder ++ when "MSL" ++ with_tempfile("script.msl", %()) do |path| ++ MiniMagick.identify { |identify| identify << "msl:#{path}" } ++ end ++ when "PS", "EPS", "EPI", "EPSF", "EPSI", "EPT", "EPT2", "EPT3" ++ with_tempfile("page.ps", "%!PS\nshowpage\n") do |path| ++ MiniMagick.identify { |identify| identify << "#{coder.downcase}:#{path}" } ++ end ++ when "PDF", "AI", "EPDF", "PDFA", "POCKETMOD" ++ MiniMagick.identify { |identify| identify << "#{coder.downcase}:#{file_fixture("cropped.pdf")}" } ++ when "XPS", "PCL" ++ with_tempfile("page.ps", "%!PS\nshowpage\n") do |path| ++ MiniMagick.identify { |identify| identify << "#{coder.downcase}:#{path}" } ++ end ++ when "MPC" ++ MiniMagick.identify { |identify| identify << "mpc:#{file_fixture("racecar.jpg")}" } ++ when "FILE" ++ MiniMagick.identify { |identify| identify << "file://#{file_fixture("racecar.jpg")}" } ++ when "TEXT", "EPHEMERAL" ++ MiniMagick.identify { |identify| identify << "#{coder.downcase}:#{file_fixture("racecar.jpg")}" } ++ when "LABEL" ++ MiniMagick.identify { |identify| identify << "label:hello" } ++ when "PS2", "PS3", "EPS2", "EPS3" ++ Tempfile.create([ "page", ".#{coder.downcase}" ]) do |file| ++ MiniMagick.convert { |convert| convert << file_fixture("racecar.jpg").to_s << "#{coder.downcase}:#{file.path}" } ++ end ++ when "URL", "HTTP", "HTTPS", "FTP" ++ MiniMagick.identify { |identify| identify << "#{coder.downcase}://127.0.0.1:1/racecar.jpg" } ++ when "SHOW", "WIN", "PLT" ++ with_display_disabled do ++ MiniMagick.convert { |convert| convert << file_fixture("racecar.jpg").to_s << "#{coder.downcase}:" } ++ end ++ else ++ flunk "no invocation defined for the #{coder} coder; add one to invoke_coder" ++ end ++ end ++ ++ def coder_error_message(coder) ++ invoke_coder(coder) ++ "" ++ rescue MiniMagick::Error => error ++ error.message ++ end ++ ++ def with_tempfile(name, contents) ++ Tempfile.create(name.split(".").then { |base, ext| [ base, ".#{ext}" ] }) do |file| ++ file.write contents ++ file.flush ++ yield file.path ++ end ++ end ++ ++ def with_display_disabled(&block) ++ with_cli_env("DISPLAY" => "", "WAYLAND_DISPLAY" => "", &block) ++ end ++ ++ def with_operator_policy(rules, &block) ++ Dir.mktmpdir do |directory| ++ File.write File.join(directory, "policy.xml"), "#{rules}" ++ with_cli_env("MAGICK_CONFIGURE_PATH" => ActiveStorage::ImageMagick.configure_path(directory), &block) ++ end ++ end ++ ++ def with_env(overrides) ++ previous = ENV.to_h.slice(*overrides.keys) ++ ENV.update(overrides) ++ yield ++ ensure ++ overrides.each_key { |key| ENV[key] = previous[key] } ++ end ++ ++ def with_cli_env(overrides) ++ previous, MiniMagick.cli_env = MiniMagick.cli_env, MiniMagick.cli_env.merge(overrides) ++ yield ++ ensure ++ MiniMagick.cli_env = previous ++ end ++end +--- /dev/null ++++ b/railties/test/application/active_storage/engine_integration_test.rb +@@ -0,0 +1,97 @@ ++# frozen_string_literal: true ++ ++require "isolation/abstract_unit" ++ ++require "env_helpers" ++ ++module ApplicationTests ++ class ActiveStorageEngineTest < ActiveSupport::TestCase ++ include ActiveSupport::Testing::Isolation ++ ++ include EnvHelpers ++ ++ def setup ++ build_app ++ ++ File.write app_path("Gemfile"), <<~GEMFILE ++ source "https://rubygems.org" ++ gem "rails", path: "#{RAILS_FRAMEWORK_ROOT}" ++ ++ gem "propshaft" ++ gem "importmap-rails" ++ gem "sqlite3" ++ GEMFILE ++ ++ add_to_env_config :development, "config.active_storage.logger = ActiveSupport::Logger.new(STDOUT)" ++ ++ File.open("#{app_path}/config/boot.rb", "w") do |f| ++ f.puts "ENV['BUNDLE_GEMFILE'] = '#{app_path}/Gemfile'" ++ f.puts 'require "bundler/setup"' ++ end ++ end ++ ++ def teardown ++ teardown_app ++ end ++ ++ def test_mini_magick_transformer_raises_at_boot_with_unsecurable_mini_magick ++ add_to_config "config.active_storage.variant_processor = :mini_magick" ++ add_gem_stub "mini_magick", "5.0.1", "module MiniMagick; end" ++ ++ output = run_command("puts :booted") ++ ++ assert_not_includes(output, "booted") ++ assert_includes(output, "requires mini_magick 5.1 or later") ++ end ++ ++ def test_vips_transformer_boots_with_unsecurable_mini_magick ++ add_to_config "config.active_storage.variant_processor = :vips" ++ add_gem_stub "mini_magick", "5.0.1", "module MiniMagick; end" ++ ++ output = run_command("puts :booted") ++ ++ assert_includes(output, "booted") ++ end ++ ++ def test_image_magick_policy_is_applied_after_an_initializer_replaces_mini_magick_cli_env ++ File.open("#{app_path}/Gemfile", "a") { |f| f.puts 'gem "mini_magick", "~> 5.1"' } ++ app_file "config/initializers/mini_magick.rb", 'MiniMagick.cli_env = { "OMP_NUM_THREADS" => "1" }' ++ ++ output = run_command("puts MiniMagick.cli_env.inspect; puts ActiveStorage::ImageMagick::POLICY_DIRECTORY") ++ cli_env, policy_directory = output.lines.last(2).map(&:chomp) ++ ++ assert_equal({ "OMP_NUM_THREADS" => "1", "MAGICK_CONFIGURE_PATH" => policy_directory }.inspect, cli_env) ++ end ++ ++ private ++ def add_gem_stub(name, version, source) ++ FileUtils.mkdir_p app_path(name, "lib") ++ ++ File.write app_path(name, "#{name}.gemspec"), <<~RUBY ++ Gem::Specification.new do |spec| ++ spec.name = "#{name}" ++ spec.version = "#{version}" ++ spec.summary = "#{name} stub" ++ spec.authors = [ "Rails test" ] ++ spec.files = [ "lib/#{name}.rb" ] ++ end ++ RUBY ++ ++ File.write app_path(name, "lib", "#{name}.rb"), source ++ ++ File.open app_path("Gemfile"), "a" do |f| ++ f.puts %(gem "#{name}", path: "#{app_path(name)}") ++ end ++ end ++ ++ def run_command(cmd) ++ Dir.chdir(app_path) do ++ Bundler.with_original_env do ++ with_rails_env "development" do ++ `bin/rails runner "#{cmd}" 2>&1` ++ end ++ end ++ end ++ end ++ end ++end diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126067.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126067.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126067.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126067.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,643 @@ +Description: Apply the SameSite policy on every session store. + Only `CookieStore` defaulted `:same_site` to + `config.action_dispatch.cookies_same_site_protection`. `CacheStore`, + `MemCacheStore` and third-party stores built on `AbstractStore` or the + session mixins sent session cookies with no `SameSite` attribute. + . + Move the default into `Session::Compatibility`, which every session + store includes. `CookieStore` still forces `:cookie_only`; the other + stores keep their own setting. + . + ref: https://hackerone.com/reports/2637805 +Author: Jean Boussier +Origin: upstream, https://github.com/rails/rails/commit/f2392996be723708271a8d30bfcf0edc221e53ef +Bug: https://github.com/rails/rails/security/advisories/GHSA-gmj8-hvj3-49mw +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb ++++ b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb +@@ -20,8 +20,13 @@ module ActionDispatch + end + + module Compatibility ++ DEFAULT_SAME_SITE = proc { |request| request.cookies_same_site_protection } # :nodoc: ++ + def initialize(app, options = {}) + options[:key] ||= "_session_id" ++ unless options.key?(:same_site) || self.class::DEFAULT_OPTIONS.key?(:same_site) ++ options = options.merge(same_site: DEFAULT_SAME_SITE) ++ end + super + end + +--- a/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb ++++ b/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb +@@ -59,11 +59,8 @@ module ActionDispatch + end + end + +- DEFAULT_SAME_SITE = proc { |request| request.cookies_same_site_protection } # :nodoc: +- + def initialize(app, options = {}) + options[:cookie_only] = true +- options[:same_site] = DEFAULT_SAME_SITE if !options.key?(:same_site) + super + end + +--- a/actionpack/test/dispatch/session/abstract_store_test.rb ++++ b/actionpack/test/dispatch/session/abstract_store_test.rb +@@ -6,6 +6,8 @@ require "action_dispatch/middleware/sess + module ActionDispatch + module Session + class AbstractStoreTest < ActiveSupport::TestCase ++ include CookieAssertions ++ + class MemoryStore < AbstractStore + def initialize(app) + @sessions = {} +@@ -36,6 +38,39 @@ module ActionDispatch + assert Request::Session.find ActionDispatch::Request.new @env + end + ++ def test_session_cookie_gets_same_site_from_env ++ write_session = lambda do |env| ++ ActionDispatch::Request.new(env).session["foo"] = "bar" ++ [200, {}, []] ++ end ++ stack = ActionDispatch::Cookies.new(MemoryStore.new(write_session)) ++ env = Rack::MockRequest.env_for("/", "action_dispatch.cookies_same_site_protection" => proc { :strict }) ++ ++ response = Rack::MockResponse.new(*stack.call(env)) ++ ++ assert_set_cookie_attributes("_session_id", "SameSite=Strict", response.headers["set-cookie"]) ++ end ++ ++ def test_store_composed_from_the_mixins_gets_same_site_from_env ++ store_class = Class.new(Rack::Session::Abstract::Persisted) do ++ include Compatibility ++ include StaleSessionCheck ++ include SessionObject ++ ++ def find_session(req, sid) = [sid || generate_sid, {}] ++ def write_session(req, sid, session, options) = sid ++ end ++ write_session = lambda do |env| ++ ActionDispatch::Request.new(env).session["foo"] = "bar" ++ [200, {}, []] ++ end ++ env = Rack::MockRequest.env_for("/", "action_dispatch.cookies_same_site_protection" => proc { :strict }) ++ ++ response = Rack::MockResponse.new(*store_class.new(write_session).call(env)) ++ ++ assert_set_cookie_attributes("_session_id", "SameSite=Strict", response.headers["set-cookie"]) ++ end ++ + def test_new_session_object_is_merged_with_old + env = {} + as = MemoryStore.new app +--- a/actionpack/test/dispatch/session/cookie_store_test.rb ++++ b/actionpack/test/dispatch/session/cookie_store_test.rb +@@ -2,22 +2,10 @@ + + require "abstract_unit" + require "stringio" +-require "active_support/key_generator" +-require "active_support/messages/rotation_configuration" ++require_relative "store_shared_tests" + + class CookieStoreTest < ActionDispatch::IntegrationTest +- SessionKey = "_myapp_session" +- SessionSecret = "b3c631c314c0bbca50c1b2843150fe33" +- SessionSalt = "authenticated encrypted cookie" +- +- Generator = ActiveSupport::KeyGenerator.new(SessionSecret, iterations: 1000) +- Rotations = ActiveSupport::Messages::RotationConfiguration.new +- +- SameSite = proc { :lax } +- +- Encryptor = ActiveSupport::MessageEncryptor.new( +- Generator.generate_key(SessionSalt, 32), cipher: "aes-256-gcm", serializer: Marshal +- ) ++ include StoreSharedTests + + class TestController < ActionController::Base + def no_session_access +@@ -72,8 +60,6 @@ class CookieStoreTest < ActionDispatch:: + end + end + +- include CookieAssertions +- + def assert_session_cookie(attributes_string, contents) + cookies = parse_set_cookies_headers(headers["Set-Cookie"]) + +@@ -403,31 +389,6 @@ class CookieStoreTest < ActionDispatch:: + end + end + +- test "default same_site derives SameSite from env" do +- with_test_route_set do +- get "/set_session_value" +- assert_set_cookie_attributes("_myapp_session", "SameSite=Lax") +- end +- end +- +- test "explicit same_site sets SameSite" do +- cookie_options(same_site: :strict) +- +- with_test_route_set do +- get "/set_session_value" +- assert_set_cookie_attributes("_myapp_session", "SameSite=Strict") +- end +- end +- +- test "explicit nil same_site omits SameSite" do +- cookie_options(same_site: nil) +- +- with_test_route_set do +- get "/set_session_value" +- assert_not_set_cookie_attributes("_myapp_session", "SameSite") +- end +- end +- + private + # Overwrite `get` to set env hash + def get(path, **options) +@@ -447,12 +408,12 @@ class CookieStoreTest < ActionDispatch:: + end + + def cookie_options(options = {}) +- (@cookie_options ||= { key: SessionKey }).merge!(options) ++ @cookie_options ||= options + end + + def app + @app ||= self.class.build_app do |middleware| +- middleware.use ActionDispatch::Session::CookieStore, cookie_options ++ middleware.use ActionDispatch::Session::CookieStore, cookie_options.reverse_merge({ key: SessionKey }) + middleware.delete ActionDispatch::ShowExceptions + end + end +--- a/actionpack/test/dispatch/session/cache_store_test.rb ++++ b/actionpack/test/dispatch/session/cache_store_test.rb +@@ -1,8 +1,11 @@ + # frozen_string_literal: true + + require "abstract_unit" ++require_relative "store_shared_tests" + + class CacheStoreTest < ActionDispatch::IntegrationTest ++ include StoreSharedTests ++ + singleton_class.attr_accessor :app_under_test + + class LocallyCachedStore < ActiveSupport::Cache::Store +@@ -89,7 +92,7 @@ class CacheStoreTest < ActionDispatch::I + with_test_route_set do + get "/set_session_value" + assert_response :success +- assert cookies["_session_id"] ++ assert cookies[SessionKey] + + get "/get_session_value" + assert_response :success +@@ -109,8 +112,8 @@ class CacheStoreTest < ActionDispatch::I + with_test_route_set do + get "/set_session_value" + assert_response :success +- assert cookies["_session_id"] +- session_cookie = cookies.get_cookie("_session_id") ++ assert cookies[SessionKey] ++ session_cookie = cookies.get_cookie(SessionKey) + + get "/call_reset_session" + assert_response :success +@@ -129,7 +132,7 @@ class CacheStoreTest < ActionDispatch::I + + with_test_route_set do + get "/set_session_value" +- session_cookie = cookies.get_cookie("_session_id") ++ session_cookie = cookies.get_cookie(SessionKey) + + get "/read_session_while_another_request_logs_out" + assert_response :success +@@ -146,7 +149,7 @@ class CacheStoreTest < ActionDispatch::I + + with_test_route_set do + get "/set_session_value" +- session_cookie = cookies.get_cookie("_session_id") ++ session_cookie = cookies.get_cookie(SessionKey) + + get "/write_session_while_another_request_logs_out" + assert_response :success +@@ -160,7 +163,7 @@ class CacheStoreTest < ActionDispatch::I + + def test_session_logged_out_during_a_request_does_not_resend_its_cookie + @cache = LocallyCachedStore.new +- cache_store_options(expire_after: 1.hour) ++ cookie_options(expire_after: 1.hour) + + with_test_route_set do + get "/set_session_value" +@@ -174,11 +177,11 @@ class CacheStoreTest < ActionDispatch::I + def test_session_reset_by_the_request_is_saved_under_the_new_id + with_test_route_set do + get "/set_session_value" +- old_session_id = cookies["_session_id"] ++ old_session_id = cookies[SessionKey] + + get "/call_reset_session" + assert_response :success +- assert_not_equal old_session_id, cookies["_session_id"] ++ assert_not_equal old_session_id, cookies[SessionKey] + + get "/get_reset_session_value" + assert_equal 'bar: "baz"', response.body +@@ -190,7 +193,7 @@ class CacheStoreTest < ActionDispatch::I + get "/get_session_value" + assert_response :success + assert_equal "foo: nil", response.body +- assert_nil cookies["_session_id"], "should only create session on write, not read" ++ assert_nil cookies[SessionKey], "should only create session on write, not read" + end + end + +@@ -198,8 +201,8 @@ class CacheStoreTest < ActionDispatch::I + with_test_route_set do + get "/set_session_value" + assert_response :success +- assert cookies["_session_id"] +- session_id = cookies["_session_id"] ++ assert cookies[SessionKey] ++ session_id = cookies[SessionKey] + + get "/call_reset_session" + assert_response :success +@@ -220,8 +223,8 @@ class CacheStoreTest < ActionDispatch::I + with_test_route_set do + get "/set_session_value" + assert_response :success +- assert cookies["_session_id"] +- session_id = cookies["_session_id"] ++ assert cookies[SessionKey] ++ session_id = cookies[SessionKey] + + get "/get_session_id" + assert_response :success +@@ -234,7 +237,7 @@ class CacheStoreTest < ActionDispatch::I + with_autoload_path "session_autoload_test" do + get "/set_serialized_session_value" + assert_response :success +- assert cookies["_session_id"] ++ assert cookies[SessionKey] + end + with_autoload_path "session_autoload_test" do + get "/get_session_id" +@@ -252,7 +255,7 @@ class CacheStoreTest < ActionDispatch::I + with_test_route_set do + get "/set_session_value" + assert_response :success +- assert cookies["_session_id"] ++ assert cookies[SessionKey] + + get "/get_session_value" + assert_response :success +@@ -263,17 +266,18 @@ class CacheStoreTest < ActionDispatch::I + def test_prevents_session_fixation + with_test_route_set do + sid = Rack::Session::SessionId.new("0xhax") +- assert_nil @cache.read("_session_id:#{sid.private_id}") ++ assert_nil @cache.read(cache_key(sid.private_id)) + +- cookies["_session_id"] = sid.public_id ++ cookies[SessionKey] = sid.public_id + get "/set_session_value" + + assert_response :success +- assert_not_equal sid.public_id, cookies["_session_id"] +- assert_nil @cache.read("_session_id:#{sid.private_id}") ++ assert_not_nil cookies[SessionKey] ++ assert_not_equal sid.public_id, cookies[SessionKey] ++ assert_nil @cache.read(cache_key(sid.private_id)) + assert_equal( + { "foo" => "bar" }, +- @cache.read("_session_id:#{Rack::Session::SessionId.new(cookies['_session_id']).private_id}") ++ @cache.read(cache_key(Rack::Session::SessionId.new(cookies[SessionKey]).private_id)) + ) + end + end +@@ -282,12 +286,12 @@ class CacheStoreTest < ActionDispatch::I + with_test_route_set do + get "/set_session_value" + assert_response :success +- assert cookies["_session_id"] ++ assert cookies[SessionKey] + +- sid = Rack::Session::SessionId.new(cookies["_session_id"]) +- session = @cache.read("_session_id:#{sid.private_id}") +- @cache.delete("_session_id:#{sid.private_id}") +- @cache.write("_session_id:#{sid.public_id}", session) ++ sid = Rack::Session::SessionId.new(cookies[SessionKey]) ++ session = @cache.read(cache_key(sid.private_id)) ++ @cache.delete(cache_key(sid.private_id)) ++ @cache.write(cache_key(sid.public_id), session) + + get "/get_session_value" + assert_response :success +@@ -298,12 +302,12 @@ class CacheStoreTest < ActionDispatch::I + def test_session_read_by_legacy_id_is_saved_under_private_id + with_test_route_set do + get "/set_session_value" +- sid = Rack::Session::SessionId.new(cookies["_session_id"]) +- @cache.write("_session_id:#{sid.public_id}", @cache.read("_session_id:#{sid.private_id}")) +- @cache.delete("_session_id:#{sid.private_id}") ++ sid = Rack::Session::SessionId.new(cookies[SessionKey]) ++ @cache.write(cache_key(sid.public_id), @cache.read(cache_key(sid.private_id))) ++ @cache.delete(cache_key(sid.private_id)) + + get "/get_session_value" +- assert_equal({ "foo" => "bar" }, @cache.read("_session_id:#{sid.private_id}")) ++ assert_equal({ "foo" => "bar" }, @cache.read(cache_key(sid.private_id))) + end + end + +@@ -311,32 +315,70 @@ class CacheStoreTest < ActionDispatch::I + with_test_route_set do + get "/set_session_value" + assert_response :success +- assert cookies["_session_id"] ++ assert cookies[SessionKey] + +- sid = Rack::Session::SessionId.new(cookies["_session_id"]) +- session = @cache.read("_session_id:#{sid.private_id}") +- @cache.delete("_session_id:#{sid.private_id}") +- @cache.write("_session_id:#{sid.public_id}", session) ++ sid = Rack::Session::SessionId.new(cookies[SessionKey]) ++ session = @cache.read(cache_key(sid.private_id)) ++ @cache.delete(cache_key(sid.private_id)) ++ @cache.write(cache_key(sid.public_id), session) + + get "/call_reset_session" + assert_response :success + assert_not_equal [], headers["Set-Cookie"] + +- assert_nil @cache.read("_session_id:#{sid.private_id}") +- assert_nil @cache.read("_session_id:#{sid.public_id}") ++ assert_nil @cache.read(cache_key(sid.private_id)) ++ assert_nil @cache.read(cache_key(sid.public_id)) ++ end ++ end ++ ++ def test_cookie_only_false_reads_session_id_from_params ++ cookie_options(cookie_only: false) ++ ++ with_test_route_set do ++ get "/set_session_value" ++ assert_response :success ++ session_id = cookies[SessionKey] ++ ++ reset! ++ ++ get "/get_session_value", params: { SessionKey => session_id } ++ assert_response :success ++ assert_equal 'foo: "bar"', response.body + end + end + ++ def test_same_site_in_subclass_default_options_wins_over_default ++ store_class = Class.new(ActionDispatch::Session::CacheStore) do ++ const_set(:DEFAULT_OPTIONS, superclass::DEFAULT_OPTIONS.merge(same_site: :strict).freeze) ++ end ++ @app = self.class.build_app do |middleware| ++ middleware.use store_class, key: SessionKey, cache: ActiveSupport::Cache::MemoryStore.new ++ middleware.delete ActionDispatch::ShowExceptions ++ end ++ ++ with_test_route_set do ++ get "/set_session_value" ++ assert_set_cookie_attributes(SessionKey, "SameSite=Strict") ++ end ++ end ++ ++ def test_initialize_does_not_add_same_site_to_the_callers_options ++ options = { cache: ActiveSupport::Cache::MemoryStore.new } ++ ActionDispatch::Session::CacheStore.new(->(env) { [200, {}, []] }, options) ++ ++ assert_not options.key?(:same_site) ++ end ++ + private +- def cache_store_options(options = {}) +- @cache_store_options ||= options ++ def cache_key(id) ++ "_session_id:#{id}" + end + + def app + @app ||= CacheStoreTest.app_under_test = self.class.build_app do |middleware| + @cache ||= ActiveSupport::Cache::MemoryStore.new + middleware.use @cache.middleware if @cache.respond_to?(:middleware) +- middleware.use ActionDispatch::Session::CacheStore, key: "_session_id", cache: @cache, **cache_store_options ++ middleware.use ActionDispatch::Session::CacheStore, cookie_options.reverse_merge({ key: SessionKey, cache: @cache }) + middleware.delete ActionDispatch::ShowExceptions + end + end +--- a/actionpack/test/dispatch/session/mem_cache_store_test.rb ++++ b/actionpack/test/dispatch/session/mem_cache_store_test.rb +@@ -2,6 +2,7 @@ + + require "abstract_unit" + require "securerandom" ++require_relative "store_shared_tests" + + # You need to start a memcached server inorder to run these tests + class MemCacheStoreTest < ActionDispatch::IntegrationTest +@@ -42,11 +43,13 @@ class MemCacheStoreTest < ActionDispatch + ss = Dalli::Client.new(servers).stats + raise Dalli::DalliError unless ss[servers] || ss[servers + ":11211"] + ++ include StoreSharedTests ++ + def test_setting_and_getting_session_value + with_test_route_set do + get "/set_session_value" + assert_response :success +- assert cookies["_session_id"] ++ assert cookies[SessionKey] + + get "/get_session_value" + assert_response :success +@@ -70,8 +73,8 @@ class MemCacheStoreTest < ActionDispatch + with_test_route_set do + get "/set_session_value" + assert_response :success +- assert cookies["_session_id"] +- session_cookie = cookies.get_cookie("_session_id") ++ assert cookies[SessionKey] ++ session_cookie = cookies.get_cookie(SessionKey) + + get "/call_reset_session" + assert_response :success +@@ -92,7 +95,7 @@ class MemCacheStoreTest < ActionDispatch + get "/get_session_value" + assert_response :success + assert_equal "foo: nil", response.body +- assert_nil cookies["_session_id"], "should only create session on write, not read" ++ assert_nil cookies[SessionKey], "should only create session on write, not read" + end + rescue Dalli::RingError => ex + skip ex.message, ex.backtrace +@@ -102,8 +105,8 @@ class MemCacheStoreTest < ActionDispatch + with_test_route_set do + get "/set_session_value" + assert_response :success +- assert cookies["_session_id"] +- session_id = cookies["_session_id"] ++ assert cookies[SessionKey] ++ session_id = cookies[SessionKey] + + get "/call_reset_session" + assert_response :success +@@ -125,8 +128,8 @@ class MemCacheStoreTest < ActionDispatch + with_test_route_set do + get "/set_session_value" + assert_response :success +- assert cookies["_session_id"] +- session_id = cookies["_session_id"] ++ assert cookies[SessionKey] ++ session_id = cookies[SessionKey] + + get "/get_session_id" + assert_response :success +@@ -141,7 +144,7 @@ class MemCacheStoreTest < ActionDispatch + with_autoload_path "session_autoload_test" do + get "/set_serialized_session_value" + assert_response :success +- assert cookies["_session_id"] ++ assert cookies[SessionKey] + end + with_autoload_path "session_autoload_test" do + get "/get_session_id" +@@ -156,7 +159,7 @@ class MemCacheStoreTest < ActionDispatch + with_test_route_set do + get "/set_session_value" + assert_response :success +- assert cookies["_session_id"] ++ assert cookies[SessionKey] + + get "/get_session_value" + assert_response :success +@@ -171,13 +174,13 @@ class MemCacheStoreTest < ActionDispatch + get "/get_session_value" + assert_response :success + assert_equal "foo: nil", response.body +- session_id = cookies["_session_id"] ++ session_id = cookies[SessionKey] + + reset! + + get "/set_session_value", params: { _session_id: session_id } + assert_response :success +- assert_not_equal session_id, cookies["_session_id"] ++ assert_not_equal session_id, cookies[SessionKey] + end + rescue Dalli::RingError => ex + skip ex.message, ex.backtrace +@@ -189,10 +192,12 @@ class MemCacheStoreTest < ActionDispatch + private + def app + @app ||= self.class.build_app do |middleware| +- middleware.use ActionDispatch::Session::MemCacheStore, +- key: "_session_id", namespace: "mem_cache_store_test:#{SecureRandom.hex(10)}", ++ middleware.use ActionDispatch::Session::MemCacheStore, cookie_options.reverse_merge( ++ key: SessionKey, ++ namespace: "mem_cache_store_test:#{SecureRandom.hex(10)}", + memcache_server: ENV["MEMCACHE_SERVERS"] || "localhost:11211", + socket_timeout: 60 ++ ) + middleware.delete ActionDispatch::ShowExceptions + end + end +--- /dev/null ++++ b/actionpack/test/dispatch/session/store_shared_tests.rb +@@ -0,0 +1,77 @@ ++# frozen_string_literal: true ++ ++require "abstract_unit" ++require "active_support/key_generator" ++require "active_support/messages/rotation_configuration" ++ ++module StoreSharedTests ++ extend ActiveSupport::Testing::Declarative ++ include CookieAssertions ++ ++ SessionKey = "_myapp_session" ++ SessionSecret = "b3c631c314c0bbca50c1b2843150fe33" ++ SessionSalt = "authenticated encrypted cookie" ++ ++ Generator = ActiveSupport::KeyGenerator.new(SessionSecret, iterations: 1000) ++ Rotations = ActiveSupport::Messages::RotationConfiguration.new ++ ++ SameSite = proc { :lax } ++ ++ Encryptor = ActiveSupport::MessageEncryptor.new( ++ Generator.generate_key(SessionSalt, 32), cipher: "aes-256-gcm", serializer: Marshal ++ ) ++ ++ test "default same_site derives SameSite from env" do ++ with_test_route_set do ++ get "/set_session_value" ++ assert_set_cookie_attributes("_myapp_session", "SameSite=Lax") ++ end ++ end ++ ++ test "default same_site follows the SameSite policy in env" do ++ with_test_route_set do ++ get "/set_session_value", headers: { "action_dispatch.cookies_same_site_protection" => proc { :strict } } ++ assert_set_cookie_attributes("_myapp_session", "SameSite=Strict") ++ end ++ end ++ ++ test "explicit same_site sets SameSite" do ++ cookie_options(same_site: :strict) ++ ++ with_test_route_set do ++ get "/set_session_value" ++ assert_set_cookie_attributes("_myapp_session", "SameSite=Strict") ++ end ++ end ++ ++ test "explicit nil same_site omits SameSite" do ++ cookie_options(same_site: nil) ++ ++ with_test_route_set do ++ get "/set_session_value" ++ assert_not_set_cookie_attributes("_myapp_session", "SameSite") ++ end ++ end ++ ++ private ++ # Overwrite `get` to set env hash ++ def get(path, **options) ++ options[:headers] ||= {} ++ options[:headers].tap do |config| ++ config["action_dispatch.secret_key_base"] = SessionSecret ++ config["action_dispatch.authenticated_encrypted_cookie_salt"] = SessionSalt ++ config["action_dispatch.use_authenticated_cookie_encryption"] = true ++ ++ config["action_dispatch.key_generator"] ||= Generator ++ config["action_dispatch.cookies_rotations"] ||= Rotations ++ ++ config["action_dispatch.cookies_same_site_protection"] ||= SameSite ++ end ++ ++ super ++ end ++ ++ def cookie_options(options = {}) ++ (@cookie_options ||= { key: SessionKey }).merge!(options) ++ end ++end diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126068.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126068.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126068.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126068.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,69 @@ +Description: Reject a Mailgun timestamp more than two minutes ahead. + The Mailgun ingress rejected a timestamp more than 2 minutes old but + accepted any timestamp ahead of local time. + . + Allow 2 minutes of drift in both directions. +Author: Mike Dalessio +Origin: upstream, https://github.com/rails/rails/commit/4aa2ec66822bc4eb8b341a0608f1c90a3e371a34 +Bug: https://github.com/rails/rails/security/advisories/GHSA-5957-c7qm-m469 +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/actionmailbox/app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb ++++ b/actionmailbox/app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb +@@ -99,7 +99,7 @@ module ActionMailbox + + # Allow for 2 minutes of drift between Mailgun time and local server time. + def recent? +- Time.at(timestamp) >= 2.minutes.ago ++ Time.at(timestamp).between?(2.minutes.ago, 2.minutes.from_now) + end + + def expected_signature +--- a/actionmailbox/test/controllers/ingresses/mailgun/inbound_emails_controller_test.rb ++++ b/actionmailbox/test/controllers/ingresses/mailgun/inbound_emails_controller_test.rb +@@ -76,6 +76,42 @@ class ActionMailbox::Ingresses::Mailgun: + assert_response :unauthorized + end + ++ test "receiving an inbound email from Mailgun with a timestamp slightly ahead of local time" do ++ assert_difference -> { ActionMailbox::InboundEmail.count }, +1 do ++ travel_to "2018-10-09 15:14:00 EDT" ++ post rails_mailgun_inbound_emails_url, params: { ++ timestamp: 1539112500, ++ token: "7VwW7k6Ak7zcTwoSoNm7aTtbk1g67MKAnsYLfUB7PdszbgR5Xi", ++ signature: "ef24c5225322217bb065b80bb54eb4f9206d764e3e16abab07f0a64d1cf477cc", ++ "body-mime" => file_fixture("../files/welcome.eml").read ++ } ++ end ++ ++ assert_response :no_content ++ end ++ ++ test "rejecting an inbound email from Mailgun with a timestamp from the future" do ++ original_timestamp = "1539112500" ++ original_token = "7VwW7k6Ak7zcTwoSoNm7aTtbk1g67MKAnsYLfUB7PdszbgR5Xi" ++ future_timestamp = original_timestamp + original_token[0] ++ shortened_token = original_token[1..] ++ ++ # The signature covers the timestamp and token joined into one string, so it holds for any split of that string. ++ assert_equal original_timestamp + original_token, future_timestamp + shortened_token ++ ++ assert_no_difference -> { ActionMailbox::InboundEmail.count } do ++ travel_to "2018-10-09 15:26:00 EDT" ++ post rails_mailgun_inbound_emails_url, params: { ++ timestamp: future_timestamp, ++ token: shortened_token, ++ signature: "ef24c5225322217bb065b80bb54eb4f9206d764e3e16abab07f0a64d1cf477cc", ++ "body-mime" => file_fixture("../files/welcome.eml").read ++ } ++ end ++ ++ assert_response :unauthorized ++ end ++ + test "rejecting a forged inbound email from Mailgun" do + assert_no_difference -> { ActionMailbox::InboundEmail.count } do + travel_to "2018-10-09 15:15:00 EDT" diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126069.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126069.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126069.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126069.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,146 @@ +Description: Skip a tag attribute name that is blank as a string. + The guard 63f5ad83 added to `tag_options` tested `blank?` on the raw key, + but `ERB::Util.xml_name_escape` escapes the key converted to a String. + `Symbol#blank?` is `Symbol#empty?`, so `:" "` passed the guard, escaped to + the empty string, and produced an attribute with no name, which the HTML5 + tokenizer reads as a real one. `image_tag`, `video_tag`, `audio_tag` and + `picture_tag` symbolize their keys, so a String key reached it too. + . + Keep `key.blank?`, then convert the key once and pass the converted name + to `append_tag_option`, `append_prefix_tag_option` and + `append_boolean_tag_option`, so the name tested is the name emitted. + . + ref: https://hackerone.com/reports/3904103 +Author: Mike Dalessio +Origin: upstream, https://github.com/rails/rails/commit/f47452533e1f28d847c63181b9d5f8b7243ef9a4 +Bug: https://github.com/rails/rails/security/advisories/GHSA-68p9-83h6-5wpj +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/actionview/lib/action_view/helpers/tag_helper.rb ++++ b/actionview/lib/action_view/helpers/tag_helper.rb +@@ -265,18 +265,27 @@ module ActionView + options.each_pair do |key, value| + next if key.blank? + ++ name = Symbol === key ? key.name : key.to_s ++ next if name.blank? ++ + type = TAG_TYPES[key] + if type == :data && value.is_a?(Hash) + value.each_pair do |k, v| + next if k.blank? || v.nil? + ++ nested_name = Symbol === k ? k.name : k.to_s ++ next if nested_name.blank? ++ + output << sep +- output << prefix_tag_option(key, k, v, escape) ++ output << prefix_tag_option(name, nested_name, v, escape) + end + elsif type == :aria && value.is_a?(Hash) + value.each_pair do |k, v| + next if k.blank? || v.nil? + ++ nested_name = Symbol === k ? k.name : k.to_s ++ next if nested_name.blank? ++ + case v + when Array, Hash + tokens = TagHelper.build_tag_values(v) +@@ -288,16 +297,16 @@ module ActionView + end + + output << sep +- output << prefix_tag_option(key, k, v, escape) ++ output << prefix_tag_option(name, nested_name, v, escape) + end + elsif type == :boolean + if value + output << sep +- output << boolean_tag_option(key) ++ output << boolean_tag_option(name) + end + elsif !value.nil? + output << sep +- output << tag_option(key, value, escape) ++ output << tag_option(name, value, escape) + end + end + output unless output.empty? +--- a/actionview/test/template/asset_tag_helper_test.rb ++++ b/actionview/test/template/asset_tag_helper_test.rb +@@ -758,6 +758,14 @@ class AssetTagHelperTest < ActionView::T + assert_equal({ size: "16x10" }, options) + end + ++ def test_image_tag_with_whitespace_attribute_name_generates_valid_markup ++ # https://hackerone.com/reports/3904103 ++ html = image_tag("/nonexistent.png", { " " => "/onerror=alert(1)//" }) ++ fragment = Nokogiri::HTML5::DocumentFragment.parse(html) ++ attrs = fragment.at_css("img").attribute_nodes.map(&:name) ++ assert_equal [ "src" ], attrs ++ end ++ + def test_image_tag_raises_an_error_for_competing_size_arguments + exception = assert_raise(ArgumentError) do + image_tag("gold.png", height: "100", width: "200", size: "45x70") +--- a/actionview/test/template/tag_helper_test.rb ++++ b/actionview/test/template/tag_helper_test.rb +@@ -10,6 +10,17 @@ class TagHelperTest < ActionView::TestCa + COMMON_DANGEROUS_CHARS = "&<>\"' %*+,/;=^|" + INVALID_TAG_CHARS = "> /" + ++ class NameThatChangesWhenConverted ++ def initialize ++ @conversions = 0 ++ end ++ ++ def to_s ++ @conversions += 1 ++ @conversions == 1 ? "first" : " " ++ end ++ end ++ + def test_tag + assert_equal "
", tag("br") + assert_equal "
", tag(:br, clear: "left") +@@ -233,6 +244,36 @@ class TagHelperTest < ActionView::TestCa + assert_equal [ "src" ], attrs + end + ++ def test_tag_with_whitespace_symbol_attribute_name_generates_valid_markup ++ # https://hackerone.com/reports/3904103 ++ html = tag("img", "src" => "/nonexistent.png", :" " => "/onerror=alert(1)//") ++ fragment = Nokogiri::HTML5::DocumentFragment.parse(html) ++ attrs = fragment.at_css("img").attribute_nodes.map(&:name) ++ assert_equal [ "src" ], attrs ++ end ++ ++ def test_tag_with_whitespace_symbol_data_attribute_name_is_skipped ++ assert_equal "", tag("img", data: { " ": "/onerror=alert(1)//" }) ++ end ++ ++ def test_tag_with_whitespace_symbol_aria_attribute_name_is_skipped ++ assert_equal "", tag("img", aria: { " ": "/onerror=alert(1)//" }) ++ end ++ ++ def test_tag_with_attribute_name_that_is_blank_before_conversion_is_skipped ++ assert_equal "", tag("img", { false => "/onerror=alert(1)//" }) ++ assert_equal "", tag("img", { [] => "/onerror=alert(1)//" }) ++ assert_equal "", tag("img", { data: { false => "x" } }) ++ assert_equal "", tag("img", { aria: { false => "x" } }) ++ end ++ ++ def test_tag_with_attribute_name_that_changes_when_converted_generates_valid_markup ++ html = tag("img", "src" => "/nonexistent.png", NameThatChangesWhenConverted.new => "/onerror=alert(1)//") ++ fragment = Nokogiri::HTML5::DocumentFragment.parse(html) ++ attrs = fragment.at_css("img").attribute_nodes.map(&:name) ++ assert_equal [ "src", "first" ], attrs ++ end ++ + def test_tag_builder_with_dangerous_unknown_attribute_name + escaped_dangerous_chars = "_" * COMMON_DANGEROUS_CHARS.size + assert_equal "", diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126070.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126070.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126070.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126070.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,97 @@ +Description: Encode quotation marks in strip_tags output. + `strip_tags` returns an `html_safe` string, but was not encoding + quotation marks. The method now encodes all five HTML-significant + characters (`&`, `<`, `>`, `"`, `'`), consistent with the existing + `html_safe` convention. + . + Callers that use the output as plain text, such as text templates or + JSON, now see `"` and `'` where they saw `"` and `'`. + . + Also document that `sanitize` output is safe only as element content. +Author: Mike Dalessio +Origin: upstream, https://github.com/rails/rails/commit/c3772a10f405f9644125cbb484adfd2aa7a25a59 +Bug: https://github.com/rails/rails/security/advisories/GHSA-rq8q-p985-fjq7 +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/actionview/lib/action_view/helpers/sanitize_helper.rb ++++ b/actionview/lib/action_view/helpers/sanitize_helper.rb +@@ -1,5 +1,6 @@ + # frozen_string_literal: true + ++require "active_support/core_ext/string/output_safety" + require "rails-html-sanitizer" + + module ActionView +@@ -27,6 +28,9 @@ module ActionView + # Please note that sanitizing user-provided text does not guarantee that the + # resulting markup is valid or even well-formed. + # ++ # The output is markup, which is safe only as element content. Do not use it in an attribute ++ # value; use +strip_tags+ or a tag helper such as tag.a(title: ...) instead. ++ # + # ==== Options + # + # [+:tags+] +@@ -131,7 +135,8 @@ module ActionView + # strip_tags("> A quote from Smith & Wesson") + # # => > A quote from Smith & Wesson + def strip_tags(html) +- self.class.full_sanitizer.sanitize(html)&.html_safe ++ stripped = self.class.full_sanitizer.sanitize(html) ++ ERB::Util.html_escape_once(stripped) if stripped + end + + # Strips all link tags from +html+ leaving just the link text. +--- a/actionview/test/template/sanitize_helper_test.rb ++++ b/actionview/test/template/sanitize_helper_test.rb +@@ -336,6 +336,10 @@ module SanitizeHelperVendorTests + assert_includes(result, "height") + end + ++ def test_strip_tags_returns_nil_for_nil ++ assert_nil(@subject.strip_tags(nil)) ++ end ++ + def test_strip_tags + input = %(
Example of a fragment
) + result = @subject.strip_tags(input) +@@ -343,6 +347,36 @@ module SanitizeHelperVendorTests + assert_equal("Example of a fragment", result) + end + ++ def test_strip_tags_encodes_ampersand ++ assert_equal("this & that", @subject.strip_tags("this & that")) ++ assert_equal("this & that", @subject.strip_tags("this & that")) ++ assert_equal("this & that", @subject.strip_tags("this & that")) ++ end ++ ++ def test_strip_tags_encodes_less_than ++ assert_equal("this < that", @subject.strip_tags("this < that")) ++ assert_equal("this < that", @subject.strip_tags("this < that")) ++ assert_equal("this < that", @subject.strip_tags("this < that")) ++ end ++ ++ def test_strip_tags_encodes_greater_than ++ assert_equal("this > that", @subject.strip_tags("this > that")) ++ assert_equal("this > that", @subject.strip_tags("this > that")) ++ assert_equal("this > that", @subject.strip_tags("this > that")) ++ end ++ ++ def test_strip_tags_encodes_double_quote ++ assert_equal("this " that", @subject.strip_tags("this \" that")) ++ assert_equal("this " that", @subject.strip_tags("this " that")) ++ assert_equal("this " that", @subject.strip_tags("this " that")) ++ end ++ ++ def test_strip_tags_encodes_single_quote ++ assert_equal("this ' that", @subject.strip_tags("this ' that")) ++ assert_equal("this ' that", @subject.strip_tags("this ' that")) ++ assert_equal("this ' that", @subject.strip_tags("this ' that")) ++ end ++ + def test_strip_links + input = %(
Example of a fragment
) + result = @subject.strip_links(input) diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126072.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126072.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126072.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126072.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,171 @@ +Description: Close a live stream when its buffer is already closed. +Author: Jeremy Daer +Origin: upstream, https://github.com/rails/rails/commit/27ad18ed5900dee28ba20e9c6fc718ff751fa215 +Bug: https://github.com/rails/rails/security/advisories/GHSA-rwvh-fw6r-pwvp +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/actionpack/lib/action_controller/metal/live.rb ++++ b/actionpack/lib/action_controller/metal/live.rb +@@ -183,7 +183,11 @@ module ActionController + @response.delete_header "Content-Length" + end + +- super ++ begin ++ super ++ rescue ClosedQueueError ++ raise IOError, "closed stream" if connected? ++ end + + unless connected? + @buf.clear +@@ -201,14 +205,14 @@ module ActionController + write string.end_with?("\n") ? string : "#{string}\n" + end + +- # Write a 'close' event to the buffer; the producer/writing thread uses this to +- # notify us that it's finished supplying content. ++ # Close the buffer; the producer/writing thread uses this to notify us that ++ # it's finished supplying content. + # + # See also #abort. + def close + synchronize do + super +- @buf.push nil ++ @buf.close + @cv.broadcast + end + end +@@ -220,7 +224,9 @@ module ActionController + def abort + synchronize do + @aborted = true ++ @buf.close + @buf.clear ++ @cv.broadcast + end + end + +--- a/actionpack/test/controller/live_stream_test.rb ++++ b/actionpack/test/controller/live_stream_test.rb +@@ -1,6 +1,7 @@ + # frozen_string_literal: true + + require "abstract_unit" ++require "active_support/core_ext/object/with" + require "timeout" + require "concurrent/atomic/count_down_latch" + require "zeitwerk" +@@ -627,6 +628,108 @@ module ActionController + buf = ActionController::Live::Buffer.new nil + assert buf.call_on_error + end ++ ++ def test_abort_terminates_a_reader_blocked_on_the_buffer ++ response = ActionController::Live::Response.new ++ response.request = ActionDispatch::Request.empty ++ buf = response.stream ++ ++ received = [] ++ reader = Thread.new { response.each { |chunk| received << chunk } } ++ ++ buf.write "hello" ++ Timeout.timeout(5) do ++ Thread.pass until received.any? # reader drained the chunk... ++ Thread.pass until reader.status == "sleep" # ...and is blocked on the queue ++ end ++ ++ buf.abort ++ ++ assert reader.join(5), "#abort did not release a reader blocked in each_chunk" ++ assert_equal ["hello"], received ++ ensure ++ reader&.kill ++ end ++ ++ def test_close_then_abort_still_terminates_the_reader ++ response = ActionController::Live::Response.new ++ response.request = ActionDispatch::Request.empty ++ buf = response.stream ++ ++ buf.write "final" ++ buf.close # closes the queue after its final chunk ++ buf.abort # clears that pending chunk without reopening the queue ++ ++ reader = Thread.new { response.each { } } ++ ++ assert reader.join(5), "#abort after #close left the reader blocked in each_chunk" ++ ensure ++ reader&.kill ++ end ++ ++ def test_close_with_a_full_buffer_does_not_wait_for_a_reader ++ ActionController::Live::Buffer.with(queue_size: 1) do ++ response = ActionController::Live::Response.new ++ response.request = ActionDispatch::Request.empty ++ buf = response.stream ++ buf.write "final" ++ ++ closer = Thread.new { buf.close } ++ ++ assert closer.join(1), "#close waited for a reader to drain the full buffer" ++ chunks = [] ++ response.each { |chunk| chunks << chunk } ++ assert_equal ["final"], chunks ++ ensure ++ closer&.kill ++ end ++ end ++ ++ def test_close_and_abort_finish_when_a_single_slot_buffer_is_full ++ ActionController::Live::Buffer.with(queue_size: 1) do ++ response = ActionController::Live::Response.new ++ response.request = ActionDispatch::Request.empty ++ buf = response.stream ++ buf.write "queued" ++ ++ start = Concurrent::CountDownLatch.new ++ closer = Thread.new { start.wait; buf.close } ++ aborter = Thread.new { start.wait; buf.abort } ++ start.count_down ++ ++ assert closer.join(1), "#close remained blocked when raced with #abort" ++ assert aborter.join(1), "#abort remained blocked when raced with #close" ++ ++ chunks = [] ++ reader = Thread.new { response.each { |chunk| chunks << chunk } } ++ assert reader.join(1), "the aborted buffer did not terminate its reader" ++ assert_empty chunks ++ ensure ++ closer&.kill ++ aborter&.kill ++ reader&.kill ++ end ++ end ++ ++ def test_write_after_abort_does_not_block_on_the_terminator ++ ActionController::Live::Buffer.with(queue_size: 1) do ++ response = ActionController::Live::Response.new ++ response.request = ActionDispatch::Request.empty ++ buf = response.stream ++ buf.abort ++ ++ writer = Thread.new do ++ buf.write "late" ++ rescue => error ++ error ++ end ++ ++ assert writer.join(1), "#write blocked after the buffer was aborted" ++ assert_instance_of ActionController::Live::ClientDisconnected, writer.value ++ ensure ++ writer&.kill ++ end ++ end + end + end + diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126073.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126073.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126073.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126073.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,161 @@ +Description: Vary on every header that content negotiation reads. + Also vary XHR responses without `Accept` on `Content-Type`, and append + these fields to an existing `Vary` value unless it is `*`. +Author: Jeremy Daer +Origin: upstream, https://github.com/rails/rails/commit/b58c107abe9c1f10c1d6a4941402c60e4dc4742c +Bug: https://github.com/rails/rails/security/advisories/GHSA-r9jg-fmfx-2gv6 +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/actionpack/lib/action_controller/metal/rendering.rb ++++ b/actionpack/lib/action_controller/metal/rendering.rb +@@ -218,8 +218,15 @@ module ActionController + end + + def _set_vary_header +- if response.headers["Vary"].blank? && request.should_apply_vary_header? +- response.headers["Vary"] = "Accept" ++ if request.should_apply_vary_header? ++ vary_headers = response.headers["Vary"].to_s.split(",").map(&:strip).reject(&:blank?) ++ ++ unless vary_headers.include?("*") ++ request.vary_headers.each do |header| ++ vary_headers << header unless vary_headers.any? { |existing| existing.casecmp?(header) } ++ end ++ response.headers["Vary"] = vary_headers.join(", ") ++ end + end + end + +--- a/actionpack/lib/action_dispatch/http/mime_negotiation.rb ++++ b/actionpack/lib/action_dispatch/http/mime_negotiation.rb +@@ -153,7 +153,17 @@ module ActionDispatch + end + + def should_apply_vary_header? +- !params_readable? && use_accept_header && valid_accept_header ++ !params_readable? ++ end ++ ++ def vary_headers # :nodoc: ++ if use_accept_header ++ headers = ["Accept", "X-Requested-With"] ++ headers.insert(1, "Content-Type") if xhr? && accept.blank? ++ headers ++ else ++ ["X-Requested-With"] ++ end + end + + private +--- a/actionpack/test/controller/integration_test.rb ++++ b/actionpack/test/controller/integration_test.rb +@@ -212,13 +212,9 @@ class IntegrationProcessTest < ActionDis + end + end + +- def get_with_vary_set_x_requested_with +- respond_to do |format| +- format.json do +- response.headers["Vary"] = "X-Requested-With" +- render json: "JSON OK", status: 200 +- end +- end ++ def get_with_vary ++ response.headers["Vary"] = params[:vary] ++ get + end + + def get_with_params +@@ -602,7 +598,35 @@ class IntegrationProcessTest < ActionDis + def test_setting_vary_header_when_request_is_xhr_with_accept_header + with_test_route_set do + get "/get", headers: { "Accept" => "application/json" }, xhr: true +- assert_equal "Accept", response.headers["Vary"] ++ assert_equal "Accept, X-Requested-With", response.headers["Vary"] ++ end ++ end ++ ++ def test_setting_vary_header_when_request_has_no_accept_header ++ with_test_route_set do ++ get "/get", headers: { "Accept" => nil } ++ assert_equal "text/html", response.media_type ++ assert_equal "Accept, X-Requested-With", response.headers["Vary"] ++ ++ get "/get", headers: { "Accept" => nil, "X-Requested-With" => "XMLHttpRequest" } ++ assert_equal "text/javascript", response.media_type ++ assert_equal "Accept, Content-Type, X-Requested-With", response.headers["Vary"] ++ end ++ end ++ ++ def test_setting_vary_header_when_xhr_format_depends_on_content_type ++ with_test_route_set do ++ get "/get", headers: { "Accept" => nil, "Content-Type" => "application/xml", "X-Requested-With" => "XMLHttpRequest" } ++ assert_equal "application/xml", response.media_type ++ assert_equal "Accept, Content-Type, X-Requested-With", response.headers["Vary"] ++ end ++ end ++ ++ def test_setting_vary_header_when_request_has_a_browser_like_accept_header ++ with_test_route_set do ++ get "/get", headers: { "Accept" => "application/json, */*" } ++ assert_equal "text/html", response.media_type ++ assert_equal "Accept, X-Requested-With", response.headers["Vary"] + end + end + +@@ -613,23 +637,42 @@ class IntegrationProcessTest < ActionDis + end + end + +- def test_not_setting_vary_header_when_it_has_already_been_set ++ def test_appending_to_vary_header_when_it_has_already_been_set + with_test_route_set do +- get "/get_with_vary_set_x_requested_with", headers: { "Accept" => "application/json" }, xhr: true +- assert_equal "X-Requested-With", response.headers["Vary"] ++ get "/get_with_vary", params: { vary: "Accept-Language" }, headers: { "Accept" => "application/json" } ++ assert_equal "Accept-Language, Accept, X-Requested-With", response.headers["Vary"] + end + end + +- def test_not_setting_vary_header_when_ignore_accept_header_is_set +- original_ignore_accept_header = ActionDispatch::Request.ignore_accept_header +- ActionDispatch::Request.ignore_accept_header = true ++ def test_not_appending_fields_already_in_vary_header_case_insensitively ++ with_test_route_set do ++ existing = "accept, CONTENT-type, x-requested-with" ++ get "/get_with_vary", params: { vary: existing }, headers: { "Accept" => nil, "Content-Type" => "application/xml", "X-Requested-With" => "XMLHttpRequest" } ++ assert_equal "application/xml", response.media_type ++ assert_equal existing, response.headers["Vary"] ++ end ++ end + ++ def test_not_appending_to_wildcard_vary_header + with_test_route_set do +- get "/get", headers: { "Accept" => "application/json" }, xhr: true +- assert_nil response.headers["Vary"] ++ get "/get_with_vary", params: { vary: "*" }, headers: { "Accept" => nil, "Content-Type" => "application/xml", "X-Requested-With" => "XMLHttpRequest" } ++ assert_equal "application/xml", response.media_type ++ assert_equal "*", response.headers["Vary"] ++ end ++ end ++ ++ def test_not_setting_accept_in_vary_header_when_ignore_accept_header_is_set ++ ActionDispatch::Request.with(ignore_accept_header: true) do ++ with_test_route_set do ++ get "/get", headers: { "Accept" => "application/json" } ++ assert_equal "text/html", response.media_type ++ assert_equal "X-Requested-With", response.headers["Vary"] ++ ++ get "/get", headers: { "Accept" => "application/json" }, xhr: true ++ assert_equal "text/javascript", response.media_type ++ assert_equal "X-Requested-With", response.headers["Vary"] ++ end + end +- ensure +- ActionDispatch::Request.ignore_accept_header = original_ignore_accept_header + end + + private diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126074.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126074.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126074.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126074.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,126 @@ +Description: Take a filename base and extension from the sanitized name. + Backported to 7.2.2.2. The unsafe-character set stays the set already + in this tree, with NUL added. String#strip still drops a leading or + trailing NUL, so a filename that is only a NUL stays empty. +Author: Jeremy Daer +Origin: backport, https://github.com/rails/rails/commit/9b0d4bef2211a2c08cab2e0ea17fa1d0efd5d47a +Bug: https://github.com/rails/rails/security/advisories/GHSA-p2pm-g2h6-7j5j +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/activestorage/app/models/active_storage/filename.rb ++++ b/activestorage/app/models/active_storage/filename.rb +@@ -25,7 +25,7 @@ class ActiveStorage::Filename + # ActiveStorage::Filename.new("racecar").base # => "racecar" + # ActiveStorage::Filename.new(".gitignore").base # => ".gitignore" + def base +- File.basename @filename, extension_with_delimiter ++ File.basename sanitized, extension_with_delimiter + end + + # Returns the extension of the filename (i.e. the substring following the last dot, excluding a dot at the +@@ -35,7 +35,7 @@ class ActiveStorage::Filename + # ActiveStorage::Filename.new("racecar").extension_with_delimiter # => "" + # ActiveStorage::Filename.new(".gitignore").extension_with_delimiter # => "" + def extension_with_delimiter +- File.extname @filename ++ File.extname sanitized + end + + # Returns the extension of the filename (i.e. the substring following the last dot, excluding a dot at +@@ -55,9 +55,10 @@ class ActiveStorage::Filename + # ActiveStorage::Filename.new("foo:bar.jpg").sanitized # => "foo-bar.jpg" + # ActiveStorage::Filename.new("foo/bar.jpg").sanitized # => "foo-bar.jpg" + # +- # Characters considered unsafe for storage (e.g. \, $, and the RTL override character) are replaced with a dash. ++ # Characters considered unsafe for storage (e.g. \, $, the null character, and the RTL override character) are ++ # replaced with a dash. + def sanitized +- @filename.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "�").strip.tr("\u{202E}%$|:;/\t\r\n\\", "-") ++ @filename.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "�").strip.tr("\u{202E}\u{0000}%$|:;/\t\r\n\\", "-") + end + + # Returns the sanitized version of the filename. +--- a/activestorage/test/controllers/direct_uploads_controller_test.rb ++++ b/activestorage/test/controllers/direct_uploads_controller_test.rb +@@ -168,6 +168,23 @@ class ActiveStorage::DiskDirectUploadsCo + end + end + ++ test "creating a direct upload with a null byte in its filename" do ++ checksum = OpenSSL::Digest::MD5.base64digest("Hello") ++ ++ post rails_direct_uploads_url, params: { blob: { ++ filename: "holiday\0.jpg", byte_size: 5, checksum: checksum, content_type: "image/jpeg" } }, as: :json ++ ++ assert_response :success ++ ++ details = response.parsed_body ++ blob = ActiveStorage::Blob.find(details["id"]) ++ ++ assert_equal "holiday\0.jpg", blob[:filename] ++ assert_equal "holiday-.jpg", details["filename"] ++ assert_equal "jpg", blob.filename.extension ++ assert_nothing_raised { blob.variant(resize_to_limit: [100, 100]) } ++ end ++ + test "creating new direct upload does not include root in json" do + checksum = OpenSSL::Digest::MD5.base64digest("Hello") + metadata = { +--- a/activestorage/test/models/filename_test.rb ++++ b/activestorage/test/models/filename_test.rb +@@ -21,8 +21,32 @@ class ActiveStorage::FilenameTest < Acti + assert_equal "", ActiveStorage::Filename.new("racecar").extension_without_delimiter + end + ++ test "base and extension use the sanitized filename" do ++ filename = ActiveStorage::Filename.new("race\0car.j\0pg") ++ ++ assert_equal "race-car", filename.base ++ assert_equal ".j-pg", filename.extension_with_delimiter ++ assert_equal "j-pg", filename.extension ++ end ++ ++ test "base and extension transcode invalid UTF-8" do ++ filename = ActiveStorage::Filename.new((+"caf\xFF.photo\xFF").force_encoding(Encoding::UTF_8)) ++ ++ assert_equal "caf�", filename.base ++ assert_equal ".photo�", filename.extension_with_delimiter ++ assert_equal "photo�", filename.extension ++ end ++ ++ test "base and extension preserve Unicode" do ++ filename = ActiveStorage::Filename.new("café.写真") ++ ++ assert_equal "café", filename.base ++ assert_equal ".写真", filename.extension_with_delimiter ++ assert_equal "写真", filename.extension ++ end ++ + test "sanitize" do +- "%$|:;/\t\r\n\\".each_char do |character| ++ "%$|:;/\t\r\n\\\u{0000}".each_char do |character| + filename = ActiveStorage::Filename.new("foo#{character}bar.pdf") + assert_equal "foo-bar.pdf", filename.sanitized + assert_equal "foo-bar.pdf", filename.to_s +--- a/activestorage/test/models/variant_test.rb ++++ b/activestorage/test/models/variant_test.rb +@@ -31,6 +31,16 @@ class ActiveStorage::VariantTest < Activ + assert_equal 67, image.height + end + ++ test "resized variation of JPEG blob with a null byte in its filename" do ++ blob = create_file_blob(filename: "race\0car.jpg", fixture: "racecar.jpg") ++ variant = blob.variant(resize_to_limit: [100, 100]).processed ++ assert_match(/race-car\.jpg/, variant.url) ++ ++ image = read_image(variant) ++ assert_equal 100, image.width ++ assert_equal 67, image.height ++ end ++ + test "resized and monochrome variation of JPEG blob" do + blob = create_file_blob(filename: "racecar.jpg") + variant = blob.variant(resize_to_limit: [100, 100], colourspace: "b-w").processed diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126076.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126076.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126076.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126076.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,249 @@ +Description: Do not write back a cache session deleted mid-request. + A request that loaded a session from `CacheStore` wrote it back when it + finished, even if another request had deleted it in the meantime, as + `reset_session` does on logout. The deleted session came back under its + old ID. + . + Skip the write when the cache entry of the session this request loaded + is gone. +Author: Mike Dalessio +Origin: upstream, https://github.com/rails/rails/commit/5bb5ec66ed8faaf590ffe1222d7a5eb6e9d050f5 +Bug: https://github.com/rails/rails/security/advisories/GHSA-2586-8ghr-69fj +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/actionpack/lib/action_dispatch/middleware/session/cache_store.rb ++++ b/actionpack/lib/action_dispatch/middleware/session/cache_store.rb +@@ -20,6 +20,8 @@ module ActionDispatch + # is used. + # + class CacheStore < AbstractSecureStore ++ LOADED_SESSION_ID = "action_dispatch.session.cache_store.loaded_session_id" # :nodoc: ++ + def initialize(app, options = {}) + @cache = options[:cache] || Rails.cache + options[:expire_after] ||= @cache.options[:expires_in] +@@ -27,17 +29,20 @@ module ActionDispatch + end + + # Get a session from the cache. +- def find_session(env, sid) +- unless sid && (session = get_session_with_fallback(sid)) ++ def find_session(req, sid) ++ if sid && (session = get_session_with_fallback(sid)) ++ req.set_header(LOADED_SESSION_ID, sid.private_id) ++ else + sid, session = generate_sid, {} + end + [sid, session] + end + + # Set a session in the cache. +- def write_session(env, sid, session, options) ++ def write_session(req, sid, session, options) + key = cache_key(sid.private_id) + if session ++ return false if destroyed_since_loaded?(req, sid) + @cache.write(key, session, expires_in: options[:expire_after]) + else + @cache.delete(key) +@@ -61,6 +66,24 @@ module ActionDispatch + def get_session_with_fallback(sid) + @cache.read(cache_key(sid.private_id)) || @cache.read(cache_key(sid.public_id)) + end ++ ++ # Writing back a session that another request deleted, such as on logout, ++ # would restore it. ++ def destroyed_since_loaded?(req, sid) ++ req.get_header(LOADED_SESSION_ID) == sid.private_id && ++ !exist_in_backend?(cache_key(sid.private_id)) && ++ !exist_in_backend?(cache_key(sid.public_id)) ++ end ++ ++ # The request-local cache still holds the entry this request loaded, so ++ # a lookup through it cannot see a delete made by another request. ++ def exist_in_backend?(key) ++ if @cache.respond_to?(:with_local_cache) ++ @cache.with_local_cache { @cache.exist?(key) } ++ else ++ @cache.exist?(key) ++ end ++ end + end + end + end +--- a/actionpack/test/dispatch/session/cache_store_test.rb ++++ b/actionpack/test/dispatch/session/cache_store_test.rb +@@ -3,6 +3,40 @@ + require "abstract_unit" + + class CacheStoreTest < ActionDispatch::IntegrationTest ++ singleton_class.attr_accessor :app_under_test ++ ++ class LocallyCachedStore < ActiveSupport::Cache::Store ++ prepend ActiveSupport::Cache::Strategy::LocalCache ++ ++ def initialize ++ super ++ @data = {} ++ end ++ ++ private ++ def read_entry(key, **options) ++ deserialize_entry(read_serialized_entry(key, **options), **options) ++ end ++ ++ def read_serialized_entry(key, **) ++ @data[key] ++ end ++ ++ def write_entry(key, entry, **options) ++ @data[key] = serialize_entry(entry, **options) ++ true ++ end ++ ++ def delete_entry(key, **) ++ !!@data.delete(key) ++ end ++ end ++ ++ def self.log_out(request) ++ cookie = request.get_header("HTTP_COOKIE") ++ Thread.new { Rack::MockRequest.new(app_under_test).get("/call_reset_session", "HTTP_COOKIE" => cookie) }.join ++ end ++ + class TestController < ActionController::Base + def no_session_access + head :ok +@@ -26,6 +60,23 @@ class CacheStoreTest < ActionDispatch::I + render plain: "#{request.session.id.public_id}" + end + ++ def read_session_while_another_request_logs_out ++ session[:foo] ++ CacheStoreTest.log_out(request) ++ head :ok ++ end ++ ++ def write_session_while_another_request_logs_out ++ session[:foo] ++ CacheStoreTest.log_out(request) ++ session[:foo] = "baz" ++ head :ok ++ end ++ ++ def get_reset_session_value ++ render plain: "bar: #{session[:bar].inspect}" ++ end ++ + def call_reset_session + session[:bar] + reset_session +@@ -73,6 +124,67 @@ class CacheStoreTest < ActionDispatch::I + end + end + ++ def test_session_logged_out_during_a_request_stays_logged_out ++ @cache = LocallyCachedStore.new ++ ++ with_test_route_set do ++ get "/set_session_value" ++ session_cookie = cookies.get_cookie("_session_id") ++ ++ get "/read_session_while_another_request_logs_out" ++ assert_response :success ++ ++ cookies << session_cookie ++ ++ get "/get_session_value" ++ assert_equal "foo: nil", response.body ++ end ++ end ++ ++ def test_session_logged_out_during_a_writing_request_stays_logged_out ++ @cache = LocallyCachedStore.new ++ ++ with_test_route_set do ++ get "/set_session_value" ++ session_cookie = cookies.get_cookie("_session_id") ++ ++ get "/write_session_while_another_request_logs_out" ++ assert_response :success ++ ++ cookies << session_cookie ++ ++ get "/get_session_value" ++ assert_equal "foo: nil", response.body ++ end ++ end ++ ++ def test_session_logged_out_during_a_request_does_not_resend_its_cookie ++ @cache = LocallyCachedStore.new ++ cache_store_options(expire_after: 1.hour) ++ ++ with_test_route_set do ++ get "/set_session_value" ++ ++ get "/read_session_while_another_request_logs_out" ++ assert_response :success ++ assert_nil headers["Set-Cookie"] ++ end ++ end ++ ++ def test_session_reset_by_the_request_is_saved_under_the_new_id ++ with_test_route_set do ++ get "/set_session_value" ++ old_session_id = cookies["_session_id"] ++ ++ get "/call_reset_session" ++ assert_response :success ++ assert_not_equal old_session_id, cookies["_session_id"] ++ ++ get "/get_reset_session_value" ++ assert_equal 'bar: "baz"', response.body ++ end ++ end ++ + def test_getting_from_nonexistent_session + with_test_route_set do + get "/get_session_value" +@@ -183,6 +295,18 @@ class CacheStoreTest < ActionDispatch::I + end + end + ++ def test_session_read_by_legacy_id_is_saved_under_private_id ++ with_test_route_set do ++ get "/set_session_value" ++ sid = Rack::Session::SessionId.new(cookies["_session_id"]) ++ @cache.write("_session_id:#{sid.public_id}", @cache.read("_session_id:#{sid.private_id}")) ++ @cache.delete("_session_id:#{sid.private_id}") ++ ++ get "/get_session_value" ++ assert_equal({ "foo" => "bar" }, @cache.read("_session_id:#{sid.private_id}")) ++ end ++ end ++ + def test_drop_session_in_the_legacy_id_as_well + with_test_route_set do + get "/set_session_value" +@@ -204,10 +328,15 @@ class CacheStoreTest < ActionDispatch::I + end + + private ++ def cache_store_options(options = {}) ++ @cache_store_options ||= options ++ end ++ + def app +- @app ||= self.class.build_app do |middleware| +- @cache = ActiveSupport::Cache::MemoryStore.new +- middleware.use ActionDispatch::Session::CacheStore, key: "_session_id", cache: @cache ++ @app ||= CacheStoreTest.app_under_test = self.class.build_app do |middleware| ++ @cache ||= ActiveSupport::Cache::MemoryStore.new ++ middleware.use @cache.middleware if @cache.respond_to?(:middleware) ++ middleware.use ActionDispatch::Session::CacheStore, key: "_session_id", cache: @cache, **cache_store_options + middleware.delete ActionDispatch::ShowExceptions + end + end diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126077.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126077.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126077.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126077.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,240 @@ +Description: Keep a proxy from resending an upgraded session cookie. + Reading a signed or encrypted cookie that needed an upgrade, from a + rotated secret or a `:hybrid` serializer migration, wrote it back to the + response even when `session_options[:skip]` was set. A response that + skips the session, such as the Active Storage proxy's public, cacheable + response, could then carry the session cookie in `Set-Cookie`. + . + Track upgrade writes on the cookie jar and leave them out of a response + that skips the session. The check happens when the jar is written, so + it holds whether the cookie was read before or after `skip` was set. +Author: Mike Dalessio +Origin: upstream, https://github.com/rails/rails/commit/0e6cf8faa89caf4c64311d35ca2bc88c1458d4e3 +Bug: https://github.com/rails/rails/security/advisories/GHSA-x6mj-8jx9-qhqv +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/actionpack/lib/action_dispatch/middleware/cookies.rb ++++ b/actionpack/lib/action_dispatch/middleware/cookies.rb +@@ -322,6 +322,7 @@ module ActionDispatch + def initialize(request) + @set_cookies = {} + @delete_cookies = {} ++ @upgraded_cookies = Set.new + @request = request + @cookies = {} + @committed = false +@@ -384,6 +385,7 @@ module ActionDispatch + end + + handle_options(options) ++ @upgraded_cookies.delete(name.to_s) + + if @cookies[name.to_s] != value || options[:expires] + @cookies[name.to_s] = value +@@ -424,8 +426,14 @@ module ActionDispatch + @cookies.each_key { |k| delete(k, options) } + end + ++ def upgraded(name) ++ @upgraded_cookies << name.to_s ++ end ++ + def write(response) + @set_cookies.each do |name, value| ++ next if @upgraded_cookies.include?(name) && request.session_options[:skip] ++ + if write_cookie?(value) + response.set_cookie(name, value) + end +@@ -531,6 +539,10 @@ module ActionDispatch + @parent_jar[name] = options + end + ++ def upgraded(name) ++ @parent_jar.upgraded(name) ++ end ++ + protected + def request; @parent_jar.request; end + +@@ -597,7 +609,10 @@ module ActionDispatch + return + end + +- self[name] = { value: value } if force_reserialize || reserialize?(dumped) ++ if force_reserialize || reserialize?(dumped) ++ self[name] = { value: value } ++ upgraded(name) ++ end + + value + end +--- a/actionpack/test/dispatch/cookies_test.rb ++++ b/actionpack/test/dispatch/cookies_test.rb +@@ -208,6 +208,37 @@ class CookiesTest < ActionController::Te + head :ok + end + ++ def get_signed_cookie_with_session_skipped ++ request.session_options[:skip] = true ++ cookies.signed[:user_id] ++ head :ok ++ end ++ ++ def get_encrypted_cookie_with_session_skipped ++ request.session_options[:skip] = true ++ cookies.encrypted[:foo] ++ head :ok ++ end ++ ++ def get_signed_cookie_before_skipping_session ++ cookies.signed[:user_id] ++ request.session_options[:skip] = true ++ head :ok ++ end ++ ++ def reset_signed_cookie_with_session_skipped ++ request.session_options[:skip] = true ++ cookies.signed[:user_id] ++ cookies.signed[:user_id] = 46 ++ head :ok ++ end ++ ++ def set_signed_cookie_with_session_skipped ++ request.session_options[:skip] = true ++ cookies.signed[:user_id] = 45 ++ head :ok ++ end ++ + def set_invalid_encrypted_cookie + cookies[:invalid_cookie] = "invalid--9170e00a57cfc27083363b5c75b835e477bd90cf" + head :ok +@@ -1188,6 +1219,80 @@ class CookiesTest < ActionController::Te + assert_equal 45, encryptor.decrypt_and_verify(@response.cookies["foo"]) + end + ++ def test_signed_cookie_rotating_secret_is_not_rewritten_when_session_is_skipped ++ secret = "b3c631c314c0bbca50c1b2843150fe33" ++ ++ @request.env["action_dispatch.signed_cookie_digest"] = "SHA256" ++ @request.env["action_dispatch.cookies_rotations"].rotate :signed, secret, digest: "SHA1" ++ ++ old_message = ActiveSupport::MessageVerifier.new(secret, digest: "SHA1", serializer: Marshal).generate(45) ++ @request.headers["Cookie"] = "user_id=#{old_message}" ++ ++ get :get_signed_cookie_with_session_skipped ++ assert_equal 45, @controller.send(:cookies).signed[:user_id] ++ assert_nil @response.headers["Set-Cookie"] ++ end ++ ++ def test_signed_cookie_read_before_the_session_is_skipped_is_not_rewritten ++ secret = "b3c631c314c0bbca50c1b2843150fe33" ++ ++ @request.env["action_dispatch.signed_cookie_digest"] = "SHA256" ++ @request.env["action_dispatch.cookies_rotations"].rotate :signed, secret, digest: "SHA1" ++ ++ old_message = ActiveSupport::MessageVerifier.new(secret, digest: "SHA1", serializer: Marshal).generate(45) ++ @request.headers["Cookie"] = "user_id=#{old_message}" ++ ++ get :get_signed_cookie_before_skipping_session ++ assert_nil @response.headers["Set-Cookie"] ++ end ++ ++ def test_rotated_signed_cookie_set_after_reading_is_written_when_session_is_skipped ++ secret = "b3c631c314c0bbca50c1b2843150fe33" ++ ++ @request.env["action_dispatch.signed_cookie_digest"] = "SHA256" ++ @request.env["action_dispatch.cookies_rotations"].rotate :signed, secret, digest: "SHA1" ++ ++ old_message = ActiveSupport::MessageVerifier.new(secret, digest: "SHA1", serializer: Marshal).generate(45) ++ @request.headers["Cookie"] = "user_id=#{old_message}" ++ ++ get :reset_signed_cookie_with_session_skipped ++ assert_equal 46, @controller.send(:cookies).signed[:user_id] ++ assert_not_nil @response.cookies["user_id"] ++ end ++ ++ def test_encrypted_cookie_rotating_secret_is_not_rewritten_when_session_is_skipped ++ secret = "b3c631c314c0bbca50c1b2843150fe33" ++ ++ @request.env["action_dispatch.encrypted_cookie_cipher"] = "aes-256-gcm" ++ @request.env["action_dispatch.cookies_rotations"].rotate :encrypted, secret, digest: "SHA1" ++ ++ old_message = ActiveSupport::MessageEncryptor.new(secret, cipher: "aes-256-gcm", serializer: Marshal).encrypt_and_sign(45) ++ @request.headers["Cookie"] = "foo=#{::Rack::Utils.escape old_message}" ++ ++ get :get_encrypted_cookie_with_session_skipped ++ assert_equal 45, @controller.send(:cookies).encrypted[:foo] ++ assert_nil @response.headers["Set-Cookie"] ++ end ++ ++ def test_encrypted_cookie_using_hybrid_serializer_is_not_rewritten_when_session_is_skipped ++ @request.env["action_dispatch.cookies_serializer"] = :hybrid ++ ++ secret = @request.env["action_dispatch.key_generator"].generate_key(@request.env["action_dispatch.authenticated_encrypted_cookie_salt"], 32) ++ ++ marshal_value = ActiveSupport::MessageEncryptor.new(secret, cipher: "aes-256-gcm", serializer: Marshal).encrypt_and_sign("bar") ++ @request.headers["Cookie"] = "foo=#{::Rack::Utils.escape marshal_value}" ++ ++ get :get_encrypted_cookie_with_session_skipped ++ assert_equal "bar", @controller.send(:cookies).encrypted[:foo] ++ assert_nil @response.headers["Set-Cookie"] ++ end ++ ++ def test_signed_cookie_is_set_when_session_is_skipped ++ get :set_signed_cookie_with_session_skipped ++ assert_equal 45, @controller.send(:cookies).signed[:user_id] ++ assert_not_nil @response.cookies["user_id"] ++ end ++ + def test_cookie_with_hash_value_not_modified_by_rotation + @request.env["action_dispatch.signed_cookie_digest"] = "SHA256" + @request.env["action_dispatch.cookies_rotations"].rotate :signed, digest: "SHA1" +--- a/activestorage/test/controllers/blobs/proxy_controller_test.rb ++++ b/activestorage/test/controllers/blobs/proxy_controller_test.rb +@@ -125,6 +125,26 @@ class ActiveStorage::Blobs::ProxyControl + assert_instance_of ActionController::Live::Response, ActiveStorage::Blobs::ProxyController.make_response!(request) + end + ++ test "a session cookie under a rotated secret is not rewritten" do ++ old_key_generator = ActiveSupport::KeyGenerator.new("old secret key base", iterations: 1000) ++ old_secret = old_key_generator.generate_key("authenticated encrypted cookie", 32) ++ session_key = Rails.application.config.session_options[:key] ++ ++ old_cookie_jar = ActionDispatch::Request.new(Rails.application.env_config.merge("action_dispatch.key_generator" => old_key_generator)).cookie_jar ++ old_cookie_jar.encrypted[session_key] = { value: { "session_id" => SecureRandom.hex(16) } } ++ ++ rotations = ActiveSupport::Messages::RotationConfiguration.new ++ rotations.rotate :encrypted, old_secret ++ ++ with_env_config("action_dispatch.cookies_rotations" => rotations) do ++ get rails_storage_proxy_url(create_file_blob(filename: "racecar.jpg")), ++ headers: { "Cookie" => "#{session_key}=#{Rack::Utils.escape(old_cookie_jar[session_key])}" } ++ end ++ ++ assert_response :success ++ assert_nil response.headers["Set-Cookie"] ++ end ++ + private + def with_streaming_chunk_max_size(size) + old_size = ActiveStorage.streaming_chunk_max_size +@@ -133,6 +153,15 @@ class ActiveStorage::Blobs::ProxyControl + ensure + ActiveStorage.streaming_chunk_max_size = old_size + end ++ ++ def with_env_config(overrides) ++ env_config = Rails.application.env_config ++ original = env_config.slice(*overrides.keys) ++ env_config.merge!(overrides) ++ yield ++ ensure ++ env_config.except!(*overrides.keys).merge!(original) ++ end + end + + class ActiveStorage::Blobs::ExpiringProxyControllerTest < ActionDispatch::IntegrationTest diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126078.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126078.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126078.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126078.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,149 @@ +Description: Escape each match substituted into highlight's :highlighter. + `highlight` copied each match into the `:highlighter` unescaped and + returned the result `html_safe`, so with `\1` inside a quoted attribute, + as in the documented `'\1'`, a match + containing a quote added attributes such as `onfocus`. Escaping the text + first does not help, because `sanitize` turns `"` back into `"`. + . + Expand `\0` to `\9` directly and pass each group through + `ERB::Util.html_escape_once`. Never let a match start on the `>` that + closes the preceding tag, which the escaped highlighter would otherwise + replace with `>`, making the following text attributes of that tag. + Use a `title` attribute in the documented example, since a URL needs + escaping of its own. +Author: Mike Dalessio +Author: Jeremy Daer +Origin: upstream, https://github.com/rails/rails/commit/c796f6198837479ada13290eb8fa767b5219a58a +Bug: https://github.com/rails/rails/security/advisories/GHSA-v6rj-xm57-3p59 +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/actionview/lib/action_view/helpers/text_helper.rb ++++ b/actionview/lib/action_view/helpers/text_helper.rb +@@ -143,8 +143,15 @@ module ActionView + # + # [+:highlighter+] + # The highlighter string. Uses \1 as the placeholder for a +- # phrase, similar to +String#sub+. Defaults to "\1". +- # This option is ignored if a block is specified. ++ # phrase. Defaults to "\1". The numbered placeholders ++ # \0 to \9 are expanded; other +String#sub+ replacement escapes ++ # are not. The phrase is HTML escaped, quotes included. This option ++ # is ignored if a block is specified. ++ # ++ # WARNING: Put a placeholder only in element content or inside a ++ # quoted attribute value. HTML escaping does not make the phrase safe ++ # in an unquoted attribute value, in a URL, JavaScript or CSS ++ # context, or in an attribute whose value is HTML, such as +srcdoc+. + # + # [+:sanitize+] + # Whether to sanitize +text+ before highlighting. Defaults to true. +@@ -163,8 +170,8 @@ module ActionView + # highlight('You searched for: rails', ['for', 'rails'], highlighter: '\1') + # # => "You searched for: rails" + # +- # highlight('You searched for: rails', 'rails', highlighter: '\1') +- # # => "You searched for: rails" ++ # highlight('You searched for: rails', 'rails', highlighter: '\1') ++ # # => "You searched for: rails" + # + # highlight('You searched for: rails', 'rails') { |match| link_to(search_path(q: match)) } + # # => "You searched for: rails" +@@ -179,14 +186,23 @@ module ActionView + else + patterns = Array(phrases).map { |phrase| Regexp === phrase ? phrase : Regexp.escape(phrase) } + pattern = /(#{patterns.join("|")})/i ++ # The text after a tag begins with the ">" that closes it. Leave it ++ # in the segment so phrases can see it as context, but keep it out ++ # of the match so the highlighter can't take the place of the ">". ++ pattern_after_tag = /(?!\A)#{pattern}/ + highlighter = options.fetch(:highlighter, '\1') unless block + +- text.scan(/<[^>]*|[^<]+/).each do |segment| ++ text.scan(/<[^>]*|[^<]+/).each_with_index do |segment, index| + if !segment.start_with?("<") ++ segment_pattern = index > 0 ? pattern_after_tag : pattern ++ + if block +- segment.gsub!(pattern, &block) ++ segment.gsub!(segment_pattern, &block) + else +- segment.gsub!(pattern, highlighter) ++ segment.gsub!(segment_pattern) do ++ match = Regexp.last_match ++ highlighter.gsub(/\\(\d)/) { ERB::Util.html_escape_once(match[$1.to_i]) } ++ end + end + end + end.join +--- a/actionview/test/template/text_helper_test.rb ++++ b/actionview/test/template/text_helper_test.rb +@@ -275,6 +275,66 @@ class TextHelperTest < ActionView::TestC + ) + end + ++ def test_highlight_escapes_quotes_in_the_highlighted_phrase ++ assert_equal( ++ "rails" onclick="alert(1)", ++ highlight("rails\" onclick=\"alert(1)", "rails\" onclick=\"alert(1)", highlighter: '\1') ++ ) ++ assert_equal( ++ "rails' onclick='alert(1)", ++ highlight("rails' onclick='alert(1)", /rails.*/, highlighter: "\\1") ++ ) ++ assert_equal( ++ "rails" onclick="alert(1)", ++ highlight("rails\" onclick=\"alert(1)", /rails.*/, highlighter: '\0', sanitize: false) ++ ) ++ end ++ ++ def test_highlight_does_not_escape_the_highlighted_phrase_twice ++ assert_equal( ++ "ruby & rails", ++ highlight("ruby & rails", /ruby.*rails/, highlighter: '\1') ++ ) ++ end ++ ++ def test_highlight_with_regexp_groups_in_highlighter ++ assert_equal( ++ "ruby on "rails"", ++ highlight("ruby on \"rails\"", /(on) (\S+)/, highlighter: '\2 \3\4') ++ ) ++ end ++ ++ def test_highlight_with_html_safe_highlighter ++ assert_equal( ++ ""rails"", ++ highlight("\"rails\"", "\"rails\"", highlighter: content_tag(:mark, '\1', title: '\1')) ++ ) ++ end ++ ++ def test_highlight_does_not_replace_the_end_of_a_tag ++ text = " onerror=alert(1) a=\" end" ++ assert_equal text, highlight(text, ">", highlighter: '\1') ++ assert_equal text, highlight(text, ">") { |match| "" } ++ assert_equal text, highlight(text, /.*end/, highlighter: '\1') ++ assert_equal text, highlight(text, />.*/, highlighter: '\1') ++ assert_equal text, highlight(text, ">", highlighter: '\1', sanitize: false) ++ assert_equal text, highlight(text, />.*/, highlighter: '\1', sanitize: false) ++ ++ assert_equal "

rails

", highlight("

rails

", ">") ++ assert_equal "

rails

", highlight("

rails

", />rails/) ++ assert_equal "

rails

", highlight("

rails

", /.*rails.*/) ++ assert_equal "

rails

", highlight("

rails

", /.*rails.*/) { |match| "#{match}" } ++ ++ assert_equal "> 1 > 2", highlight("> 1 > 2", ">") ++ assert_equal "> 1 > 2", highlight("> 1 > 2", ">", sanitize: false) ++ assert_equal "

1 > 2

", highlight("

1 > 2

", ">", sanitize: false) ++ end ++ ++ def test_highlight_preserves_regexp_boundaries_after_a_tag ++ assert_equal "

rails

", highlight("

rails

", /\Arails/) ++ assert_equal "

rails

", highlight("

rails

", /(?<=>)rails/) ++ end ++ + def test_highlight_does_not_modify_the_options_hash + options = { highlighter: '\1', sanitize: false } + passed_options = options.dup diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126079.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126079.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126079.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126079.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,129 @@ +Description: Escape "<" and ">" inside attribute values before highlight + and simple_format split the string. + HTML5 serialization in Nokogiri 1.18.2 leaves "<" and ">" inside + attribute values. highlight then scans on those characters, and + simple_format splits on a blank line, so markup that was still inside + an attribute becomes a live element in the html_safe result. + . + Escape the two characters inside quoted attribute values first, and + keep a newline inside a tag from starting a paragraph or a
. + . + Upstream Rails 8.0.5.2 gets this safety by requiring Nokogiri 1.19.5. + Trixie stays on Nokogiri 1.18.2, so the helpers do the escape themselves. +Author: Simon Quigley +Origin: vendor +Bug: https://github.com/rails/rails/security/advisories/GHSA-2p2f-4rq4-gjwc +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/actionview/lib/action_view/helpers/text_helper.rb ++++ b/actionview/lib/action_view/helpers/text_helper.rb +@@ -180,6 +180,7 @@ + # # => "ruby on rails" + def highlight(text, phrases, options = {}, &block) + text = sanitize(text) if options.fetch(:sanitize, true) ++ text = escape_angle_brackets_in_attributes(text) unless text.nil? + + if text.blank? || phrases.blank? + text || "" +@@ -545,11 +546,69 @@ + @_cycles[name] = cycle_object + end + ++ # HTML5 serialization before Nokogiri 1.19.5 leaves "<" and ">" ++ # inside attribute values. Escape them before highlight scans and ++ # before simple_format splits, and keep a newline inside a tag. ++ def escape_angle_brackets_in_attributes(html) ++ return html if html.nil? ++ ++ source = html.to_str ++ return source if source.empty? ++ ++ escaped = +"" ++ index = 0 ++ length = source.length ++ ++ while index < length ++ if source[index] == "<" ++ escaped << "<" ++ index += 1 ++ quote = nil ++ ++ while index < length ++ char = source[index] ++ if quote ++ if char == quote ++ quote = nil ++ escaped << char ++ elsif char == "<" ++ escaped << "<" ++ elsif char == ">" ++ escaped << ">" ++ else ++ escaped << char ++ end ++ elsif char == '"' || char == "'" ++ quote = char ++ escaped << char ++ elsif char == ">" ++ escaped << ">" ++ index += 1 ++ break ++ else ++ escaped << char ++ end ++ index += 1 ++ end ++ else ++ next_tag = source.index("<", index) || length ++ escaped << source[index...next_tag] ++ index = next_tag ++ end ++ end ++ ++ escaped ++ end ++ + def split_paragraphs(text) + return [] if text.blank? + +- text.to_str.gsub(/\r\n?/, "\n").split(/\n\n+/).map! do |t| +- t.gsub!(/([^\n]\n)(?=[^\n])/, '\1
') || t ++ text = escape_angle_brackets_in_attributes(text.to_str) ++ text = text.gsub(/\r\n?/, "\n") ++ text = text.gsub(/<[^>]*>/) { |tag| tag.gsub("\n", "\u0000") } ++ text.split(/\n\n+/).map! do |paragraph| ++ paragraph.gsub!(/([^\n]\n)(?=[^\n])/, '\1
') || paragraph ++ paragraph.gsub("\u0000", "\n") + end + end + +--- a/actionview/test/template/text_helper_test.rb ++++ b/actionview/test/template/text_helper_test.rb +@@ -335,6 +335,24 @@ + assert_equal "

rails

", highlight("

rails

", /(?<=>)rails/) + end + ++ def test_highlight_keeps_markup_inside_attribute_values_inert ++ html = highlight(%(z), "class", sanitize: false) ++ ++ assert_empty Nokogiri::HTML5.fragment(html).css("img") ++ assert_includes html, "class=\"<img src=x onerror=alert(1)>\"" ++ assert_equal %(

rails

), highlight("

rails

", "rails", sanitize: false) ++ end ++ ++ def test_simple_format_keeps_markup_inside_attribute_values_inert ++ html = simple_format(%(link), { class: "post" }, { sanitize: false }) ++ ++ assert_empty Nokogiri::HTML5.fragment(html).css("img") ++ assert_includes html, "<img src=x onerror=alert(1)>" ++ assert_includes html, "

" ++ assert_equal "

one

\n\n

two

", simple_format("one\n\ntwo", {}, { sanitize: false }) ++ assert_equal "

one\n
two

", simple_format("one\ntwo", {}, { sanitize: false }) ++ end ++ + def test_highlight_does_not_modify_the_options_hash + options = { highlighter: '\1', sanitize: false } + passed_options = options.dup diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126080.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126080.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126080.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126080.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,84 @@ +Description: Match safe_constantize load errors as a literal string. + `safe_constantize` built a `Regexp` from the constant name, unescaped, + to check a `LoadError` message, so a caller passing untrusted input, + such as an Action Cable subscribe command, chose the pattern the + server compiled. + . + Match the name's first segment as a literal string instead, and add a + CHANGELOG entry. +Author: Jeremy Daer +Origin: upstream, https://github.com/rails/rails/commit/210ac22d446c8e2625b091e79256806b836eee20 +Bug: https://github.com/rails/rails/security/advisories/GHSA-8474-xrp6-wh69 +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/activesupport/lib/active_support/inflector/methods.rb ++++ b/activesupport/lib/active_support/inflector/methods.rb +@@ -319,7 +319,8 @@ module ActiveSupport + e.name.to_s == camel_cased_word.to_s) + rescue LoadError => e + message = e.respond_to?(:original_message) ? e.original_message : e.message +- raise unless /Unable to autoload constant #{const_regexp(camel_cased_word)}/.match?(message) ++ constant_name = camel_cased_word.split("::").find { |part| !part.empty? } || camel_cased_word ++ raise unless message.include?("Unable to autoload constant #{constant_name}") + end + + # Returns the suffix that should be added to a number to denote the position +@@ -349,23 +350,6 @@ module ActiveSupport + end + + private +- # Mounts a regular expression, returned as a string to ease interpolation, +- # that will match part by part the given constant. +- # +- # const_regexp("Foo::Bar::Baz") # => "Foo(::Bar(::Baz)?)?" +- # const_regexp("::") # => "::" +- def const_regexp(camel_cased_word) +- parts = camel_cased_word.split("::") +- +- return Regexp.escape(camel_cased_word) if parts.empty? +- +- last = parts.pop +- +- parts.reverse!.inject(last) do |acc, part| +- part.empty? ? acc : "#{part}(::#{acc})?" +- end +- end +- + # Applies inflection rules for +singularize+ and +pluralize+. + # + # If passed an optional +locale+ parameter, the uncountables will be +--- a/activesupport/test/inflector_test.rb ++++ b/activesupport/test/inflector_test.rb +@@ -438,6 +438,29 @@ class InflectorTest < ActiveSupport::Tes + end + end + ++ def test_safe_constantize_treats_load_error_constant_name_as_literal ++ mismatches = { ++ "Example.Channel" => "ExampleXChannel", ++ "Example.Channel::Nested" => "ExampleXChannel", ++ } ++ ++ mismatches.each do |requested_name, reported_name| ++ error = LoadError.new("Unable to autoload constant #{reported_name}") ++ ++ ActiveSupport::Inflector.stub(:constantize, ->(_) { raise error }) do ++ assert_raises(LoadError) do ++ ActiveSupport::Inflector.safe_constantize(requested_name) ++ end ++ end ++ end ++ ++ matching_error = LoadError.new("Unable to autoload constant Example.Channel") ++ ++ ActiveSupport::Inflector.stub(:constantize, ->(_) { raise matching_error }) do ++ assert_nil ActiveSupport::Inflector.safe_constantize("Example.Channel::Nested") ++ end ++ end ++ + def test_ordinal + OrdinalNumbers.each do |number, ordinalized| + assert_equal(ordinalized, number + ActiveSupport::Inflector.ordinal(number)) diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126081.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126081.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126081.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126081.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,92 @@ +Description: Return the parameters object from each_key. + `ActionController::Parameters#each_key` was delegated to the internal + hash, so with a block it returned that `HashWithIndifferentAccess` + instead of the `Parameters`, and mass assignment of the return value + skipped the `permitted?` check. + . + Define `each_key` to return `self`, as `each_pair` and `each_value` do. + Document that `as_json` returns every parameter, permitted or not, in a + plain hash that mass assignment does not check. +Author: Mike Dalessio +Origin: upstream, https://github.com/rails/rails/commit/2fc8838300133931e19eed3ea6cee76a7e83f19c +Bug: https://github.com/rails/rails/security/advisories/GHSA-wm3x-v3qw-4jh3 +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/actionpack/lib/action_controller/metal/strong_parameters.rb ++++ b/actionpack/lib/action_controller/metal/strong_parameters.rb +@@ -184,15 +184,14 @@ module ActionController + # as_json(options=nil) + # + # Returns a hash that can be used as the JSON representation for the parameters. +- +- ## +- # :method: each_key + # +- # :call-seq: +- # each_key(&block) ++ # Like `#to_unsafe_h`, the hash holds every parameter, permitted or not, and ++ # mass assignment does not check it. Do not pass it to a model. + # +- # Calls block once for each key in the parameters, passing the key. If no block +- # is given, an enumerator is returned instead. ++ # params = ActionController::Parameters.new(name: "Bob", admin: true) ++ # params.as_json # => {"name" => "Bob", "admin" => true} ++ # User.new(params) # => ActiveModel::ForbiddenAttributesError ++ # User.new(params.as_json) # => # + + ## + # :method: empty? +@@ -235,7 +234,7 @@ module ActionController + # Returns the content of the parameters as a string. + + delegate :keys, :empty?, :exclude?, :include?, +- :as_json, :to_s, :each_key, to: :@parameters ++ :as_json, :to_s, to: :@parameters + + alias_method :has_key?, :include? + alias_method :key?, :include? +@@ -420,6 +419,15 @@ module ActionController + + self + end ++ ++ # Calls block once for each key in the parameters, passing the key. If no block ++ # is given, an enumerator is returned instead. ++ def each_key(&block) ++ return to_enum(:each_key) unless block_given? ++ @parameters.each_key(&block) ++ ++ self ++ end + + # Returns a new array of the values of the parameters. + def values +--- a/actionpack/test/controller/parameters/accessors_test.rb ++++ b/actionpack/test/controller/parameters/accessors_test.rb +@@ -31,6 +31,23 @@ class ParametersAccessorsTest < ActiveSu + assert_same @params, @params.each_value { |_| _ } + end + ++ test "each_key returns self" do ++ assert_same @params, @params.each_key { |_| _ } ++ end ++ ++ test "each_key yields each key" do ++ keys = [] ++ @params.each_key { |key| keys << key } ++ assert_equal @params.keys, keys ++ end ++ ++ test "each_key return value is rejected by mass assignment" do ++ model = Class.new { include ActiveModel::API; attr_accessor :person }.new ++ assert_raises(ActiveModel::ForbiddenAttributesError) do ++ model.assign_attributes(@params.each_key { |_| _ }) ++ end ++ end ++ + test "[] retains permitted status" do + @params.permit! + assert_predicate @params[:person], :permitted? diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126084.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126084.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126084.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126084.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,136 @@ +Description: Sign GCS direct uploads with V2 when cache_control is set. + Since e3fe39285f, a GCS service with `cache_control` signed direct-upload + URLs with V4, which did not bind the Content-Type or Content-MD5 + headers. The uploader could store any Content-Type on the object. + . + Always sign with V2, which binds both. `headers_for_direct_upload` still + returns Cache-Control, which the client now sends unsigned, so the + uploader can change its own object's Cache-Control. Direct-upload URLs + with `cache_control` are no longer limited to V4's 7-day expiry. +Author: Mike Dalessio +Origin: upstream, https://github.com/rails/rails/commit/ddc08ba61a8001e7402864c62e466cf732fc7614 +Bug: https://github.com/rails/rails/security/advisories/GHSA-3w93-6hmw-whh4 +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/activestorage/lib/active_storage/service/gcs_service.rb ++++ b/activestorage/lib/active_storage/service/gcs_service.rb +@@ -91,25 +91,14 @@ module ActiveStorage + + def url_for_direct_upload(key, expires_in:, checksum:, custom_metadata: {}, **) + instrument :url, key: key do |payload| +- headers = {} +- version = :v2 +- +- if @config[:cache_control].present? +- headers["Cache-Control"] = @config[:cache_control] +- # v2 signing doesn't support non `x-goog-` headers. Only switch to v4 signing +- # if necessary for back-compat; v4 limits the expiration of the URL to 7 days +- # whereas v2 has no limit +- version = :v4 +- end +- +- headers.merge!(custom_metadata_headers(custom_metadata)) +- ++ # V2 signatures bind the Content-Type (empty) and Content-MD5 headers. GCS leaves headers ++ # other than x-goog-* out of V2 signatures, so the client sends Cache-Control unsigned. + args = { + content_md5: checksum, + expires: expires_in, +- headers: headers, ++ headers: custom_metadata_headers(custom_metadata), + method: "PUT", +- version: version, ++ version: :v2, + } + + if @config[:iam] +--- a/activestorage/test/service/gcs_service_test.rb ++++ b/activestorage/test/service/gcs_service_test.rb +@@ -87,6 +87,32 @@ if SERVICE_CONFIGURATIONS[:gcs] + service.delete(key) + end + ++ test "direct upload with cache control rejects a Content-Type the URL does not sign" do ++ config_with_cache_control = { gcs: SERVICE_CONFIGURATIONS[:gcs].merge({ cache_control: "public, max-age=1800" }) } ++ service = ActiveStorage::Service.configure(:gcs, config_with_cache_control) ++ ++ key = SecureRandom.base58(24) ++ data = "" ++ checksum = Digest::MD5.base64digest(data) ++ url = service.url_for_direct_upload(key, expires_in: 5.minutes, content_type: "image/png", content_length: data.size, checksum: checksum) ++ ++ uri = URI.parse url ++ request = Net::HTTP::Put.new uri.request_uri ++ request.body = data ++ service.headers_for_direct_upload(key, checksum: checksum, filename: ActiveStorage::Filename.new("test.png"), content_type: "image/png").each do |k, v| ++ request.add_field k, v ++ end ++ request.add_field "Content-Type", "text/html" ++ response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| ++ http.request request ++ end ++ ++ assert_equal "403", response.code ++ assert_not service.exist?(key) ++ ensure ++ service.delete(key) ++ end ++ + test "upload with content_type and content_disposition" do + key = SecureRandom.base58(24) + data = "Something else entirely!" +@@ -203,3 +229,51 @@ if SERVICE_CONFIGURATIONS[:gcs] + else + puts "Skipping GCS Service tests because no GCS configuration was supplied" + end ++ ++class ActiveStorage::Service::GCSServiceDirectUploadSignatureTest < ActiveSupport::TestCase ++ setup do ++ @signing_key = OpenSSL::PKey::RSA.new(2048) ++ @service = ActiveStorage::Service.configure(:gcs, gcs: { ++ service: "GCS", ++ bucket: "bucket", ++ cache_control: "public, max-age=1800", ++ project_id: "project", ++ credentials: { ++ type: "service_account", ++ project_id: "project", ++ client_email: "uploader@project.iam.gserviceaccount.com", ++ private_key: @signing_key.to_pem ++ } ++ }) ++ @checksum = OpenSSL::Digest::MD5.base64digest("Some text") ++ end ++ ++ test "direct upload with cache control authorizes only an empty Content-Type" do ++ url = @service.url_for_direct_upload("key", expires_in: 5.minutes, content_type: "text/plain", content_length: 9, checksum: @checksum) ++ ++ assert authorizes?(url, content_type: "", checksum: @checksum) ++ assert_not authorizes?(url, content_type: "text/html", checksum: @checksum) ++ end ++ ++ test "direct upload with cache control authorizes only the declared checksum" do ++ url = @service.url_for_direct_upload("key", expires_in: 5.minutes, content_type: "text/plain", content_length: 9, checksum: @checksum) ++ ++ assert authorizes?(url, content_type: "", checksum: @checksum) ++ assert_not authorizes?(url, content_type: "", checksum: OpenSSL::Digest::MD5.base64digest("Other text")) ++ end ++ ++ test "direct upload headers with cache control include Cache-Control" do ++ headers = @service.headers_for_direct_upload("key", checksum: @checksum, filename: ActiveStorage::Filename.new("test.txt"), content_type: "text/plain") ++ ++ assert_equal "public, max-age=1800", headers["Cache-Control"] ++ end ++ ++ private ++ # Rebuilds the string that GCS verifies a V2 signed PUT URL against. ++ def authorizes?(url, content_type:, checksum:) ++ query = Rack::Utils.parse_query(URI(url).query) ++ string_to_sign = ["PUT", checksum, content_type, query["Expires"], "/bucket/key"].join("\n") ++ ++ @signing_key.public_key.verify(OpenSSL::Digest::SHA256.new, Base64.strict_decode64(query["Signature"].to_s), string_to_sign) ++ end ++end diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126085.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126085.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126085.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126085.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,228 @@ +Description: Bind the declared byte size on a GCS direct upload. + GCS direct-upload URLs did not bind the declared content length, so a + client could store a body of any size under a blob whose `byte_size` + said otherwise. + . + Sign `x-goog-content-length-range` for the declared length and return + it from `headers_for_direct_upload`. + . + Browsers send the new header, so a bucket's CORS configuration must + allow `x-goog-content-length-range`; the guide's example now does. +Author: Mike Dalessio +Origin: upstream, https://github.com/rails/rails/commit/7fe85a72a789eae5ee070ce3ee1dad10a8a5f70c +Bug: https://github.com/rails/rails/security/advisories/GHSA-hfr4-8rjc-97m2 +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/activestorage/lib/active_storage/service/gcs_service.rb ++++ b/activestorage/lib/active_storage/service/gcs_service.rb +@@ -89,14 +89,14 @@ module ActiveStorage + end + end + +- def url_for_direct_upload(key, expires_in:, checksum:, custom_metadata: {}, **) ++ def url_for_direct_upload(key, expires_in:, checksum:, content_length:, custom_metadata: {}, **) + instrument :url, key: key do |payload| + # V2 signatures bind the Content-Type (empty) and Content-MD5 headers. GCS leaves headers + # other than x-goog-* out of V2 signatures, so the client sends Cache-Control unsigned. + args = { + content_md5: checksum, + expires: expires_in, +- headers: custom_metadata_headers(custom_metadata), ++ headers: { "x-goog-content-length-range" => content_length_range(content_length), **custom_metadata_headers(custom_metadata) }, + method: "PUT", + version: :v2, + } +@@ -114,10 +114,10 @@ module ActiveStorage + end + end + +- def headers_for_direct_upload(key, checksum:, filename: nil, disposition: nil, custom_metadata: {}, **) ++ def headers_for_direct_upload(key, checksum:, content_length:, filename: nil, disposition: nil, custom_metadata: {}, **) + content_disposition = content_disposition_with(type: disposition, filename: filename) if filename + +- headers = { "Content-MD5" => checksum, "Content-Disposition" => content_disposition, **custom_metadata_headers(custom_metadata) } ++ headers = { "Content-MD5" => checksum, "Content-Disposition" => content_disposition, "x-goog-content-length-range" => content_length_range(content_length), **custom_metadata_headers(custom_metadata) } + if @config[:cache_control].present? + headers["Cache-Control"] = @config[:cache_control] + end +@@ -217,5 +217,9 @@ module ActiveStorage + def custom_metadata_headers(metadata) + metadata.transform_keys { |key| "x-goog-meta-#{key}" } + end ++ ++ def content_length_range(content_length) ++ "#{content_length},#{content_length}" ++ end + end + end +--- a/activestorage/test/controllers/direct_uploads_controller_test.rb ++++ b/activestorage/test/controllers/direct_uploads_controller_test.rb +@@ -84,7 +84,7 @@ if SERVICE_CONFIGURATIONS[:gcs] + assert_equal metadata, details["metadata"] + assert_equal "text/plain", details["content_type"] + assert_match %r{storage\.googleapis\.com/#{@config[:bucket]}}, details["direct_upload"]["url"] +- assert_equal({ "Content-MD5" => checksum, "Content-Disposition" => "inline; filename=\"hello.txt\"; filename*=UTF-8''hello.txt", "x-goog-meta-my_key_3" => "my_value_3" }, details["direct_upload"]["headers"]) ++ assert_equal({ "Content-MD5" => checksum, "Content-Disposition" => "inline; filename=\"hello.txt\"; filename*=UTF-8''hello.txt", "x-goog-content-length-range" => "6,6", "x-goog-meta-my_key_3" => "my_value_3" }, details["direct_upload"]["headers"]) + end + end + end +--- a/activestorage/test/service/gcs_public_service_test.rb ++++ b/activestorage/test/service/gcs_public_service_test.rb +@@ -29,6 +29,7 @@ if SERVICE_CONFIGURATIONS[:gcs_public] + request.body = data + request.add_field "Content-Type", "" + request.add_field "Content-MD5", checksum ++ request.add_field "x-goog-content-length-range", "#{data.size},#{data.size}" + Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| + http.request request + end +--- a/activestorage/test/service/gcs_service_test.rb ++++ b/activestorage/test/service/gcs_service_test.rb +@@ -24,6 +24,7 @@ if SERVICE_CONFIGURATIONS[:gcs] + request.body = data + request.add_field "Content-Type", "" + request.add_field "Content-MD5", checksum ++ request.add_field "x-goog-content-length-range", "#{data.size},#{data.size}" + Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| + http.request request + end +@@ -33,6 +34,31 @@ if SERVICE_CONFIGURATIONS[:gcs] + @service.delete key + end + ++ test "directly uploading file larger than the provided content-length does not work" do ++ key = SecureRandom.base58(24) ++ data = "Some text that is longer than the specified content length" ++ checksum = OpenSSL::Digest::MD5.base64digest(data) ++ url = @service.url_for_direct_upload(key, expires_in: 5.minutes, content_type: "text/plain", content_length: data.size - 1, checksum: checksum) ++ ++ uri = URI.parse url ++ request = Net::HTTP::Put.new uri.request_uri ++ request.body = data ++ @service.headers_for_direct_upload(key, checksum: checksum, content_length: data.size - 1).each do |k, v| ++ request.add_field k, v ++ end ++ request.add_field "Content-Type", "" ++ upload_result = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| ++ http.request request ++ end ++ ++ assert_equal "400", upload_result.code ++ assert_raises ActiveStorage::FileNotFoundError do ++ @service.download(key) ++ end ++ ensure ++ @service.delete key ++ end ++ + test "direct upload with content disposition" do + key = SecureRandom.base58(24) + data = "Something else entirely!" +@@ -42,7 +68,7 @@ if SERVICE_CONFIGURATIONS[:gcs] + uri = URI.parse url + request = Net::HTTP::Put.new uri.request_uri + request.body = data +- @service.headers_for_direct_upload(key, checksum: checksum, filename: ActiveStorage::Filename.new("test.txt"), disposition: :attachment).each do |k, v| ++ @service.headers_for_direct_upload(key, checksum: checksum, content_length: data.size, filename: ActiveStorage::Filename.new("test.txt"), disposition: :attachment).each do |k, v| + request.add_field k, v + end + request.add_field "Content-Type", "" +@@ -69,7 +95,7 @@ if SERVICE_CONFIGURATIONS[:gcs] + uri = URI.parse url + request = Net::HTTP::Put.new uri.request_uri + request.body = data +- headers = service.headers_for_direct_upload(key, checksum: checksum, filename: ActiveStorage::Filename.new("test.txt"), disposition: :attachment) ++ headers = service.headers_for_direct_upload(key, checksum: checksum, content_length: data.size, filename: ActiveStorage::Filename.new("test.txt"), disposition: :attachment) + assert_equal("public, max-age=1800", headers["Cache-Control"]) + + headers.each do |k, v| +@@ -99,7 +125,7 @@ if SERVICE_CONFIGURATIONS[:gcs] + uri = URI.parse url + request = Net::HTTP::Put.new uri.request_uri + request.body = data +- service.headers_for_direct_upload(key, checksum: checksum, filename: ActiveStorage::Filename.new("test.png"), content_type: "image/png").each do |k, v| ++ service.headers_for_direct_upload(key, checksum: checksum, content_length: data.size, filename: ActiveStorage::Filename.new("test.png"), content_type: "image/png").each do |k, v| + request.add_field k, v + end + request.add_field "Content-Type", "text/html" +@@ -207,6 +233,7 @@ if SERVICE_CONFIGURATIONS[:gcs] + request.body = data + request.add_field("Content-Type", "") + request.add_field("Content-MD5", checksum) ++ request.add_field("x-goog-content-length-range", "#{data.size},#{data.size}") + Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| + http.request request + end +@@ -251,28 +278,43 @@ class ActiveStorage::Service::GCSService + test "direct upload with cache control authorizes only an empty Content-Type" do + url = @service.url_for_direct_upload("key", expires_in: 5.minutes, content_type: "text/plain", content_length: 9, checksum: @checksum) + +- assert authorizes?(url, content_type: "", checksum: @checksum) +- assert_not authorizes?(url, content_type: "text/html", checksum: @checksum) ++ assert authorizes?(url, content_type: "", checksum: @checksum, content_length_range: "9,9") ++ assert_not authorizes?(url, content_type: "text/html", checksum: @checksum, content_length_range: "9,9") + end + + test "direct upload with cache control authorizes only the declared checksum" do + url = @service.url_for_direct_upload("key", expires_in: 5.minutes, content_type: "text/plain", content_length: 9, checksum: @checksum) + +- assert authorizes?(url, content_type: "", checksum: @checksum) +- assert_not authorizes?(url, content_type: "", checksum: OpenSSL::Digest::MD5.base64digest("Other text")) ++ assert authorizes?(url, content_type: "", checksum: @checksum, content_length_range: "9,9") ++ assert_not authorizes?(url, content_type: "", checksum: OpenSSL::Digest::MD5.base64digest("Other text"), content_length_range: "9,9") ++ end ++ ++ test "direct upload authorizes only the declared content length" do ++ url = @service.url_for_direct_upload("key", expires_in: 5.minutes, content_type: "text/plain", content_length: 9, checksum: @checksum) ++ ++ assert authorizes?(url, content_type: "", checksum: @checksum, content_length_range: "9,9") ++ assert_not authorizes?(url, content_type: "", checksum: @checksum, content_length_range: "0,1000") ++ assert_not authorizes?(url, content_type: "", checksum: @checksum, content_length_range: nil) + end + + test "direct upload headers with cache control include Cache-Control" do +- headers = @service.headers_for_direct_upload("key", checksum: @checksum, filename: ActiveStorage::Filename.new("test.txt"), content_type: "text/plain") ++ headers = @service.headers_for_direct_upload("key", checksum: @checksum, content_length: 9, filename: ActiveStorage::Filename.new("test.txt"), content_type: "text/plain") + + assert_equal "public, max-age=1800", headers["Cache-Control"] + end + ++ test "direct upload headers include the declared content length range" do ++ headers = @service.headers_for_direct_upload("key", checksum: @checksum, content_length: 9, filename: ActiveStorage::Filename.new("test.txt"), content_type: "text/plain") ++ ++ assert_equal "9,9", headers["x-goog-content-length-range"] ++ end ++ + private + # Rebuilds the string that GCS verifies a V2 signed PUT URL against. +- def authorizes?(url, content_type:, checksum:) ++ def authorizes?(url, content_type:, checksum:, content_length_range:) + query = Rack::Utils.parse_query(URI(url).query) +- string_to_sign = ["PUT", checksum, content_type, query["Expires"], "/bucket/key"].join("\n") ++ extension_headers = content_length_range ? "x-goog-content-length-range:#{content_length_range}\n" : "" ++ string_to_sign = ["PUT", checksum, content_type, query["Expires"], "#{extension_headers}/bucket/key"].join("\n") + + @signing_key.public_key.verify(OpenSSL::Digest::SHA256.new, Base64.strict_decode64(query["Signature"].to_s), string_to_sign) + end +--- a/guides/source/active_storage_overview.md ++++ b/guides/source/active_storage_overview.md +@@ -1099,6 +1099,7 @@ + * `x-ms-blob-content-disposition` (for Azure Storage only) + * `x-ms-blob-type` (for Azure Storage only) + * `Cache-Control` (for GCS, only if `cache_control` is set) ++ * `x-goog-content-length-range` (for GCS) + + No CORS configuration is required for the Disk service since it shares your app’s origin. + +@@ -1130,7 +1131,7 @@ + { + "origin": ["https://www.example.com"], + "method": ["PUT"], +- "responseHeader": ["Content-Type", "Content-MD5", "Content-Disposition"], ++ "responseHeader": ["Content-Type", "Content-MD5", "Content-Disposition", "x-goog-content-length-range"], + "maxAgeSeconds": 3600 + } + ] diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126186.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126186.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126186.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126186.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,114 @@ +Description: Keep an extension only when it matches the media type. + `Blob#open` named its tempfile after the uploaded filename, extension + included. FFmpeg picks its AviSynth demuxer on a `.avs` extension + alone, so a script named `attack.avs` and declared `video/mp4` was run by + ffprobe and ffmpeg. + . + Keep the extension only when Marcel maps it to the blob's content type. + . + ref: https://hackerone.com/reports/3900470 +Author: Mike Dalessio +Origin: upstream, https://github.com/rails/rails/commit/8106938fb0a595f11006dd1497cd409e27d7d636 +Bug: https://github.com/rails/rails/security/advisories/GHSA-v924-7rp8-4mxh +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/activestorage/app/models/active_storage/blob.rb ++++ b/activestorage/app/models/active_storage/blob.rb +@@ -312,7 +312,8 @@ class ActiveStorage::Blob < ActiveStorag + + # Downloads the blob to a tempfile on disk. Yields the tempfile. + # +- # The tempfile's name is prefixed with +ActiveStorage-+ and the blob's ID. Its extension matches that of the blob. ++ # The tempfile's name is prefixed with +ActiveStorage-+ and the blob's ID. It keeps the blob filename's ++ # extension when that extension denotes the blob's content type, and has no extension otherwise. + # + # By default, the tempfile is created in Dir.tmpdir. Pass +tmpdir:+ to create it in a different directory: + # +@@ -328,7 +329,7 @@ class ActiveStorage::Blob < ActiveStorag + key, + checksum: checksum, + verify: !composed, +- name: [ "ActiveStorage-#{id}-", filename.extension_with_delimiter ], ++ name: [ "ActiveStorage-#{id}-", tempfile_extension ], + tmpdir: tmpdir, + &block + ) +@@ -367,6 +368,25 @@ class ActiveStorage::Blob < ActiveStorag + end + + private ++ # The extension is there for tools that cannot tell the type from the bytes (316d87e4: ImageMagick ++ # needs it for an SVG with no XML declaration), but some tools choose a decoder on it alone: FFmpeg ++ # runs a `.avs` file as an AviSynth script. So the uploaded extension is kept only when it denotes ++ # the blob's media type. ++ def tempfile_extension ++ extension = filename.extension_with_delimiter ++ return "" if extension.blank? ++ ++ type_for_extension = Marcel::MimeType.for(name: filename.to_s) ++ return "" if type_for_extension == Marcel::MimeType::BINARY || type_for_extension != media_type ++ ++ extension ++ end ++ ++ # Marcel answers in canonical lowercase, so drop parameters and case before comparing. ++ def media_type ++ content_type.to_s.split(";").first.to_s.strip.downcase ++ end ++ + def compute_checksum_in_chunks(io) + raise ArgumentError, "io must be rewindable" unless io.respond_to?(:rewind) + +--- a/activestorage/test/models/blob_test.rb ++++ b/activestorage/test/models/blob_test.rb +@@ -207,6 +207,47 @@ class ActiveStorage::BlobTest < ActiveSu + end + end + ++ test "open drops a filename extension the content type does not account for" do ++ blob = create_blob(data: 'Import("/etc/passwd")', filename: "attack.avs", content_type: "video/mp4") ++ ++ assert_equal "video/mp4", blob.content_type ++ ++ blob.open do |file| ++ assert File.basename(file.path).start_with?("ActiveStorage-#{blob.id}-") ++ assert_equal "", File.extname(file.path) ++ end ++ end ++ ++ test "open drops a filename extension Marcel does not recognize" do ++ blob = create_blob(data: 'Import("/etc/passwd")', filename: "attack.avs", content_type: "application/octet-stream") ++ ++ blob.open { |file| assert_equal "", File.extname(file.path) } ++ end ++ ++ test "open drops a filename extension that denotes a different content type" do ++ blob = create_blob(data: "Hello world!", filename: "hello.jpg", content_type: "video/mp4", identify: false) ++ ++ blob.open { |file| assert_equal "", File.extname(file.path) } ++ end ++ ++ test "open drops a video extension from an image blob before ImageMagick can delegate it to ffmpeg" do ++ blob = create_blob(data: "#EXTM3U\n#EXTINF:1,\nfile:///etc/hostname\n", filename: "evil.mp4", content_type: "image/png", identify: false) ++ ++ blob.open { |file| assert_equal "", File.extname(file.path) } ++ end ++ ++ test "open compares the filename extension against the media type alone" do ++ blob = create_file_blob(filename: "icon.svg", content_type: "image/SVG+XML; charset=utf-8", identify: false) ++ ++ blob.open { |file| assert_equal ".svg", File.extname(file.path) } ++ end ++ ++ test "open keeps a filename extension the content type accounts for" do ++ create_file_blob(filename: "racecar.jpg", content_type: "image/jpeg").open do |file| ++ assert file.path.end_with?(".jpg") ++ end ++ end ++ + test "open in a custom tmpdir" do + create_file_blob(filename: "racecar.jpg").open(tmpdir: tmpdir = Dir.mktmpdir) do |file| + assert_predicate file, :binmode? diff -Nru rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126188.patch rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126188.patch --- rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126188.patch 1970-01-01 00:00:00.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/CVE-2026-126188.patch 2026-11-20 18:56:24.000000000 +0000 @@ -0,0 +1,274 @@ +Description: Restrict the formats ffprobe and ffmpeg may open. + Active Storage let ffmpeg and ffprobe choose any demuxer they were + built with, though previews and analysis need only common audio and + video containers. + . + Pass `-format_whitelist` immediately before the input at every ffmpeg + and ffprobe call site, from the new + `config.active_storage.ffmpeg_allowed_formats`. Log a warning when + ffprobe exits unsuccessfully, so a refused file's missing metadata has + a cause in the log. + . + Files in other formats, such as MXF, DV and AC3, now fail to preview + and get no metadata. Applications that need them must add their + demuxers to the list, or set it to `nil`; the CHANGELOG names the + refused formats. + . + On 7.2.2.2, streaming_max_ranges follows streaming_chunk_max_size. + The ffmpeg assignment is inserted with that line left in place. +Author: Mike Dalessio +Origin: backport, https://github.com/rails/rails/commit/69aff80d115bbb9d1e82fd6c6f2fd3ddeafb958b +Bug: https://github.com/rails/rails/security/advisories/GHSA-3f4q-8x5m-76v8 +Bug-Debian: https://bugs.debian.org/1154301 +Forwarded: not-needed +Reviewed-by: Simon Quigley +Last-Update: 2026-11-20 +--- +--- a/activestorage/lib/active_storage.rb ++++ b/activestorage/lib/active_storage.rb +@@ -367,6 +367,12 @@ module ActiveStorage + + mattr_accessor :video_preview_arguments, default: "-y -vframes 1 -f image2" + ++ mattr_accessor :ffmpeg_allowed_formats, default: %w[ mov matroska avi mpeg mpegts flv asf ogg mp3 wav flac aac aiff caf ].freeze ++ ++ def self.ffmpeg_format_whitelist_arguments # :nodoc: ++ [ "-format_whitelist", Array(ffmpeg_allowed_formats).join(",") ] unless ffmpeg_allowed_formats.nil? ++ end ++ + module Transformers + extend ActiveSupport::Autoload + +--- a/activestorage/lib/active_storage/analyzer/audio_analyzer.rb ++++ b/activestorage/lib/active_storage/analyzer/audio_analyzer.rb +@@ -60,9 +60,12 @@ module ActiveStorage + "-show_streams", + "-show_format", + "-v", "error", ++ *ActiveStorage.ffmpeg_format_whitelist_arguments, + file.path + ]) do |output| + JSON.parse(output.read) ++ end.tap do ++ logger.warn "Audio analysis failed because ffprobe exited with status #{$?.exitstatus}. The file may be corrupt, or in a format outside config.active_storage.ffmpeg_allowed_formats." unless $?.success? + end + end + rescue Errno::ENOENT +--- a/activestorage/lib/active_storage/analyzer/video_analyzer.rb ++++ b/activestorage/lib/active_storage/analyzer/video_analyzer.rb +@@ -140,9 +140,12 @@ module ActiveStorage + "-show_streams", + "-show_format", + "-v", "error", ++ *ActiveStorage.ffmpeg_format_whitelist_arguments, + file.path + ]) do |output| + JSON.parse(output.read) ++ end.tap do ++ logger.warn "Video analysis failed because ffprobe exited with status #{$?.exitstatus}. The file may be corrupt, or in a format outside config.active_storage.ffmpeg_allowed_formats." unless $?.success? + end + end + rescue Errno::ENOENT +--- a/activestorage/lib/active_storage/engine.rb ++++ b/activestorage/lib/active_storage/engine.rb +@@ -31,6 +31,7 @@ module ActiveStorage + config.active_storage.paths = ActiveSupport::OrderedOptions.new + config.active_storage.queues = ActiveSupport::InheritableOptions.new + config.active_storage.precompile_assets = true ++ config.active_storage.ffmpeg_allowed_formats = ActiveStorage.ffmpeg_allowed_formats + + config.active_storage.variable_content_types = %w( + image/png +@@ -118,6 +119,7 @@ module ActiveStorage + ActiveStorage.content_types_allowed_inline = app.config.active_storage.content_types_allowed_inline || [] + ActiveStorage.binary_content_type = app.config.active_storage.binary_content_type || "application/octet-stream" + ActiveStorage.video_preview_arguments = app.config.active_storage.video_preview_arguments || "-y -vframes 1 -f image2" ++ ActiveStorage.ffmpeg_allowed_formats = app.config.active_storage.ffmpeg_allowed_formats + ActiveStorage.track_variants = app.config.active_storage.track_variants || false + ActiveStorage.streaming_chunk_max_size = app.config.active_storage.streaming_chunk_max_size || 100.megabytes + ActiveStorage.streaming_max_ranges = app.config.active_storage.streaming_max_ranges || 1 +--- a/activestorage/lib/active_storage/previewer/video_previewer.rb ++++ b/activestorage/lib/active_storage/previewer/video_previewer.rb +@@ -30,7 +30,7 @@ module ActiveStorage + + private + def draw_relevant_frame_from(file, &block) +- draw self.class.ffmpeg_path, "-i", file.path, *Shellwords.split(ActiveStorage.video_preview_arguments), "-", &block ++ draw self.class.ffmpeg_path, *ActiveStorage.ffmpeg_format_whitelist_arguments, "-i", file.path, *Shellwords.split(ActiveStorage.video_preview_arguments), "-", &block + end + end + end +--- a/activestorage/test/analyzer/audio_analyzer_test.rb ++++ b/activestorage/test/analyzer/audio_analyzer_test.rb +@@ -17,6 +17,25 @@ class ActiveStorage::Analyzer::AudioAnal + assert_equal "Lavc57.64", metadata[:tags][:encoder] + end + ++ test "analyzing a playlist declared as audio" do ++ blob = create_playlist_blob(referencing: "audio.mp3", filename: "audio.m3u8", content_type: "audio/mpeg") ++ metadata = extract_metadata_from(blob) ++ ++ assert_nil metadata[:duration] ++ assert_nil metadata[:bit_rate] ++ end ++ ++ test "analyzing an audio file whose format is not allowed" do ++ blob = create_file_blob(filename: "audio.mp3", content_type: "audio/mp3") ++ ++ ActiveStorage.with(ffmpeg_allowed_formats: %w[ wav ], logger: ActiveSupport::Logger.new(log = StringIO.new)) do ++ metadata = extract_metadata_from(blob) ++ ++ assert_nil metadata[:duration] ++ assert_match "Audio analysis failed because ffprobe exited with status 1", log.string ++ end ++ end ++ + test "instrumenting analysis" do + events = subscribe_events_from("analyze.active_storage") + +--- a/activestorage/test/analyzer/video_analyzer_test.rb ++++ b/activestorage/test/analyzer/video_analyzer_test.rb +@@ -86,6 +86,25 @@ class ActiveStorage::Analyzer::VideoAnal + assert_not metadata[:audio] + end + ++ test "analyzing a playlist declared as a video" do ++ blob = create_playlist_blob(referencing: "video.mp4", filename: "video.m3u8", content_type: "video/mp4") ++ metadata = extract_metadata_from(blob) ++ ++ assert_nil metadata[:width] ++ assert_nil metadata[:duration] ++ end ++ ++ test "analyzing a video whose format is not allowed" do ++ blob = create_file_blob(filename: "video.mp4", content_type: "video/mp4") ++ ++ ActiveStorage.with(ffmpeg_allowed_formats: %w[ matroska ], logger: ActiveSupport::Logger.new(log = StringIO.new)) do ++ metadata = extract_metadata_from(blob) ++ ++ assert_nil metadata[:width] ++ assert_match "Video analysis failed because ffprobe exited with status 1", log.string ++ end ++ end ++ + test "instrumenting analysis" do + events = subscribe_events_from("analyze.active_storage") + +--- a/activestorage/test/previewer/video_previewer_test.rb ++++ b/activestorage/test/previewer/video_previewer_test.rb +@@ -20,6 +20,54 @@ class ActiveStorage::Previewer::VideoPre + end + end + ++ test "previewing videos in other common formats" do ++ { "video.webm" => "video/webm", "rotated_hdr_video.mov" => "video/quicktime" }.each do |fixture, content_type| ++ blob = create_file_blob(filename: fixture, content_type: content_type) ++ ++ ActiveStorage::Previewer::VideoPreviewer.new(blob).preview do |attachable| ++ assert_equal "image/jpeg", Marcel::Magic.by_extension(MiniMagick::Image.read(attachable[:io]).type).type, fixture ++ end ++ end ++ end ++ ++ test "previewing a playlist declared as a video" do ++ blob = create_playlist_blob(referencing: "video.mp4", filename: "video.m3u8", content_type: "video/mp4") ++ ++ assert_raises ActiveStorage::PreviewError do ++ ActiveStorage::Previewer::VideoPreviewer.new(blob).preview ++ end ++ end ++ ++ test "previewing a video whose format is not allowed" do ++ blob = create_file_blob(filename: "video.mp4", content_type: "video/mp4") ++ ++ ActiveStorage.with(ffmpeg_allowed_formats: %w[ matroska ]) do ++ assert_raises ActiveStorage::PreviewError do ++ ActiveStorage::Previewer::VideoPreviewer.new(blob).preview ++ end ++ end ++ end ++ ++ test "previewing a video whose format is not allowed by a comma-separated list" do ++ blob = create_file_blob(filename: "video.mp4", content_type: "video/mp4") ++ ++ ActiveStorage.with(ffmpeg_allowed_formats: "matroska,avi") do ++ assert_raises ActiveStorage::PreviewError do ++ ActiveStorage::Previewer::VideoPreviewer.new(blob).preview ++ end ++ end ++ end ++ ++ test "previewing a video when no formats are allowed" do ++ blob = create_file_blob(filename: "video.mp4", content_type: "video/mp4") ++ ++ ActiveStorage.with(ffmpeg_allowed_formats: []) do ++ assert_raises ActiveStorage::PreviewError do ++ ActiveStorage::Previewer::VideoPreviewer.new(blob).preview ++ end ++ end ++ end ++ + test "previewing a video that can't be previewed" do + blob = create_file_blob(filename: "report.pdf", content_type: "video/mp4") + +--- a/activestorage/test/test_helper.rb ++++ b/activestorage/test/test_helper.rb +@@ -51,6 +51,18 @@ class ActiveSupport::TestCase + ActiveStorage::Blob.create_before_direct_upload! key: key, filename: filename, byte_size: byte_size, checksum: checksum, content_type: content_type, record: record + end + ++ def create_playlist_blob(referencing:, filename:, content_type:) ++ playlist = <<~M3U8 ++ #EXTM3U ++ #EXT-X-TARGETDURATION:10 ++ #EXTINF:10, ++ file://#{file_fixture(referencing).realpath} ++ #EXT-X-ENDLIST ++ M3U8 ++ ++ create_blob(data: playlist, filename: filename, content_type: content_type, identify: false) ++ end ++ + def build_blob_after_unfurling(key: nil, data: "Hello world!", filename: "hello.txt", content_type: "text/plain", identify: true, record: nil) + ActiveStorage::Blob.build_after_unfurling key: key, io: StringIO.new(data), filename: filename, content_type: content_type, identify: identify, record: record + end +--- a/railties/test/application/configuration_test.rb ++++ b/railties/test/application/configuration_test.rb +@@ -3854,6 +3854,37 @@ module ApplicationTests + ActiveStorage.video_preview_arguments + end + ++ test "ActiveStorage.ffmpeg_allowed_formats restricts ffmpeg to common media formats by default" do ++ app "development" ++ ++ assert_equal %w[ mov matroska avi mpeg mpegts flv asf ogg mp3 wav flac aac aiff caf ], ActiveStorage.ffmpeg_allowed_formats ++ end ++ ++ test "ActiveStorage.ffmpeg_allowed_formats can be configured" do ++ add_to_config "config.active_storage.ffmpeg_allowed_formats = %w[ mov ]" ++ ++ app "development" ++ ++ assert_equal %w[ mov ], ActiveStorage.ffmpeg_allowed_formats ++ end ++ ++ test "ActiveStorage.ffmpeg_allowed_formats can be extended" do ++ add_to_config "config.active_storage.ffmpeg_allowed_formats += %w[ mxf ]" ++ ++ app "development" ++ ++ assert_includes ActiveStorage.ffmpeg_allowed_formats, "mov" ++ assert_includes ActiveStorage.ffmpeg_allowed_formats, "mxf" ++ end ++ ++ test "ActiveStorage.ffmpeg_allowed_formats can be disabled" do ++ add_to_config "config.active_storage.ffmpeg_allowed_formats = nil" ++ ++ app "development" ++ ++ assert_nil ActiveStorage.ffmpeg_allowed_formats ++ end ++ + test "ActiveStorage.variant_processor uses mini_magick without Rails 7 defaults" do + remove_from_config '.*config\.load_defaults.*\n' + diff -Nru rails-7.2.2.2+dfsg/debian/patches/series rails-7.2.2.2+dfsg/debian/patches/series --- rails-7.2.2.2+dfsg/debian/patches/series 2026-10-04 21:13:12.000000000 +0000 +++ rails-7.2.2.2+dfsg/debian/patches/series 2026-11-20 18:56:24.000000000 +0000 @@ -29,3 +29,21 @@ CVE-2026-33195-reject-disk-path-traversal.patch CVE-2026-33202-escape-disk-globs.patch CVE-2026-33658-limit-streaming-ranges.patch +CVE-2026-126188.patch +CVE-2026-126186.patch +CVE-2026-126084.patch +CVE-2026-126085.patch +CVE-2026-126081.patch +CVE-2026-126080.patch +CVE-2026-126078.patch +CVE-2026-126079.patch +CVE-2026-126077.patch +CVE-2026-126076.patch +CVE-2026-126074.patch +CVE-2026-126073.patch +CVE-2026-126072.patch +CVE-2026-126070.patch +CVE-2026-126069.patch +CVE-2026-126068.patch +CVE-2026-126067.patch +CVE-2026-122006.patch