Flickr Stored XSS
A stored cross-site scripting vulnerability existed in the name field of Flickr groups, which was rendered unsafely on an old page. An attacker could execute arbitrary JavaScript in a victim's browser and, by chaining with a CSRF token, delete the victim's account.
Published on keerok.github.io
This is a simple bug but I want to write about it anyway. I found this bug some time ago and the following article is basically my report (literally my report) that I sended to Flickr bug bounty program.
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
Flickr is a photo sharing site, and one of its features lets a user create a Group and give it a name. That group name is stored and later rendered in several places across the application. The report describes a stored cross-site scripting bug in that rendering, reachable through an old set of pages that still carry the .gne extension. According to the author, every path containing .gne appears to belong to an old version of the Flickr pages, and those pages were still served alongside the current site on www.flickr.com.
The bug itself is simple, but the write-up is worth reading because of the impact demonstration: a proof of concept that deletes the victim's account by driving the account deletion flow from inside the XSS.
Setup
No special accounts or roles are described beyond having a Flickr account, which is what lets you create a Group. The only tool mentioned is gau, used to collect known paths for the domain. The author does not state a browser, version or any other environment detail.
The precondition is that the attacker can create a group and set its name, and that a user views the affected page and clicks the button containing it.
Finding it
Using gau, the author collected a large number of paths with the .gne extension. The author notes that all paths containing .gne seem to be an old version of the Flickr pages.
With a Flickr account you can create a Group and set a name on it. For the first tests the author put this payload in the name of the group:
</script><img src=x onerror=alert(1)>
The same payload was also tried in a lot of other parts of the application.

After going through every .gne page that gau had produced, photos_user_map.gne stood out. On that page the author's first reaction was simply to click a button containing the payload. The XSS fired.

Exploitation
Finding the alert was not enough; the author wanted to show real impact, so the goal became deleting the account of a victim. The author notes the PoC is probably not the most beautiful code and that there are likely better ways to do it, but it worked.
Step 1: framing the deletion page
flickr.com sends x-frame-options that only allow same-origin iframes. Because the XSS runs on www.flickr.com, the attacker's JavaScript is same-origin with the target and can therefore iframe /account/delete and read into it.
The script loads /account/delete into an iframe and uses ifr.contentDocument.getElementByTagName to collect all the hrefs on the page. The one that matters is the link carrying the h parameter, which is a CSRF token.
Step 2: following the tokenised link
Once the position of the h parameter href is known, hrefs[i].click() simulates a click that redirects to:
www.flickr.com/account/delete?step=1&h=TOKEN

