When GPTs Call Home: Exploiting SSRF in ChatGPT’s Custom Action
The custom GPT Actions feature allowed a user-supplied API URL to be fetched by OpenAI's servers, and an attacker could use an HTTPS redirect to reach the internal Azure metadata service. By abusing the authentication settings to add the required metadata header, the attacker could read the metadata response and obtain an Azure management API access token.
Published on infosecwriteups.com
In cybersecurity, you begin to develop a kind of hacker mindset or “sixth sense”. You start seeing the world not just for what it does, but for what it could do.
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the server fetched user-supplied URLs without blocking redirects to internal addresses, and the authentication header feature allowed arbitrary headers to be added to the request.
Impact
An attacker could obtain an Azure management API access token for the GPT's cloud identity, potentially allowing access to the cloud API, though the report does not show what that token could actually do.
What the attacker needed
A ChatGPT Plus account; ability to create a custom GPT; an attacker-controlled HTTPS server
The fix
OpenAI patched the issue almost immediately after it was reported.
How it was found
- Create a custom GPT and add an Action with an API URL pointing to an attacker-controlled HTTPS server.
- Configure that server to respond with a 302 redirect to the internal metadata URL.
- Observe that the GPT follows the redirect and returns the metadata service response.
- Add an API key named Metadata with the value True in the authentication settings to supply the required header.
- Request the metadata identity token endpoint and receive an Azure management API access token.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A custom GPT can be told to call an external API by giving it a web address. The service that runs the GPT then fetches that address from its own servers. The researcher found that by pointing the address at a redirect, the server could be made to fetch an internal cloud address that normal users cannot reach, and then read the secret token returned there.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.