Skip to content
Info disclosure Disclosed report Intermediate

Possible Sensitive Session Information Leak in Active Storage

Active Storage sends the user's session cookie in a Set-Cookie header with a public Cache-Control header when serving blobs. Some caching proxies may cache this response, allowing unrelated users to obtain the original user's session cookie.

tyage Follow

Originally disclosed on HackerOne

Bounty$4,323 High 7.2 View original
  • Disclosed after 19 days

Summary by the program

Possible Sensitive Session Information Leak in Active Storage

There is a possible sensitive session information leak in Active Storage. By default, Active Storage sends a Set-Cookie header along with the user's session cookie when serving blobs. It also sets Cache-Control to public. Certain proxies may cache the Set-Cookie, leading to an information leak.

This vulnerability has been assigned the CVE identifier CVE-2024-26144.

Versions Affected: >= 5.2.0, < 7.1.0 Not affected: < 5.2.0, > 7.1.0 Fixed Versions: 7.0.8.1, 6.1.7.7

The report

Original report: https://hackerone.com/reports/2140554 Advisory: https://github.com/rails/rails/security/advisories/GHSA-8h22-8cf7-hq6g

Impact

Active Storage, when serving files (blobs), incorrectly sends the Set-Cookie header containing the user's session cookie along with a Cache-Control: public header. Some certain caching proxies may cache this response, including the Set-Cookie header. This allows unrelated users accessing the cached content to obtain the original user's session cookie.

The original report as published on HackerOne, by tyage. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

Active Storage is the file upload and attachment component of Ruby on Rails. Applications use it to attach blobs (images, documents and other files) to records and to serve those blobs back to users, either through a redirect to a storage service or directly through a Rails controller.

The report concerns a leak that happens in the second case: when Active Storage serves a blob itself, the response carries the user's session cookie in a Set-Cookie header, and the same response is marked Cache-Control: public. The combination means a shared cache in front of the application can store a response that contains one user's session cookie and hand it to somebody else.

The issue was assigned CVE-2024-26144. The affected range is >= 5.2.0, < 7.1.0, versions below 5.2.0 and above 7.1.0 are not affected, and the fixed versions are [redacted] and 6.1.7.7.

Setup

The report does not describe a test environment, accounts, roles or tooling. The relevant preconditions follow from the vulnerability itself: a Rails application on an affected version that serves Active Storage blobs through the application, a user with an active session, and a caching proxy between the user and the application that is willing to cache responses marked Cache-Control: public together with their Set-Cookie header.

Finding it

The observation is that Active Storage, by default, sends a Set-Cookie header along with the user's session cookie when serving blobs, and at the same time sets Cache-Control to public. A response that is explicitly public is a candidate for storage by shared caches, and a response that carries a session cookie must never be stored by a shared cache. The two headers together are the bug.

Exploitation

Step 1: A user requests a blob

A logged-in user fetches a blob served by Active Storage. The application responds with the blob and, in the same response, a Set-Cookie header containing the user's session cookie, plus Cache-Control: public.

Step 2: A proxy caches the response

A caching proxy on the path between the user and the application may cache the response, including the Set-Cookie header, because the response is marked public.

Step 3: Another user receives the cached response

An unrelated user who requests the same cached content is served the stored response and thereby obtains the original user's session cookie. With that cookie, the second user holds the original user's session cookie.

The report does not include the raw request or response, so the exact header values and the proxy configuration are not reproduced here.

Root cause

Active Storage serves blobs with the session cookie attached and marks the response Cache-Control: public. The mistake is the combination: a response that is allowed to be stored by shared caches must not carry per-user credentials, and a response that carries a session cookie must be private. Because the response is explicitly public, a caching proxy has no reason to refuse to store it, and the Set-Cookie header travels with the stored copy. The report does not describe any additional defence that was in place and failed; the default behaviour itself is the problem.

Impact

Unrelated users who access the cached content can obtain the original user's session cookie. The obtained cookie is the original user's session cookie. The report hedges the condition: this requires a caching proxy that caches the response including the Set-Cookie header, so the leak depends on the infrastructure in front of the application, not on the Rails application alone.

Fix

The fixed versions are [redacted] and 6.1.7.7.

Variants to test

  1. Any framework endpoint that serves user-specific content and sets Cache-Control: public: check whether the response also carries Set-Cookie. A positive result is a response with both headers present.
  2. File and attachment download endpoints, including redirects to storage services: check whether the redirect or the file response carries session cookies and public caching headers.
  3. Static and semi-static routes that still run through the session middleware: look for Set-Cookie on responses that a CDN or reverse proxy would consider cacheable.
  4. Responses with Vary headers that do not include Cookie: a cache may treat the response as shareable across users even when the content differs per session.

Hunting notes

This class of bug hides where application responses pass through a shared cache: CDNs, reverse proxies and any caching layer in front of a dynamic application. During recon, the signals are responses that combine Cache-Control: public (or a cacheable status with no private directive) with Set-Cookie, and endpoints that serve per-user files or attachments. The report shows impact by describing the concrete consequence: an unrelated user retrieving the cached response obtains the original user's session cookie.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

