Skip to content

Commit

Permalink
Merge pull request #48869 from brunoprietog/disable-session-active-st…
Browse files Browse the repository at this point in the history
…orage-proxy-controllers

Disable session in ActiveStorage blobs and representations proxy controllers

[CVE-2024-26144]
  • Loading branch information
rafaelfranca authored and tenderlove committed Feb 21, 2024
1 parent 56bcc0a commit 78fe149
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions activestorage/CHANGELOG.md
@@ -1,3 +1,11 @@
* Disables the session in `ActiveStorage::Blobs::ProxyController`
and `ActiveStorage::Representations::ProxyController`
in order to allow caching by default in some CDNs as CloudFlare

Fixes #44136

*Bruno Prieto*

## Rails 6.1.7.6 (August 22, 2023) ##

* No changes.
Expand Down
Expand Up @@ -4,6 +4,7 @@
class ActiveStorage::Blobs::ProxyController < ActiveStorage::BaseController
include ActiveStorage::SetBlob
include ActiveStorage::SetHeaders
include ActiveStorage::DisableSession

def show
http_cache_forever public: true do
Expand Down
Expand Up @@ -3,6 +3,7 @@
# Proxy files through application. This avoids having a redirect and makes files easier to cache.
class ActiveStorage::Representations::ProxyController < ActiveStorage::Representations::BaseController
include ActiveStorage::SetHeaders
include ActiveStorage::DisableSession

def show
http_cache_forever public: true do
Expand Down
@@ -0,0 +1,12 @@
# frozen_string_literal: true

# This concern disables the session in order to allow caching by default in some CDNs as CloudFlare.
module ActiveStorage::DisableSession
extend ActiveSupport::Concern

included do
before_action do
request.session_options[:skip] = true
end
end
end

0 comments on commit 78fe149

Please sign in to comment.