Dev & EngARTICLE

Rails fixes multipart upload exploit and prevents update_all from leaking across association owners

Rails fixes multipart upload exploit and prevents update_all from leaking across association owners
Image: Bisneto Braga
Article · Dev & Eng
Reading
6 min
Code
2
In short

The This Week in Rails for November 20, 2026 brings a patch to Rack against a technique used in real exploits, plus a new default that better isolates association records. See what to check before updating in production.

The This Week in Rails bulletin for November 20, 2026, written by Claudio Baccigalupo, gathers a batch of changes with a stated focus on security: from the rewrite of the Securing Rails guide to two behavior adjustments that directly affect anyone already running an application. None of them is a new major version, but at least one arrives as a retroactive patch, which means it can change the behavior of apps in production without an explicit version upgrade.

It's worth separating what is a reinforcement of posture (the rewritten guide) from what is an actual behavior change (the patches). This piece focuses on the two patches and the two new defaults, because those are the ones that can silently break something.

Rack patch closes a door used in exploits

Rack::Multipart::Parser accepted multipart form data submitted in arbitrary character encodings. According to the bulletin, this behavior "has little to no legitimate use, but has been used multiple times in exploit chains against Rails applications." Rack now simply ignores the encoding declared by the client.

The detail that matters for anyone running production: the change wasn't held back for the next major release. It was backported to versions 8.1 and 8.0, meaning apps already on those versions get the new behavior when they update the patch, without needing to migrate defaults. If some legacy integration in your system depends on sending multipart in a different encoding (a rare case, but one that exists in old integrations with legacy systems), the opt-out is explicit:

ruby
config.action_dispatch.allow_rack_multipart_encoding = true

The trade-off here is direct: keeping this flag on reopens the attack surface the patch closes. Before enabling it, it's worth confirming whether the client that depends on the arbitrary encoding can't simply be fixed on the other side.

unscope in associations let update_all leak across owners

This is the most subtle adjustment in the bulletin, and also the easiest to miss in a code audit. When an association uses unscope(where: ...), unscope(:where), or rewhere in its scope, it can remove the very condition that links the records to the association's owner. The bulletin's example illustrates this with a has_many that loses the car_id clause:

ruby
class Car < ActiveRecord::Base
 has_many :all_bulbs, -> { unscope(:where) }, class_name: "Bulb"
end

car.all_bulbs
# Before: SELECT "bulbs".* FROM "bulbs"
# After: SELECT "bulbs".* FROM "bulbs" WHERE "bulbs"."car_id" = ?

The practical risk isn't just that the read query ends up broader than it should. It's that update_all, delete_all, and dependent: :delete_all called on that association would start affecting records belonging to other owners, because the condition that limited it to "only this car's bulbs" had disappeared along with the unscope.

The new config.active_record.association_scope_keeps_owner_conditions fixes this by always preserving the owner's condition, regardless of the unscope declared in the scope. With load_defaults "8.2" this behavior comes already enabled. Those on previous defaults keep the old behavior, but now receive a deprecation warning on every use, a sign that it's worth auditing has_many/has_one with unscope or rewhere in the scope before the default actually changes.

In short: if your app uses dependent: :delete_all or calls update_all/delete_all on associations with a custom scope, this is the line in the bulletin that deserves a code search now, not after the upgrade.

CI generated by rails new gets SHA pinning

The ci.yml that Rails generates for new apps now pins GitHub Actions versions by SHA instead of by tag, mitigating "repointed git tag" attacks (when someone re-points an already published tag to a malicious commit). Dependabot keeps updating these references automatically, so the security gain doesn't cost manual maintenance.

One deliberate exception: ruby/setup-ruby is left unpinned, so new Ruby versions become available immediately, an explicit trade-off between maximum security and not locking the workflow into an outdated Ruby version. Checkout actions also now declare persist-credentials: false, preventing later steps in the workflow from reading GitHub tokens directly from the filesystem.

This only affects new apps generated from now on; anyone who already has a ci.yml in production doesn't get the change automatically and can port the pattern manually by looking at Rails' updated template.

Action Mailer without Active Job: less coupling, one dependency to check

Rails broke the rigid dependency between Action Mailer and Active Job. Apps that use Action Mailer without Active Job now load much less code, a gain in boot time and dependency surface, not exactly a security item, but relevant for anyone auditing what each gem loads in production.

The point of attention is for anyone using Action Mailer outside a full Rails application (for example, in a gem or a service that only imports the mailer) and depends on deliver_later: from now on it may be necessary to explicitly add Active Job to the Gemfile, because it no longer comes along for free.

CSRF in Active Storage, fixtures, and the end of Rails 6.1 Marshal

Three smaller adjustments round out this week's security package:

  • Apps that turned off default_protect_from_forgery had Active Storage controllers without CSRF protection; now ActiveStorage::BaseController checks for this and re-enables protection in that case.
  • Support for the Marshal format generated by Rails 6.1 has been completely removed: Active Record models serialized in that old format can no longer be loaded (writing in that format had already been discontinued before). Anyone keeping cache or serialized session data for years without recycling it may hit this limit when upgrading.
  • Fixtures for tables with virtual columns (generated by the database) no longer fail with a "column does not exist" error, since the value is now left up to the database itself.

None of these three is dramatic on its own, but the pattern is consistent with the rest of the bulletin: closing gaps that depended on manual configuration or poorly documented legacy behavior.

What to check before updating

For anyone maintaining Rails in production, this bulletin's practical checklist looks like this:

  1. Run integration tests that depend on multipart upload with non-standard encoding, if there are any.
  2. Search the code for unscope and rewhere inside has_many/has_one scope blocks, especially near update_all, delete_all, or dependent: :delete_all.
  3. Check whether default_protect_from_forgery is turned off anywhere in the configuration and whether that was intentional for Active Storage too.
  4. Check whether any service uses Action Mailer isolated from the Rails application and depends on deliver_later without Active Job declared in the Gemfile.
  5. If there's long-standing cached or serialized payload data, confirm it's not a leftover from the Rails 6.1 format.

None of this requires migrating to a new major version today. But since one of the patches has already been backported to 8.0 and 8.1, part of this behavior may already be changing with your next bundle update, with or without an explicit notice in your app's changelog.

Translated from the Brazilian Portuguese original · Read the original

Read also