Imagine a café with a shared noticeboard. You ask the barista for a document that belongs to you, and the barista hands it over, but also pins a copy of your house key to the board so that "anyone who needs it later" can find it. The next customer who asks for the same document gets your key along with it. That is roughly what this bug does, except the document is a file served by a web application and the key is your session cookie.

Active Storage is a feature of Ruby on Rails, a popular framework for building websites. Rails is a set of tools that developers use to build web applications quickly. Active Storage is the part of Rails that handles files: it lets an application attach images, documents and other files (called blobs) to records in its database, and then serve those files back to users.

There are two ways Active Storage can hand a file to a user. It can redirect the user's browser to a separate storage service that holds the file, or it can send the file itself through the Rails application. This report is about the second way. When Active Storage sends the file itself, the response includes the user's session cookie, and the response is also marked as publicly cacheable. A caching proxy sitting between the user and the application can then store that response, cookie included, and give it to someone else.

The issue was given the identifier CVE-2024-26144. A CVE is a public catalogue number for a known security flaw, so people can refer to the same bug unambiguously. The affected versions are >= 5.2.0, < 7.1.0, meaning Rails 5.2.0 and later, up to but not including 7.1.0. Versions below 5.2.0 and above 7.1.0 are not affected. The fixed versions are [redacted] and 6.1.7.7.

The pieces you need to know

Before walking through the bug, here are the few concepts it relies on.

A cookie is a small piece of text that a website asks your browser to store and send back on every later request to that site. It is how a website remembers who you are between page loads. A session cookie is the specific cookie that proves you are logged in. If someone else gets a copy of it, their browser can present it to the site and the site will treat them as you. It is like a wristband at an event: whoever wears it gets in.

A header is a line of extra information that travels with every web request and response, alongside the actual content. Headers say things like what type of content is being sent, or whether the browser may store it. Two headers matter here:

  • Set-Cookie is a response header that tells the browser to store a cookie. When a site sends Set-Cookie with your session cookie, your browser saves it and sends it back next time.
  • Cache-Control is a response header that tells browsers and intermediate servers whether and how long they may keep a copy of the response. The value public means "anyone may store this, including shared caches". The value private means "only the end user's own browser may store this".

A caching proxy is a server that sits between users and the application and keeps copies of responses so it can answer repeated requests faster. A content delivery network (CDN) is a large-scale example. Because one proxy serves many users, anything it stores can be handed to a different user. That is fine for a public image, and dangerous for anything personal.

Information disclosure is the security term for a bug where data that should stay private becomes visible to someone who should not see it. Here the disclosed data is a session cookie.

Context

Active Storage is the file upload and attachment component of Ruby on Rails. Applications use it to attach blobs (images, documents and other files) to records and to serve those blobs back to users, either through a redirect to a storage service or directly through a Rails controller.

The report concerns a leak that happens in the second case: when Active Storage serves a blob itself, the response carries the user's session cookie in a Set-Cookie header, and the same response is marked Cache-Control: public. The combination means a shared cache in front of the application can store a response that contains one user's session cookie and hand it to somebody else.

The issue was assigned CVE-2024-26144. The affected range is >= 5.2.0, < 7.1.0, versions below 5.2.0 and above 7.1.0 are not affected, and the fixed versions are [redacted] and 6.1.7.7.

Setup

The report does not describe a test environment, accounts, roles or tooling. The relevant preconditions follow from the vulnerability itself: a Rails application on an affected version that serves Active Storage blobs through the application, a user with an active session, and a caching proxy between the user and the application that is willing to cache responses marked Cache-Control: public together with their Set-Cookie header.

In plain terms, you need three things in place for the bug to bite: the application must be on a vulnerable Rails version, it must be serving files itself rather than redirecting to a storage service, and there must be a shared cache in front of it that follows the public instruction. Remove any one of those and the leak does not happen.

Finding it

The observation is that Active Storage, by default, sends a Set-Cookie header along with the user's session cookie when serving blobs, and at the same time sets Cache-Control to public. A response that is explicitly public is a candidate for storage by shared caches, and a response that carries a session cookie must never be stored by a shared cache. The two headers together are the bug.

Think of it as two instructions that contradict each other. One header says "keep a copy of this for everyone". The other header hands over the visitor's wristband. Either instruction alone is normal; together they create the leak. The researcher did not need to break anything or guess a password: the default behaviour of the framework produced the dangerous combination on its own.

Exploitation

Step 1: A user requests a blob

A logged-in user fetches a blob served by Active Storage. The application responds with the blob and, in the same response, a Set-Cookie header containing the user's session cookie, plus Cache-Control: public.

Why this step matters: this is the ordinary, everyday action. The user is not doing anything unusual, just opening a file that belongs to them. The response they receive is the one that carries both the file and their credential.

Step 2: A proxy caches the response

A caching proxy on the path between the user and the application may cache the response, including the Set-Cookie header, because the response is marked public.

