How I hacked Instagram to see private photos
Instagram's API endpoints for setting a profile public or private lacked CSRF protections, allowing an attacker to change a victim's privacy settings via a crafted web page. This could make a private profile public, exposing the user's photos and personal information.
insertco.in
Published on insertco.in
In this article, I would like to explain a vulnerability (now properly fixed) discovered months ago on the Instagram’s web and mobile applications.
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
The API endpoints for changing profile privacy did not require any CSRF token or verify the request's origin, and they also did not check the user-agent to ensure requests came from the mobile app.
Impact
An attacker could change any logged-in user's profile from private to public, exposing their photos and personal information; the attack worked on the web application because the API did not enforce user-agent checks.
What the attacker needed
Victim is logged in to Instagram web; victim visits attacker's page; attacker knows the API endpoint
The fix
Instagram fixed it by differentiating mobile and web sessions at login, enabling CSRF tokens for web sessions and user-agent checks plus reCAPTCHA for mobile sessions.
How it was found
- Identify the API endpoint used by the mobile app to set a profile to public.
- Create a simple HTML form that submits a POST request to that endpoint.
- Trick a logged-in victim into submitting the form (e.g., by visiting a malicious page).
- Observe that the victim's profile privacy setting is changed.
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.
When you log into a website, your browser stores a session cookie. If the site doesn't use extra security tokens, another website can make your browser send requests to the site without your knowledge. This is called cross-site request forgery (CSRF). Here, an attacker could trick a logged-in Instagram user into visiting a page that silently changed their profile from private to public, exposing their photos.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.