Step 3: confirming and submitting
On this second step the script marks a checkbox and then clicks the delete button:
ifra.contentDocument.getElementsByName('confirm')[0].click()
ifr.contentDocument.getElementsByName('Submit')[0].click()
The author notes a setTimeout was added because the page needs to load before ifr.contentDocument can be used.
The final PoC is shown in this video:
Root cause
The group name is stored and later rendered by the old photos_user_map.gne page without adequate output encoding, so the payload is interpreted as HTML and JavaScript instead of text. The legacy photos_user_map.gne page rendered the stored group name without adequate output encoding.
The impact chain works because of two design choices that combine badly with the XSS. First, x-frame-options only restricts framing to the same origin, which does nothing against script that already runs on that origin. Second, the account deletion flow is protected by a CSRF token in the h parameter, but the token is readable from the same-origin iframe, so it provides no protection against this attack.
Impact
An attacker who can set a group name can store the payload and have it execute in the browser of any user who views the affected .gne page and clicks the button containing the name. Because the script runs on www.flickr.com, it can read the account deletion page through a same-origin iframe, extract the CSRF token, and complete the deletion flow on the victim's behalf. The demonstrated outcome is full account deletion. The report does not describe other actions taken with the same access.
Fix
The report states that the bug was fixed on April 25th 2022, but does not say what changed. The natural fix is to encode the group name on output in the legacy .gne pages, or to retire those pages; the report does not confirm which was done.
Variants to test
- Enumerate legacy paths with gau or similar tools and look for extensions that suggest an older codebase (
.gnehere). A positive result is a page that renders current user-controlled data, such as a group name, profile field or photo title, inside a script or attribute context. - Store the same payload in every field a user can name (group name, album title, profile display name) and check each page that renders it. A positive result is the payload executing on any page, especially one that is not the page where the value was entered.
- Where an XSS runs on the same origin as sensitive account pages, check whether those pages can be framed and read. A positive result is
contentDocumentaccess to a page containing a CSRF token or a destructive form. - Look for destructive flows protected only by a token that is readable from the same origin. A positive result is a token in a link or form that same-origin script can extract and replay to complete the action.
Timeline
| Date | Event |
|---|---|
| April 7th 2022 | Report submitted |
| April 11th 2022 | First response |
| April 18th 2022 | Rewarded $3263 |
| April 25th 2022 | Bug fixed |
The HackerOne report is at https://hackerone.com/reports/1534636.
What happened, in plain words
Flickr is a website for sharing photos. One of its features lets you create a Group (a kind of shared space for photos) and give that group a name. Flickr saves that name and shows it again in many places on the site.
The researcher found that on one old page, photos_user_map.gne, clicking a button containing the group name triggered the XSS. That meant a group name could contain instructions that a browser treats as code, not as text. When another person opened that page and clicked a button showing the group name, the code ran in their browser. This kind of bug is called stored cross-site scripting, or stored XSS: "stored" because the bad value is saved on the server, and "cross-site scripting" because code written by one user runs in another user's browser.
Finding the pop-up was only the start. The researcher then wrote a small program that, once running inside the victim's browser, opened Flickr's account deletion page, read the secret code that page uses to prove a request is genuine, and completed the deletion on the victim's behalf. Flickr paid a $3263 bounty and fixed the bug.
Background you need
A few ideas come up again and again below, so here they are from zero.
- HTML and JavaScript. A web page is mostly HTML: text with markers (tags) that tell the browser what is a heading, a button, an image and so on. JavaScript is the programming language browsers run to make pages interactive. When a browser sees a
<script>tag, it runs the JavaScript inside it. - XSS (cross-site scripting). If a site takes something a user typed and puts it into a page without escaping it, the browser may treat that text as HTML or JavaScript. Escaping means turning characters like
<into a harmless form so they display as text. Without escaping, an attacker can make the browser run their code as if the site itself had written it. - Stored XSS. The attacker's value is saved on the server (here, a group name) and served to other people later. The victim does not have to click a strange link; visiting the normal page is enough.
- Payload. The piece of text an attacker submits, designed to be interpreted as code by the browser.
- iframe. A page inside a page. One site can load another page into a rectangular frame within itself.
- Same origin. Browsers group pages by origin: the combination of protocol (http or https), host name and port. Pages from the same origin may read each other's content; pages from different origins may not. This rule is what stops one website from reading your bank's pages.
x-frame-options. A response header (extra information a server sends with a page) that tells the browser who is allowed to put that page in an iframe. A value of same-origin means only pages from the same origin may frame it.- CSRF token. A secret, hard-to-guess value that a site puts into a form or link. The server checks it when the form is submitted, to make sure the request came from a page the site itself served, not from some other site. CSRF stands for cross-site request forgery: tricking a logged-in user's browser into sending an unwanted request.
contentDocument. A property in JavaScript that gives a script access to the inside of an iframe, but only if the iframe's page is from the same origin.- gau. A command-line tool that collects known URLs for a domain from public sources. The researcher used it to build a list of paths to look at.
Finding the bug
The researcher started by collecting URLs. Using gau, they found many paths ending in .gne. The author notes that all paths containing .gne seem to be an old version of the Flickr pages.
With a Flickr account you can create a Group and set its name. For the first tests, the researcher put this payload in the group name:
</script><img src=x onerror=alert(1)>
Line by line:
</script>is a closing tag. It only means something if the page has already opened a<script>block; in that case it ends the script early, so whatever follows is no longer treated as JavaScript.<img src=x onerror=alert(1)>inserts an image tag.src=xpoints at an image that does not exist, so loading it fails.onerror=alert(1)is an event handler: when the image fails to load, the browser runs the JavaScriptalert(1), which shows a pop-up box containing the number 1. A pop-up is the classic harmless proof that code ran.
The same payload was also tried in many other parts of the application, not just the group name.

Next, the researcher went through every .gne page that gau had produced. One stood out: photos_user_map.gne. On that page a button contained the payload. The researcher's first reaction was simply to click the button that contained the payload, and the XSS fired.

So the saved group name had survived into the old page and was placed in a spot where the browser read the injected </script> and <img> as real markup instead of plain text.
Turning it into real impact
A pop-up proves code ran, but it does not show what damage is possible. The researcher wanted to demonstrate something serious, so the goal became deleting the victim's account. The researcher notes the proof-of-concept code is probably not the most beautiful and that there are likely better ways to do it, but it worked.
Step 1: loading the deletion page inside the attack
flickr.com sends x-frame-options that only allow same-origin iframes. That sounds like protection, but here it does not help: the XSS runs on www.flickr.com, so the attacker's JavaScript is same-origin with the target. It is allowed to frame /account/delete and to read inside that frame.
The script loads /account/delete into an iframe and uses ifr.contentDocument.getElementByTagName to collect all the links (hrefs) on that page. The one that matters is the link carrying the h parameter, which is a CSRF token.
The script needs that token to continue, and because it is same-origin it can read it straight out of the framed page.
Step 2: following the link that carries the token
Once the position of the h parameter link is known, hrefs[i].click() simulates a click on it. That redirects the frame to:
www.flickr.com/account/delete?step=1&h=TOKEN
Line by line:
www.flickr.com/account/deleteis the account deletion page.?starts the query string, the part of a URL that carries parameters.step=1tells the page which step of the flow to show.&separates parameters.h=TOKENcarries the CSRF token that was just extracted from the link.TOKENstands for the real value the script read.