Why this step matters: the proxy is doing exactly what it was told. Cache-Control: public is an invitation to store the response, and the proxy has no instruction telling it to strip the cookie first. The stored copy now contains the user's session cookie.

Step 3: Another user receives the cached response

An unrelated user who requests the same cached content is served the stored response and thereby obtains the original user's session cookie. With that cookie, the second user holds the original user's session cookie.

Why this step matters: this is where the leak hands one user's session cookie to another. The second user never attacked anything; they simply asked for the same content and the cache answered with a copy that still had the first user's cookie attached. The stored copy still had the first user's session cookie attached.

The report does not include the raw request or response, so the exact header values and the proxy configuration are not reproduced here.

Root cause

Active Storage serves blobs with the session cookie attached and marks the response Cache-Control: public. The mistake is the combination: a response that is allowed to be stored by shared caches must not carry per-user credentials, and a response that carries a session cookie must be private. Because the response is explicitly public, a caching proxy has no reason to refuse to store it, and the Set-Cookie header travels with the stored copy. The report does not describe any additional defence that was in place and failed; the default behaviour itself is the problem.

A useful comparison is a photocopier in an office. If a document is marked "public, copy freely", the copier will happily duplicate it. If that same document happens to have your password written on the back, the copier does not know to stop. The fix has to come from whoever wrote the document, not from the copier.

Impact

Unrelated users who access the cached content can obtain the original user's session cookie. The obtained cookie is the original user's session cookie. The report hedges the condition: this requires a caching proxy that caches the response including the Set-Cookie header, so the leak depends on the infrastructure in front of the application, not on the Rails application alone.

In other words, not every deployment is exposed. A site with no shared cache in front of it, or a cache configured to ignore or strip Set-Cookie, would not leak. But where such a cache exists, the consequence is serious: the attacker does not need the victim's password, only the cookie that the cache handed out.

Fix

The reasoning behind the fix is simple: remove one of the two contradictory instructions, and the dangerous combination disappears.

Variants to test

The same pattern can appear elsewhere. These are the places worth checking, in the order the technical write-up lists them.

  1. Any framework endpoint that serves user-specific content and sets Cache-Control: public: check whether the response also carries Set-Cookie. A positive result is a response with both headers present.
  2. File and attachment download endpoints, including redirects to storage services: check whether the redirect or the file response carries session cookies and public caching headers.
  3. Static and semi-static routes that still run through the session middleware: look for Set-Cookie on responses that a CDN or reverse proxy would consider cacheable.
  4. Responses with Vary headers that do not include Cookie: a cache may treat the response as shareable across users even when the content differs per session.

A note on the fourth item: a Vary header tells a cache which parts of the request make responses different from each other. If Vary lists, say, the browser's language but not Cookie, the cache may assume two users asking for the same page can share one stored answer, even though the page is personalised. That is the same underlying mistake in a different disguise.

Hunting notes

This class of bug hides where application responses pass through a shared cache: CDNs, reverse proxies and any caching layer in front of a dynamic application. During recon, the signals are responses that combine Cache-Control: public (or a cacheable status with no private directive) with Set-Cookie, and endpoints that serve per-user files or attachments. The report shows impact by describing the concrete consequence: an unrelated user retrieving the cached response obtains the original user's session cookie.

For a beginner, the takeaway is a habit of looking at response headers, not just page content. When you see a response that both hands out a cookie and invites shared storage, you have found the shape of this bug.

Glossary

  • Active Storage: the part of the Ruby on Rails framework that attaches files to database records and serves them to users.
  • Blob: a file such as an image or document, as stored and served by Active Storage.
  • Cache-Control: a response header that tells browsers and intermediate servers whether they may keep a copy of the response, and for whom.
  • Caching proxy: a server between users and an application that stores copies of responses to answer repeated requests faster.
  • CDN (content delivery network): a large network of caching servers distributed geographically, used to serve content quickly to many users.
  • Cookie: a small piece of text a website asks the browser to store and send back on later requests, used to remember who you are.
  • CVE: a public catalogue identifier for a known security vulnerability.
  • CVSS score: a numeric rating of how severe a vulnerability is.
  • Header: a line of metadata sent with a web request or response, separate from the actual content.
  • Information disclosure: a vulnerability where data that should be private becomes visible to someone who should not see it.
  • Private (Cache-Control directive): an instruction that only the end user's own browser may store the response.
  • Public (Cache-Control directive): an instruction that any cache, including shared ones, may store the response.
  • Reverse proxy: a server that sits in front of an application and forwards requests to it, often also caching responses.
  • Ruby on Rails: a framework for building web applications in the Ruby programming language.
  • Session: the period during which a website recognises you as a logged-in user, tracked by a session cookie.
  • Session cookie: the cookie that proves you are logged in; anyone holding a copy can act as you.
  • Set-Cookie: a response header that instructs the browser to store a cookie.
  • Vary: a response header that tells caches which request headers make responses differ, so they know when a stored copy can be reused.
  • Vulnerability: a weakness in software that can be used to cause harm or break security.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.