Instagram delete media CSRF
A copyright-related endpoint on Instagram deleted a user's media via a GET request without a CSRF token. An attacker could make a logged-in victim open a crafted URL to delete the victim's post or story.
Published on blog.darabi.me
In January 2019, I discovered a CSRF vulnerability in Instagram's copyright workflow that could be abused to delete a victim's own post or story.
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.
Context
Instagram runs a copyright workflow for media that may infringe another person's copyright. When Instagram detects such content, the affected user receives a notification with options related to the copyrighted media, including removing the content or requesting an appeal.
The notification above is what Instagram showed for media that triggered the copyright workflow. The workflow is backed by a set of endpoints, and one of them turned out to perform a destructive action on the user's own media.
| Product | |
|---|---|
| Issue | Cross-Site Request Forgery (CSRF) |
| Impact | Delete a victim's Instagram post or story |
| Reported | January 29, 2019 |
| Fixed | January 30, 2019 |
| Bounty | $3,000 |
Setup
To reach the workflow, I uploaded a video that triggered the copyright detection. To get there, I uploaded a video that triggered the copyright detection, then reviewed the requests and endpoints the workflow used. No special tooling is described in the report; the work was done by inspecting the requests the copyright notification produced.
Finding it
After the upload triggered the workflow, I went through the related requests and endpoints. One of them stood out: a copyright endpoint that deletes the affected media, reachable through a plain GET request. A destructive action behind GET is a red flag on its own, because a GET can be triggered cross-site in many ways (a link, an image tag, a redirect) without the browser applying the protections that apply to other request types. The second question was whether the request carried any anti-CSRF protection. It did not: no CSRF token or equivalent verification mechanism was required.
Exploitation
The vulnerable endpoint follows this pattern:
https://www.instagram.com/media/{MEDIA_ID}/copyright/dismiss_am/
MEDIA_ID is the identifier of the affected media and can reference either a Story ID or a Post ID. Because the deletion happens on a GET with no request verification, an attacker only has to make a logged-in victim open a crafted URL pointing at this endpoint with the victim's media ID. The victim's browser sends the request with the victim's session, and the referenced media is deleted from the victim's account.
Step 1: Trigger the copyright workflow
Upload a video that triggers Instagram's copyright detection so that the copyright notification and its related requests become visible.
Step 2: Identify the deletion endpoint
Among the requests behind the notification, locate the copyright endpoint that deletes the affected media. It is invoked as a GET against:
https://www.instagram.com/media/{MEDIA_ID}/copyright/dismiss_am/
Step 3: Confirm the missing protection
Check that the request carries no CSRF token and no equivalent anti-CSRF mechanism. With that confirmed, the endpoint can be invoked by anyone who can get the authenticated victim to load the URL.
Step 4: Deliver the crafted URL
The attacker supplies the victim's MEDIA_ID (a Story ID or a Post ID) in the URL and gets the victim to open it while authenticated to Instagram. The media referenced by the ID is deleted.
The behaviour worked in both the Instagram web interface and the Android application, so the same trick applied to a victim on either client.
The screenshot above is evidence from the CSRF vulnerability report.
Root cause
The design mistake is a state-changing operation exposed over GET with no CSRF token or equivalent request-verification mechanism. CSRF defences rely on making a request unforgeable by a third-party site, typically a token the attacker cannot read or guess, or on refusing to act on requests that a browser can be made to send cross-site without preflight. Here neither applied: the endpoint accepted a simple GET, so any page or link the victim visited could cause the request to be sent with the victim's cookies, and the server had nothing to check that the request was intentional. The report does not describe the server-side implementation, so the exact reason the check was absent is not stated; the observable fact is that no CSRF token or equivalent protection was required.
Impact
An attacker can cause the referenced media to be deleted from the victim's account by getting the victim to open a crafted URL while logged in. The affected media can be a post or a story, and the behaviour was confirmed on both the Instagram web interface and the Android application. The action is destructive: content the victim previously posted is removed. The attack requires the victim to be authenticated and to open the URL; the report does not describe any further conditions.
Fix
Instagram triaged the report on the same day it was submitted and deployed a permanent fix the following day. The general remedy for this class of issue is to stop performing the deletion on a GET and to require a valid CSRF token, or an equivalent verification mechanism, on the request that performs it.
Variants to test
- Other copyright and moderation endpoints. Enumerate the requests behind copyright notifications, appeals and takedown flows and check whether any state-changing action is reachable by
GET. A positive result is a request that changes or removes content when loaded directly in an authenticated browser, with no token in the URL. - Story and post identifiers. Try the same endpoint pattern with both a Story ID and a Post ID. A positive result is deletion of the referenced media in either case.
- Mobile clients. Repeat the test from the Android application as well as the web interface. A positive result is the same deletion behaviour on both clients, which suggests the server, not the client, is missing the check.
- Token presence but no validation. Where a CSRF token exists, remove it or replace it with an arbitrary value and replay the request. A positive result is the action succeeding without a valid token.
- Method override. Where a
POSTis required, try method-override parameters or headers to see whether the server still accepts the action through a simple request. A positive result is the destructive action completing from a cross-site simple request.
What happened, in plain words
In January 2019, Pouya Darabi found a way to make Instagram delete a victim's own post or story without that person agreeing to it. The trick was simple: Instagram had a web address (a URL) that, when opened in a browser by someone logged in to Instagram, would delete a piece of that person's content. The address did not ask for any proof that the person really wanted the deletion. So an attacker only had to get the victim to open a link, and the content was gone.
This kind of attack has a name: Cross-Site Request Forgery, usually shortened to CSRF. The rest of this article explains what that means, how the researcher found the problem, and how it was fixed.
| Product | |
|---|---|
| Issue | Cross-Site Request Forgery (CSRF) |
| Impact | Delete a victim's Instagram post or story |
| Reported | January 29, 2019 |
| Fixed | January 30, 2019 |
| Bounty | $3,000 |
Background: what the copyright workflow is
Instagram is a social network where people share photos and videos. A post is a piece of content on someone's profile. A story is a piece of content that disappears after a while. Both have an identifier, a kind of serial number, that Instagram uses internally to refer to that exact piece of content.
Instagram also has to deal with copyright. Copyright is the legal right of a person who created something (a song, a video, a photo) to control how it is used. If someone uploads content that may belong to someone else, Instagram wants to tell the uploader and offer choices: remove the content, or ask for a review (an appeal).
To make those choices available, Instagram built a copyright workflow. A workflow is just a sequence of screens and actions that guide a user through a process. Behind every screen and button in a web application there are requests: messages the browser sends to Instagram's servers asking them to do something or return some information.
When Instagram detected content that might infringe copyright, the affected user received a notification with options related to the copyrighted media, including removing the content or requesting an appeal.
The image above shows the notification Instagram displayed for media that triggered the copyright workflow. It is the starting point of the whole story: the researcher needed to see this notification, because the notification is what makes the related requests visible.
Setup: how the researcher got to the right place
To reach the workflow, the researcher uploaded a video that triggered the copyright detection. To get there, the researcher uploaded a video that triggered the copyright detection, then reviewed the requests and endpoints the workflow used.
Why upload a video on purpose? Because the interesting requests only appear when the workflow is active. If you never trigger the copyright notification, you never see the buttons and links that the notification offers, and you never see the requests behind them. Uploading a video that trips the detection is a way of making Instagram show its hand.
No special tooling is described in the report. The work was done by inspecting the requests the copyright notification produced. In a browser, you can see these requests using the developer tools, a panel built into every modern browser that lists the network traffic a page generates. You do not need to understand every detail to follow the rest of this article; the important idea is that a web page is not a single thing but a stream of requests and responses.
Finding it: a delete button that works through a link
After the upload triggered the workflow, the researcher went through the related requests and endpoints. An endpoint is a specific address on a server that performs a specific job, like a counter in a shop: you go to the right counter with the right form and the clerk does one particular thing. In web terms, an endpoint is a URL plus the rules for what it accepts.
One endpoint stood out: a copyright endpoint that deletes the affected media, reachable through a plain GET request.
To understand why that matters, you need to know the two most common request types:
GETis what a browser uses when you click a link or type an address. It is meant for fetching information, like reading a page. It should not change anything on the server.POSTis what a browser uses when you submit a form, for example when you send a message or change a setting. It is meant for actions that change something.
A destructive action behind GET is a red flag on its own, because a GET can be triggered cross-site in many ways: a link, an image tag, a redirect. Cross-site means from a different website than Instagram. When you load a page on some other site, that page can contain an image whose address is actually an Instagram URL. Your browser will happily fetch that image, which means it sends a GET request to Instagram. The other site never needs to read the response; the request itself is the attack.
The second question was whether the request carried any anti-CSRF protection. It did not: no CSRF token or equivalent verification mechanism was required.
A CSRF token is a secret value that Instagram's own pages include in requests that change something. The server checks the value before acting. An attacker on another site cannot read that value, because the browser keeps pages from different sites apart. So a request without the correct token is rejected. It works like a cloakroom ticket: the attendant only hands over the coat if you show the matching ticket. Without a ticket, no coat, no matter how convincingly you ask.
Here, there was no ticket to show and no attendant asking for one. The server simply acted on any request that arrived.
Exploitation: how the attack works
The vulnerable endpoint follows this pattern:
https://www.instagram.com/media/{MEDIA_ID}/copyright/dismiss_am/
Line by line, in plain words:
https://www.instagram.comis Instagram's website. Thehttpspart means the connection is encrypted, so nobody in between can read or change it./media/is the first part of the path, telling Instagram that what follows concerns a piece of media.{MEDIA_ID}is a placeholder. It is not literal text; it stands for the actual identifier of a specific post or story. The curly braces are a convention meaning "put the real value here"./copyright/dismiss_am/is the rest of the path, pointing at the copyright-related action. The name suggests dismissing something, but the effect described in the report is deletion of the affected media.- The trailing slash is part of the address as written.
MEDIA_ID is the identifier of the affected media and can reference either a Story ID or a Post ID. Because the deletion happens on a GET with no request verification, an attacker only has to make a logged-in victim open a crafted URL pointing at this endpoint with the victim's media ID.
Why does being logged in matter? When you log in to a website, the site gives your browser a cookie: a small piece of data the browser stores and sends back with every request to that site. The cookie is how the site recognises you on the next request. It is like a wristband at an event: you show it once at the entrance, and after that the staff let you in and out without asking for your ID again.
When the victim opens the crafted URL, the victim's browser sends the request to Instagram and automatically attaches the victim's cookie. Instagram sees a logged-in user asking for the deletion and performs it. The attacker never sees the cookie and never needs to. The victim's own browser does the work.
The victim's browser sends the request with the victim's session, and the referenced media is deleted from the victim's account. A session is the period during which the site treats you as logged in, tied to that cookie.
Step 1: Trigger the copyright workflow
Upload a video that triggers Instagram's copyright detection so that the copyright notification and its related requests become visible.
This step exists to create the conditions for the test. Without a notification, there is nothing to inspect.
Step 2: Identify the deletion endpoint
Among the requests behind the notification, locate the copyright endpoint that deletes the affected media. It is invoked as a GET against:
https://www.instagram.com/media/{MEDIA_ID}/copyright/dismiss_am/
This step is about finding the exact address that performs the deletion. The researcher looked at the traffic the notification generated and singled out the request whose effect was to remove the media.
Step 3: Confirm the missing protection
Check that the request carries no CSRF token and no equivalent anti-CSRF mechanism. With that confirmed, the endpoint can be invoked by anyone who can get the authenticated victim to load the URL.
This is the decisive check. A request that changes something is only safe from cross-site abuse if the server can tell a genuine request from a forged one. If there is no token and no other check, there is nothing to tell them apart.
Step 4: Deliver the crafted URL
The attacker supplies the victim's MEDIA_ID (a Story ID or a Post ID) in the URL and gets the victim to open it while authenticated to Instagram. The media referenced by the ID is deleted.
The victim clicks, the browser sends the request with the victim's cookie, and the content is removed.
The behaviour worked in both the Instagram web interface and the Android application, so the same trick applied to a victim on either client. A client here means the app or website the person uses to access Instagram.
The screenshot above is evidence from the CSRF vulnerability report.
Root cause: why the design was wrong
The design mistake is a state-changing operation exposed over GET with no CSRF token or equivalent request-verification mechanism. A state-changing operation is any action that alters data on the server, such as deleting, editing or publishing. Fetching a page does not change state; deleting a post does.
CSRF defences rely on making a request unforgeable by a third-party site, typically a token the attacker cannot read or guess, or on refusing to act on requests that a browser can be made to send cross-site without preflight. Preflight is a check some browsers perform before certain cross-site requests, asking the target server whether the request is allowed. Simple requests, including a plain GET, do not trigger it.
Here neither applied: the endpoint accepted a simple GET, so any page or link the victim visited could cause the request to be sent with the victim's cookies, and the server had nothing to check that the request was intentional. The report does not describe the server-side implementation, so the exact reason the check was absent is not stated; the observable fact is that no CSRF token or equivalent protection was required.
Impact: what an attacker could achieve
An attacker can cause the referenced media to be deleted from the victim's account by getting the victim to open a crafted URL while logged in. The affected media can be a post or a story, and the behaviour was confirmed on both the Instagram web interface and the Android application.
The action is destructive: content the victim previously posted is removed. The attack requires the victim to be authenticated and to open the URL; the report does not describe any further conditions.
Fix: what Instagram did
Instagram triaged the report on the same day it was submitted and deployed a permanent fix the following day. Triaged means the security team reviewed the report, confirmed it was a real issue and started handling it.
The general remedy for this class of issue is to stop performing the deletion on a GET and to require a valid CSRF token, or an equivalent verification mechanism, on the request that performs it.
Variants to test: where else to look
If you are learning from this report, these are the follow-up checks a researcher would try on similar features. Each one is a way of asking the same question in a different place: can a request that changes something be sent by a site that should not be able to send it?
- Other copyright and moderation endpoints. Enumerate the requests behind copyright notifications, appeals and takedown flows and check whether any state-changing action is reachable by
GET. A positive result is a request that changes or removes content when loaded directly in an authenticated browser, with no token in the URL. - Story and post identifiers. Try the same endpoint pattern with both a Story ID and a Post ID. A positive result is deletion of the referenced media in either case.
- Mobile clients. Repeat the test from the Android application as well as the web interface. A positive result is the same deletion behaviour on both clients, which suggests the server, not the client, is missing the check.
- Token presence but no validation. Where a CSRF token exists, remove it or replace it with an arbitrary value and replay the request. A positive result is the action succeeding without a valid token.
- Method override. Where a
POSTis required, try method-override parameters or headers to see whether the server still accepts the action through a simple request. A positive result is the destructive action completing from a cross-site simple request.
Disclosure timeline
| Date | Event |
|---|---|
| January 29, 2019 | Vulnerability reported to Instagram. |
| January 29, 2019 | Report triaged. |
| January 30, 2019 | Permanent fix deployed. |
| February 14, 2019 | $3,000 bounty awarded. |
A bounty is a payment a company makes to a researcher who reports a security problem responsibly, instead of exploiting it or selling it.
Glossary
- API: a defined set of addresses and rules that one piece of software uses to ask another to do something; here, the endpoints Instagram's web and mobile clients call.
- Appeal: a request for a review of a decision, in this case a copyright decision.
- Authenticated: recognised by a website as a logged-in user, usually because the browser sent a valid session cookie.
- Bounty: a payment made by a company to a researcher who reports a security issue.
- Browser: the program you use to visit websites, such as Chrome or Firefox.
- Client: the app or website a person uses to access a service; here, the Instagram web interface or the Android application.
- Cookie: a small piece of data a website stores in your browser and that your browser sends back with requests to that site, used to recognise you between requests.
- Copyright: the legal right of a creator to control how their work is used.
- Cross-site: coming from a different website than the one being targeted.
- CSRF (Cross-Site Request Forgery): an attack where a malicious site makes a logged-in victim's browser send a request to another site, causing an action the victim did not intend.
- CSRF token: a secret value included in a request that changes something, which the server checks to confirm the request came from its own pages and not from another site.
- Destructive action: an action that removes or overwrites data, such as deleting a post.
- Developer tools: a panel built into browsers that shows the requests and responses a page generates.
- Endpoint: a specific address on a server that performs a specific job.
GET: the request type a browser uses to fetch something, such as when you click a link; it is not meant to change data on the server.- Identifier (ID): a value that uniquely refers to one item, such as one specific post or story.
- Media: a photo or video, or a post or story containing one.
- Method override: a technique of telling a server to treat one request type as another, for example sending a
POSTthat the server handles as a different method. - Notification: a message shown to a user about something that concerns them, here a copyright warning.
POST: the request type a browser uses when submitting a form, meant for actions that change something.- Preflight: a check some browsers perform before certain cross-site requests, asking the target server whether the request is allowed.
- Request: a message a browser sends to a server asking it to do something or return something.
- Response: the message a server sends back after a request.
- Session: the period during which a website treats you as logged in, tied to a cookie.
- State-changing operation: any action that alters data on a server, such as deleting, editing or publishing.
- Story: a piece of Instagram content that disappears after a while.
- Triage: the step where a security team reviews a report, confirms the issue and starts handling it.
- URL: the address of something on the web, such as a page or an endpoint.
- Workflow: a sequence of screens and actions that guide a user through a process.