Step 3: ticking the box and submitting
On this second step the script marks a checkbox and then clicks the delete button:
ifra.contentDocument.getElementsByName('confirm')[0].click()
ifr.contentDocument.getElementsByName('Submit')[0].click()
Line by line:
ifra.contentDocumentreaches inside the iframe, which is allowed because it is same-origin.getElementsByName('confirm')finds every element on that page whose name attribute isconfirm, which is the checkbox the user normally has to tick to agree.[0]takes the first match..click()simulates a click on it, so the box becomes ticked without the victim doing anything.- The second line does the same for the element named
Submit, the button that actually confirms the deletion.
The researcher notes a setTimeout was added because the page needs time to load before ifr.contentDocument can be used. In plain terms: the script waits a moment before reaching into the frame, otherwise it would look too early and find nothing.
The final proof of concept is shown in this video:
The video shows the proof of concept.
Why it worked
The group name is saved and later shown by the old .gne pages without proper output encoding. Encoding means converting special characters so the browser displays them as text. Because that did not happen, a value containing </script><img src=x onerror=alert(1)> was read as HTML and JavaScript instead of text. The legacy photos_user_map.gne page showed the saved value without proper output encoding.
Two design choices made the impact chain possible once the XSS was running:
x-frame-optionsonly restricts framing to the same origin. That does nothing against script that already runs on that origin, because such script counts as same-origin.- The account deletion flow is protected by a CSRF token in the
hparameter, but the token can be read from a same-origin iframe. A token only helps if the attacker cannot read it.
What an attacker could do
Anyone who can set a group name can save the payload, and it will run in the browser of any user who views the affected .gne page and clicks the button containing the name. Because the script runs on www.flickr.com, it can read the account deletion page through a same-origin iframe, pull out the CSRF token, and finish the deletion flow on the victim's behalf. The demonstrated result is full account deletion. The report does not describe other actions taken with the same access.
The fix
The report says the bug was fixed on April 25th 2022 but does not say what changed. The natural fix is to encode the group name on output in the legacy .gne pages, or to retire those pages altogether; the report does not confirm which was done.
Where else to look
- Collect old paths with gau or similar tools and look for extensions that suggest an older codebase (
.gnehere). A good sign is a page that shows current user-controlled data, such as a group name, profile field or photo title, inside a script or an attribute. - Save the same payload in every field a user can name (group name, album title, profile display name) and check each page that shows it. A good sign is the payload running on any page, especially one other than the page where the value was entered.
- Where an XSS runs on the same origin as sensitive account pages, check whether those pages can be framed and read. A good sign is
contentDocumentaccess to a page containing a CSRF token or a destructive form. - Look for destructive flows protected only by a token that is readable from the same origin. A good sign is a token in a link or form that same-origin script can extract and replay to complete the action.
Timeline
| Date | Event |
|---|---|
| April 7th 2022 | Report submitted |
| April 11th 2022 | First response |
| April 18th 2022 | Rewarded $3263 |
| April 25th 2022 | Bug fixed |
The HackerOne report is at https://hackerone.com/reports/1534636.
Glossary
- Bounty: money a company pays a researcher for reporting a security bug responsibly.
- Browser: the program you use to view web pages, such as Firefox or Chrome.
- Checkbox: a small box on a form that you tick to agree to something.
contentDocument: a JavaScript property that gives access to the inside of an iframe, only when the iframe's page is from the same origin.- CSRF (cross-site request forgery): tricking a logged-in user's browser into sending a request the user did not intend.
- CSRF token: a secret value placed in a form or link and checked by the server to confirm the request came from the site itself.
- Encoding (output encoding): converting special characters so the browser shows them as text instead of treating them as markup.
- Event handler: an attribute such as
onerrorthat tells the browser which JavaScript to run when something happens, like an image failing to load. - HTML: the markup language that describes the structure of a web page.
hparameter: the query parameter in the deletion link that carries the CSRF token.- iframe: a page embedded inside another page.
- JavaScript: the programming language browsers run to make pages interactive.
- Origin: the combination of protocol, host name and port that browsers use to decide which pages may read each other.
- Parameter (query parameter): a name and value pair after the
?in a URL, such asstep=1. - Payload: the text an attacker submits, designed to be interpreted as code.
- Proof of concept (PoC): a small demonstration that shows a bug is real and what it can do.
setTimeout: a JavaScript function that runs code after a delay.- Stored XSS: cross-site scripting where the malicious value is saved on the server and served to other users later.
x-frame-options: a response header that tells the browser which pages may put this page in an iframe..gne: the file extension of the old Flickr pages where the bug was found.