Skip to content
Cache bugs Write-up Advanced

ChatGPT Account Takeover - Wildcard Web Cache Deception

A path traversal URL parser confusion allowed caching of sensitive API endpoints under the /share/ path, leaking user auth tokens. An attacker could steal a victim's token and take over their account.

Harel Follow

Published on nokline.github.io

Bounty$6,500 View original

Last year Nagli discovered a web cache deception vulnerability in ChatGPT. The impact of this was critical, as it lead to the leak of user’s auth tokens and subsequently, an account takeover.

Harel (@h4r3l), on nokline.github.io

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

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. 5 min read.

Context

ChatGPT had recently introduced a "share" feature that lets users publicly share their chats with others. A shared chat is reachable at a URL of the form:

Text
https://chat.openai.com/share/CHAT-UUID

The site sits behind Cloudflare's CDN, which caches responses before they reach the web server. The previous year, Nagli had found a web cache deception vulnerability in ChatGPT that leaked users' auth tokens and led to account takeover. OpenAI notified users and patched the bug. This write-up describes a second, related issue: a "wildcard" cache deception built on a path traversal URL parser confusion, which again allowed an attacker to steal auth tokens and take over accounts.

The author assumes familiarity with the basics of web cache deception and points readers to Nagli's write-up for a refresher. The technique also builds on a similar concept from a web cache poisoning bug the author had found in Glassdoor, which allowed caching of "un-cacheable" files and endpoints. It is not exactly the same technique, but it shows the potential of URL parser confusions, particularly path traversals, to open new doors for cache vulnerabilities.

Setup

The work was done by interacting with the share feature in a browser and inspecting responses in the developer tools network tab. The attack relies on a victim visiting the crafted URL so that their response is cached and can later be retrieved by the attacker.

Finding it

While playing with the share feature, the author noticed that shared chat links would not update as the conversation with ChatGPT continued. Having dealt with bugs like this before, the first thought was a caching issue: the shared chat was cached and would not update until the cache entry expired.

Opening the network tab to check the response headers confirmed it: the response carried the header Cf-Cache-Status: HIT. That was interesting because the resource was not a static file. The URL had no static extension:

Text
https://chat.openai.com/share/CHAT-UUID

This suggested a cache rule based not on the file extension but on the location in the URL's path. To test that, the author requested a path that does not exist:

Text
https://chat.openai.com/share/random-path-that-does-not-exist

It was cached as well. The cache rule evidently looked something like:

