The Wire · Showcase
RELATION#UPDATE IGNORES SCOPE: SILENT CROSS-TENANT WRITES
By RepoJournal · Filed · About Rails
A one-line fix that closes a silent cross-tenant write hole in Rails' association updates.
Rails' `Relation#update` and `#update!` currently ignore the relation's scope, so `post.comments.update!(comment_id, ...)` can write a comment belonging to another post when the id comes off a request [1][2]. This is a textbook tenant-boundary breach: when the association is the tenant boundary (`buyer.suppliers`, `account.users`), the relation's conditions never reach the query because the id is resolved by the class-level `find`. The PR keeps the scope in the query, and the maintainer notes it's a follow-up to the PK-overlapping FK clearing fix [3], which now also handles the case where keeping all FK parts would lose the set-to-nil operation. Meanwhile, `bin/rails test:system` raises a `LoadError` on fresh apps because `rails new` no longer generates a `test/system` folder but the generated CI still runs the command [4]. That's a one-line guard in the test runner. Elsewhere, the Agents on Rails second report is live with Grok 4.6, GLM 5.3, Gemini 3.7 Flash, and Opus 4.8 results [5], and the Opus 4.8 comparison to Opus 5 has been corrected [6]. The report's run logs are published in `rails/ai-evals` [7], and `bin/rails console` gets a `--no-banner` flag for scripts and CI [8].
One email a day. Unsubscribe in one click.
Keep up with Rails in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.
One email a day. Unsubscribe in one click. Read a past issue →
Action items
- → Review and test Relation#update scope fix before your next deploy rails/rails [immediate]
- → Patch bin/rails test:system LoadError if you use generated CI rails/rails [immediate]
- → Read the Agents on Rails second report for model benchmark results rails/website [monitor]
- → Try bin/rails console --no-banner in your scripts rails/rails [plan]
References
- [1] Keep the relation scope in `Relation#update` and `#update!` ↗ rails/rails
- [2] Keep the relation scope in `Relation#update` and `#update!` rails/rails
- [3] Fix clearing PK-overlapping association keys when assigning nil ↗ rails/rails
- [4] Don't raise LoadError when a test:* folder is missing ↗ rails/rails
- [5] Agents on Rails: second report ↗ rails/website
- [6] Fix comparison of Claude Opus versions (#723) rails/website
- [7] Add atomic tasks run logs ↗ rails/ai-evals
- [8] Add --no-banner to bin/rails console ↗ rails/rails