Exploit database

GH-0bf0461ee352d98af34ba79de7f55b74

rails/rails-forensics-cve-2026-66066

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-66066

7 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files4
rails/rails-forensics-cve-2026-66066Revision 81805d617de6

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

bin/kr2s_recover_variants.rb

Ruby · 2,317 bytes
# CVE-2026-66066 (GHSA-xr9x-r78c-5hrm) forensics.
#
# Recovers what a crafted blob actually returned. Each confirmed hit has a
# variant record, and that record holds the rendered image through
# has_one_attached :image. libmatio put the bytes it read from the target file
# into that image as pixel values, so the variant is what left the building.
#
# This reads only, through the reading role, and writes the recovered variants
# under --output for offline decoding.
#
#   bin/rails runner kr2s_recover_variants.rb --jsonl ./tmp/active-storage-RUN.jsonl \
#     --output ./tmp/variants

require "json"
require "optparse"
require "fileutils"
require "pathname"

options = { output: "./tmp/variants" }
OptionParser.new do |parser|
  parser.on("--jsonl PATH") { |value| options[:jsonl] = value }
  parser.on("--output DIR") { |value| options[:output] = value }
end.parse(ARGV)

crafted = File.readlines(options[:jsonl]).filter_map do |line|
  row = JSON.parse(line)
  row if row["verdict"] == "crafted"
end

output = Pathname.new(options[:output])
FileUtils.mkdir_p output

puts "crafted blobs in #{options[:jsonl]}: #{crafted.size}"
puts

ActiveRecord::Base.connected_to(role: :reading) do
  records = ActiveStorage::VariantRecord.where(blob_id: crafted.map { |row| row["blob_id"] })
  puts "variant records for them: #{records.count}"

  # The rendered image is an attachment on the variant record, so it is a blob
  # in its own right with its own key, size and creation time.
  images = ActiveStorage::Attachment
    .where(record_type: "ActiveStorage::VariantRecord", record_id: records.pluck(:id), name: "image")
    .includes(:blob)

  puts "rendered variant images still present: #{images.count}"
  puts

  sizes = Hash.new(0)
  recovered = 0

  images.find_each do |attachment|
    image = attachment.blob
    bytes = image.service.download(image.key)

    File.binwrite output.join("variant-#{attachment.record_id}-#{image.id}.bin"), bytes
    sizes[bytes.bytesize] += 1
    recovered += 1
  rescue StandardError => error
    warn "variant #{attachment.record_id}: #{error.class}: #{error.message}"
  end

  puts "recovered #{recovered} variant images into #{output}"
  puts
  puts "by size:"
  sizes.sort_by { |bytes, _| bytes }.each { |bytes, count| puts "  #{bytes.to_s.rjust(8)} bytes  x#{count}" }
end