Text
/share/*

So practically anything under the /share/ path gets cached. The author flags this as a red flag (or a green flag, depending on how you look at it): relaxed cache rules can be very dangerous, especially combined with URL parser confusions.

Exploitation

Step 1: Understand the double parsing

On a site that uses caching, a request must pass through the CDN before it reaches the web server, so the URL is parsed twice. That makes a URL parser confusion possible. In ChatGPT's case, the two servers parsed URL encoded forward slashes differently: Cloudflare's CDN did not decode and did not normalise a URL encoded path traversal, while the web server did. A URL encoded path traversal therefore lets an attacker cache any file from the server, including the highest impact API endpoints that contain authorization tokens.

Step 2: Craft the payload

The example payload is:

Text
https://chat.openai.com/share/%2F..%2Fapi/auth/session?cachebuster=123

Here %2F decodes to /, and /api/auth/session is a sensitive API endpoint that contains the user's auth token. Breaking the payload down:

  1. The CDN caches anything under /share/.
  2. The CDN does not decode or normalise %2F..%2F, so the response will be cached.
  3. When the CDN forwards the URL, the web server does decode and normalise %2F..%2F and responds with /api/auth/session, which contains the auth token.

Step 3: Cache the victim's token and retrieve it

When the victim visits the crafted URL, their auth token is cached. When the attacker later visits the same URL, they see the victim's cached auth token. The author drew a sketch to visualise the flow:

From the original on nokline.github.io

With the auth token in hand, the attacker can take over the account, view chats, billing information and more.

In one sentence: a URL encoded path traversal was used to cache sensitive API endpoints, thanks to a path normalization inconsistency between the CDN and the web server. The author notes this was probably the quickest find in their bug bounty experience, one of the more interesting ones, and their biggest bounty so far at $6500.

Root cause

The cache rule matches on the URL path prefix /share/* rather than on file extensions, so any path under /share/ is treated as cacheable. The CDN does not decode or normalise the URL encoded traversal sequence %2F..%2F, so it still sees a path under /share/ and caches the response. The web server, receiving the same URL, decodes and normalizes it into a traversal out of /share/ and serves the sensitive endpoint /api/auth/session. The mismatch between the two parsers is what turns a relaxed cache rule into a token leak.

Impact

An attacker who gets a logged-in victim to visit the crafted URL can have that victim's auth token cached and then read it by requesting the same URL. With the token, the attacker can take over the account and view chats, billing information and more. The attack requires the victim to visit the crafted link while authenticated; the report does not describe any other preconditions.

Fix

The report does not describe the specific fix that was applied. Based on the root cause, the relevant changes would be to make the CDN and the web server agree on URL decoding and normalization, and to avoid caching authenticated API responses under a path prefix rule such as /share/*.

Variants to test

  1. Prefix-based cache rules: request a non-existent path under a cacheable prefix and check for Cf-Cache-Status: HIT. A positive result is a cache hit on a path that does not correspond to a static file.
  2. Encoded traversal under the cacheable prefix: request %2F..%2F followed by a sensitive endpoint, with a cachebuster query parameter, and compare the CDN's view with the origin's response. A positive result is a cached response containing data from the endpoint outside the prefix.
  3. Other encodings of the separator and dot segments: try encoded backslashes, double encoding and mixed encodings of / and . in the traversal. A positive result is a cache hit whose body comes from a different path.
  4. Sensitive endpoints as the traversal target: point the traversal at endpoints that return auth tokens or session data. A positive result is a cached body containing another user's token.
  5. Cache rule scope: test other prefixes that behave like /share/* to see whether the same relaxation exists elsewhere. A positive result is any prefix where arbitrary sub-paths are cached.

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. 10 min read.

What happened, in plain words

ChatGPT has a feature called "share": you can take a conversation you had with the chatbot and give other people a link they can open to read it. The link looks like this:

Text
https://chat.openai.com/share/CHAT-UUID

chat.openai.com is the address of ChatGPT's website. CHAT-UUID is a long random identifier that stands for one particular shared conversation, the way a ticket number stands for one particular booking. When you open a link like that, the site shows you the conversation that belongs to that identifier.

A website like this is not one single computer. In front of the actual application server sits a CDN (content delivery network), a network of servers run by a company (here Cloudflare) that sits between visitors and the site. One of the things a CDN does is caching: it keeps a copy of a response it has already produced, so that the next person asking for the same thing gets the stored copy quickly instead of making the application work again. Think of it like a photocopy kept at the front desk: the first visitor gets the original, later visitors get the photocopy, and the original is only fetched again once the photocopy is thrown away (the cache entry "expires").

The year before, another researcher, Nagli, had found a bug in ChatGPT called web cache deception. The idea of that class of bug is simple: trick the cache into storing a page that contains a logged-in user's private data, then fetch that stored copy yourself. Nagli's bug leaked users' auth tokens and allowed account takeover. An auth token is a long secret string that the site gives your browser after you log in; your browser sends it with every request so the site knows who you are, roughly like a wristband at an event: whoever wears it is treated as you. Account takeover means someone else ends up in control of your account. OpenAI told users about the bug and fixed it.

This write-up is about a second, related bug: a "wildcard" cache deception built on a path traversal URL parser confusion, which again let an attacker steal auth tokens and take over accounts. The author assumes you already know the basics of web cache deception and recommends reading Nagli's write-up first. The technique also builds on a similar idea from a cache poisoning bug the author had found in Glassdoor, which allowed caching of files and endpoints that were supposed to be "un-cacheable". It is not exactly the same technique, but it shows how much potential URL parser confusions, especially path traversals, have for opening new doors in cache vulnerabilities.

Setup

Everything was done by using the share feature in a normal browser and looking at responses in the developer tools network tab. The network tab is a panel in the browser (usually opened with F12) that lists every request the page makes and lets you read the response headers, the small pieces of information the server sends alongside the page.

The attack relies on a victim visiting a crafted URL so that their response gets cached and the attacker can later retrieve it.

Finding it

While playing with the share feature, the author noticed that shared chat links would not update as the conversation with ChatGPT continued. Having dealt with bugs like this before, the first thought was a caching issue: the shared chat was cached and would not update until the cache entry expired.

To check, the author opened the network tab and looked at the response headers. The response carried the header Cf-Cache-Status: HIT. Cf- is the prefix Cloudflare uses for its own headers, and HIT means "this response came from the cache, not from the application". That was interesting, because the resource was not a static file: a static file is something like an image or a style sheet that never changes, and caches are usually set up to store those. The URL had no static extension:

Text
https://chat.openai.com/share/CHAT-UUID

There is no .jpg or .css at the end, just a path under /share/. This suggested that the cache rule was based not on the file extension but on the location in the URL's path. A cache rule is the instruction that tells the CDN what it is allowed to store; "anything whose path starts with /share/" would be such a rule.

To test that, the author requested a path that does not exist:

Text
https://chat.openai.com/share/random-path-that-does-not-exist

If the cache only stored real shared chats, a made-up path should not be stored. It was cached as well. So the cache rule evidently looked something like:

Text
/share/*

The * is a wildcard meaning "anything after this". In plain words: practically anything under the /share/ path gets cached. The author flags this as a red flag (or a green flag, depending on how you look at it): relaxed cache rules can be very dangerous, especially combined with URL parser confusions.

Exploitation

Step 1: Understand the double parsing

On a site that uses caching, a request must pass through the CDN before it reaches the web server, so the URL is read twice: once by the CDN and once by the application. Each of those programs has its own URL parser, the piece of software that takes the text of a URL and works out which path it points to. Two parsers can disagree about what the same text means, and that disagreement is a URL parser confusion.

In ChatGPT's case, the two servers parsed URL encoded forward slashes differently. URL encoding is the way special characters are written in a URL so they cannot be confused with the URL's own punctuation: a slash / can be written as %2F. Decoding is turning %2F back into /. Normalising is tidying a path up into its simplest form, so that a/../b becomes b, because .. means "go up one folder".

Cloudflare's CDN did not decode and did not normalise a URL encoded path traversal, while the web server did. A path traversal is a path that uses .. to climb out of the folder it started in, like writing ../ in a file manager to go up a directory. Because the two sides disagree, a URL encoded path traversal lets an attacker cache any file from the server, including the highest impact API endpoints that contain authorization tokens.

An API endpoint is a URL that returns data rather than a web page, meant for the site's own front end to call. If the website is a restaurant's dining room, the API is the kitchen window where the staff pick up orders: same building, different purpose, and the dishes that come out can be more sensitive than the menu on the wall.

Step 2: Craft the payload

The example payload is:

Text
https://chat.openai.com/share/%2F..%2Fapi/auth/session?cachebuster=123

Here %2F decodes to /, and /api/auth/session is a sensitive API endpoint that contains the user's auth token. The ?cachebuster=123 part is a query parameter, the extra bit after the question mark that sites use to pass values;

Breaking the payload down:

  1. The CDN caches anything under /share/.
  2. The CDN does not decode or normalise %2F..%2F, so as far as the CDN is concerned the path still starts with /share/, and the response will be cached.
  3. When the CDN forwards the URL, the web server does decode and normalise %2F..%2F and responds with /api/auth/session, which contains the auth token.

In other words, the CDN reads the address as "a page under the share folder" and stores it, while the application reads the same address as "the session endpoint" and answers with the user's secret token. The CDN stores the answer without understanding what it contains.

Step 3: Cache the victim's token and retrieve it

When the victim visits the crafted URL, their auth token is cached. When the attacker later visits the same URL, they see the victim's cached auth token. The author drew a sketch to visualise the flow:

From the original on nokline.github.io

With the auth token in hand, the attacker can take over the account, view chats, billing information and more. The token is the wristband: presenting it is enough to be treated as the victim.

In one sentence: a URL encoded path traversal was used to cache sensitive API endpoints, thanks to a path normalisation inconsistency between the CDN and the web server. The author notes this was probably the quickest find in their bug bounty experience, one of the more interesting ones, and their biggest bounty so far at $6500.

Root cause

The cache rule matches on the URL path prefix /share/* rather than on file extensions, so any path under /share/ is treated as cacheable. The CDN does not decode or normalise the URL encoded traversal sequence %2F..%2F, so it still sees a path under /share/ and caches the response. The web server, receiving the same URL, decodes and normalises it into a traversal out of /share/ and serves the sensitive endpoint /api/auth/session. The mismatch between the two parsers is what turns a relaxed cache rule into a token leak.

Impact

An attacker who gets a logged-in victim to visit the crafted URL can have that victim's auth token cached and then read it by requesting the same URL. With the token, the attacker can take over the account and view chats, billing information and more. The attack requires the victim to visit the crafted link while authenticated; the report does not describe any other preconditions.

Fix

The report does not describe the specific fix that was applied. Based on the root cause, the relevant changes would be to make the CDN and the web server agree on URL decoding and normalisation, and to avoid caching authenticated API responses under a path prefix rule such as /share/*.

Variants to test

If you want to look for the same pattern on other sites, these are the checks to try. Each one is a small experiment with a clear "positive" result.

  1. Prefix-based cache rules: request a non-existent path under a cacheable prefix and check for Cf-Cache-Status: HIT. A positive result is a cache hit on a path that does not correspond to a static file.
  2. Encoded traversal under the cacheable prefix: request %2F..%2F followed by a sensitive endpoint, with a cachebuster query parameter, and compare the CDN's view with the origin's response. A positive result is a cached response containing data from the endpoint outside the prefix.
  3. Other encodings of the separator and dot segments: try encoded backslashes, double encoding and mixed encodings of / and . in the traversal. A positive result is a cache hit whose body comes from a different path.
  4. Sensitive endpoints as the traversal target: point the traversal at endpoints that return auth tokens or session data. A positive result is a cached body containing another user's token.
  5. Cache rule scope: test other prefixes that behave like /share/* to see whether the same relaxation exists elsewhere. A positive result is any prefix where arbitrary sub-paths are cached.

Glossary

  • CDN (content delivery network): a network of servers placed between visitors and a website that stores copies of responses and forwards requests to the real server.
  • Caching: keeping a copy of a response so later requests for the same thing are served from the copy instead of the application.
  • Cache rule: the instruction that decides which URLs a cache is allowed to store, for example "anything under /share/".
  • Cache entry: one stored copy in the cache, identified by its URL.
  • Cache hit: a request answered from the stored copy rather than from the application; Cloudflare marks it with Cf-Cache-Status: HIT.
  • Cachebuster: a made-up query parameter whose only purpose is to give a URL its own distinct cache entry.
  • Web cache deception: a bug where an attacker tricks a cache into storing a logged-in user's private response, then fetches that stored copy.
  • Web cache poisoning: a related bug where an attacker gets malicious content stored in the cache and served to other users.
  • Auth token: a secret string the site gives your browser after login and that your browser sends with each request to prove who you are.
  • Account takeover: an attacker gaining control of another person's account.
  • API endpoint: a URL that returns data rather than a web page, used by the site's own front end.
  • URL parser: the software that reads the text of a URL and decides which path it points to.
  • URL parser confusion: a bug where two programs read the same URL differently.
  • URL encoding: writing special characters in a URL in a safe form, such as %2F for /.
  • Decoding: turning an encoded character such as %2F back into /.
  • Normalising: tidying a path into its simplest form, so a/../b becomes b.
  • Path traversal: a path that uses .. to climb out of the folder it started in.
  • Wildcard: a * in a rule meaning "anything here".
  • Query parameter: the extra name=value part of a URL after the ?.
  • Response header: a small piece of information a server sends alongside a response, such as whether it came from a cache.
  • Static file: a file such as an image or style sheet that does not change per user and is normally cacheable.
  • Developer tools network tab: a browser panel that lists requests and lets you inspect their headers and responses.

More by Harel

View all

1 more disclosed report, best first.

More from OpenAI (ChatGPT)

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Web cache poisoning and deception

The lesson behind this report.

A cache and the origin disagree about a request, so a poisoned response is served to everyone or a private page is stored as public.