Skip to content
IDOR Write-up Beginner

Spoof an user to create a description of a group in Flickr

The group description endpoint accepted a user_id parameter from the client and trusted it, so a group admin could submit another user's identifier and have the resulting description attributed to that victim. An attacker could therefore post content in a group under another person's name.

Samuel Follow

Published on medium.com

Hi guys, I’m now at San Francisco and I’m very happy because I met with a lot of Hackers at HackerOne h1–415. I am very grateful to have participated.

Samuel, on medium.com

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

Flickr is the target here, reached through the Yahoo bug bounty programme, which the author describes as having a very large scope and as being pleasant to study because of the technology and behaviour of its services. The author had not worked with Flickr before and chose it for this research.

Flickr exposes multiple services, which makes it a good place to cross-test between several accounts, run fraud tests and look for authorisation problems. The feature examined in this write-up is the group section: a user can create a group and then create and edit a group description. Editing that description is done through a call to the Flickr REST API endpoint /services/rest, with the method flickr.groups.addBlast.

Setup

The researcher worked with at least two accounts. The first, referred to as user A, is the administrator of a newly created group and is the account whose session is used for the requests. The second, user B, is the account whose identity is later impersonated.

The captured request shows a Chrome browser on Windows. The setup used an account able to create a group and edit its description, plus another user's ID. The author notes that the ID of another user can be obtained in multiple ways, for example by commenting on a user's photos or by giving likes to photos.

Finding it

After creating a group as user A, the author went on to create a group description.

Group created by user A From the original on medium.com

The screenshot shows the group as created by user A.

Group Description From the original on medium.com

The second screenshot shows the group description that was created.

With the administrator account, the author then modified the description. Doing so generated the following request, which the author captured as the original request:

Several parameters matter in this body. group_id identifies the group being edited. blast carries the text of the description. user_id and viewerNSID both hold the NSID of the acting account, user A. method=flickr.groups.addBlast selects the API method, and csrf carries the anti-CSRF token issued to the session.

The author's reasoning was simple: what would happen if the value of the user_id variable were replaced with the ID of another user? The presence of a user identifier in the body of a request that writes content into a group is exactly the kind of parameter that should be derived from the authenticated session rather than trusted from the client.

Exploitation

Step 1: create a group and a description as user A

The author created a group with user A and then created a group description, which produced the original request shown above. This establishes the baseline: a legitimate administrator editing their own group's description.

Step 2: change user_id to the victim's ID

The author modified the value of user_id to the NSID of user B and changed the description text accordingly, producing the modified request:

In this request, user_id now holds 147120294%40N08, the NSID of user B, while the session cookies, the csrf token and viewerNSID still belong to user A. The description text in blast was also changed to refer to user B. The request was sent with user A's authenticated session.

Step 3: observe the result

The result was that the victim user's account had been spoofed.

Spoof another user From the original on medium.com

The screenshot shows the result: the account of the victim user has been spoofed. The author notes that the ID of another user can be obtained in multiple ways, such as commenting on a user's photos or giving likes to photos.

Root cause

Changing user_id to another user's ID caused the content to be attributed to that user. The session cookies and the csrf token prove who is calling, but the server trusts the client-supplied identifier when attributing the content. This is a classic insecure direct object reference in a write operation: the object being referenced is the author identity, and no check ties it to the caller.

The anti-CSRF token did not help, because the request was made with the attacker's own valid session and a matching token; CSRF protection only proves that the request came from the session owner's browser, not that the identity in the body matches that session. In the modified request viewerNSID still held user A's NSID. Whether the server performs any authorisation check on group membership for the target user is not stated in the report.

Impact

A user could use the name of another user to write content in their group. In the author's words, this affects the confidentiality of the victim user's account: content appears under the victim's identity without their consent. It requires knowing the victim's NSID, which the author says can be obtained in multiple ways, such as commenting on photos or giving likes.

Fix

The report does not describe any fix or the vendor's response.

Variants to test

  1. Other write methods in the same API family: replay a legitimate call with the user_id (or equivalent author field) swapped for another account's NSID. A positive result is content attributed to the other account.
  2. Read methods with a user identifier: substitute another user's ID in calls that return private or semi-private data. A positive result is data belonging to the other account being returned to your session.
  3. Identity fields in other positions: try the same substitution in query strings, JSON bodies and headers, since the check may be missing only where the parameter is parsed differently.
  4. Cross-check parameters: where a request carries both a session-derived viewer identifier and a body-supplied user identifier, change only the latter and see whether the server reconciles them.
  5. Group membership boundaries: attempt the same substitution on groups where the attacker is an administrator but the victim is not a member, and on groups where the victim is a member, to map how far the missing check extends.

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

What happened, in plain words

Flickr is a photo-sharing website. Like most large sites, it has a public front end (the pages you see in your browser) and a hidden back end called an API. An API is a set of addresses a website's own pages talk to in order to fetch or save data. Think of it as the kitchen of a restaurant: you, the customer, only see the dining room, but the waiters carry your order to the kitchen, and the kitchen does the actual work. When you edit something on a web page, your browser quietly sends a message to the kitchen (the API) telling it what to change.

This report is about one of those messages. The researcher, Samuel (@saamux), was testing Flickr through the Yahoo bug bounty programme. A bug bounty programme is a scheme where a company pays or thanks independent researchers for finding security problems and reporting them privately. He had not worked with Flickr before and decided to look at its group feature. A group on Flickr has a written description that its creator can edit.

The researcher had two accounts. We will call them user A and user B. User A created a group and wrote a description for it. When he saved that description, he captured the message the browser sent to Flickr's servers. Looking at that message, he noticed it contained a field naming the user who was writing the description. He asked himself a simple question: what happens if I change that name to somebody else's? He changed it to user B's identifier and sent the message again. The result was that user B's account had been spoofed. That is the whole bug: one user can make content appear to come from another user.

This kind of flaw is called an IDOR, short for Insecure Direct Object Reference. The name sounds technical, but the idea is everyday: imagine a cloakroom where you hand in your coat and get a ticket with a number. If the attendant hands out coats based only on whatever number you say, without checking that the ticket is really yours, you can ask for coat number 42 and walk away with a stranger's coat. An IDOR is the same mistake in software: the program accepts an identifier sent by the user and acts on it without checking that this user is allowed to touch that thing. Here the thing being referenced is not a coat but an identity, the name attached to a piece of content.

Background: the API and the request

Flickr's pages do not save data by themselves. They send requests to an API endpoint, which is a fixed address on a server that accepts a particular kind of message. The endpoint in this report is /services/rest, on the host api.flickr.com. The word REST here just describes a common style of API where each request names an action and carries its data as parameters.

Two more ideas are needed before reading the captured request.

A cookie is a small piece of text that a website stores in your browser after you log in, and that your browser sends back with every later request. It is how the site recognises you from one page to the next, because the web itself has no memory. Think of it as the wristband you get at an event: the staff glance at it to know you are allowed in, without asking for your ID every time. Some of the cookies in the captured request are session cookies, which prove which account is logged in.

A CSRF token (Cross-Site Request Forgery token) is a second, different guard. CSRF is an attack where a malicious page tricks your browser into sending a request to a site where you are logged in, using your cookies without your knowledge. To prevent it, the site gives your browser a random value, the token, and expects it back with any request that changes something. A request coming from a malicious page will not know the token, so it gets rejected. The token in this request is the csrf parameter.

With those two ideas in mind, here is the message the researcher captured when user A saved the group description. He calls it the original request:

This is an HTTP request, the format browsers and servers use to talk to each other. It is written here as one long line, but it has two parts. The first part, up to the blank space, is the head: a list of labels and values describing the message. The second part, after the space, is the body: the actual data being sent.

Line by line, in plain words:

  • POST /services/rest HTTP/1.1 says this is a POST request, the kind used to send data and change something on the server, aimed at the address /services/rest, using version 1.1 of the HTTP protocol.
  • Host: api.flickr.com names the server being contacted.
  • Connection: close asks the server to close the connection after answering.
  • Content-Length: 341 says the body is 341 bytes long, so the server knows where the message ends.
  • Origin: https://www.flickr.com says the request was made by a page from flickr.com. Browsers add this automatically.
  • User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) ... Chrome/64.0.3282.167 ... identifies the browser and operating system that sent the request. It tells us the researcher was working from Chrome on Windows.
  • Content-Type: application/x-www-form-urlencoded; charset=UTF-8 says the body is formatted as a list of name=value pairs joined by &, the same format used when you submit a web form.
  • Accept: */* says the browser will accept any kind of answer.
  • Referer: https://www.flickr.com/groups/3112603@N20/ says which page the request came from: the group's page.
  • Accept-Encoding: gzip, deflate lists the compression formats the browser can handle for the answer.
  • Accept-Language: es-ES,es;q=0.9 says the browser prefers Spanish.
  • Cookie: ... is the long list of cookies the browser holds for Flickr. This is the wristband: it is what tells Flickr which account is logged in. The values here are session data and have been redacted.

Now the body, which is the part that matters for the bug. It is a list of parameters separated by &:

  • group_id=3112603%40N20 identifies the group being edited. The %40 is how the @ character is written when it travels inside a URL, so this reads 3112603@N20.
  • blast=This%20is%20a%20rule%20with%20user%20A is the text of the description. %20 is an encoded space, so it reads This is a rule with user A.
  • user_id=138671920%40N05 is the identifier of the user the content is attributed to. Here it is user A's identifier, written in Flickr's NSID format, which is a short string ending in @N and two digits.
  • extras=gimme_blast asks the server to include the description in its answer.
  • viewerNSID=138671920%40N05 is the identifier of the person viewing, again user A.
  • method=flickr.groups.addBlast names the action being performed: add a description to a group.
  • csrf=1518832271%3Ahfolijlgt08%[redacted] is the anti-CSRF token described above, issued to this session.
  • `[redacted] identifies the application making the call.
  • format=json, hermes=1, hermesClient=1, reqId=f5def5f4 and nojsoncallback=1 are settings about how the answer should be formatted and tracked. They are not relevant to the bug.

Two parameters stand out: user_id and viewerNSID both carry user A's identifier. The first says who the content belongs to; the second says who is looking. The researcher's question was aimed at the first one.

Setting up the test

The researcher needed two things: an account that could create a group and edit its description, and the identifier of a second account. He created a group with user A:

Group created by user A From the original on medium.com

The screenshot shows the group as created by user A.

He then created a description for that group:

Group Description From the original on medium.com

The second screenshot shows the group description that was created.

With the administrator account, he then modified the description. Saving that change is what produced the original request above. This step matters because it gives a baseline: a normal, legitimate action by the person who is allowed to do it. To find out whether a program checks permissions, you first need to see what a permitted action looks like, so you can compare it with a forbidden one.

Changing the identity

The researcher's reasoning was direct: what would happen if the value of the user_id variable were replaced with the ID of another user? A user identifier sitting in the body of a request that writes content is exactly the kind of value a server should not take on trust from the browser. The server already knows who is logged in from the cookies; it should use that, not a field the client can type freely.

He changed user_id to user B's identifier and changed the description text to match, producing this modified request:

Comparing it with the original, only two things changed in the body:

  • user_id now holds 147120294%40N08, which is user B's identifier, in place of user A's 138671920%40N05.
  • blast now reads This%20is%20a%20rule%20with%20user%20B, so the text itself refers to user B.

Everything else stayed the same. The cookies still belong to user A, the csrf token is still the one issued to user A's session, and viewerNSID still holds user A's identifier. The request was sent with user A's logged-in session.

The result

The server accepted the request and wrote the description as if user B had authored it:

Spoof another user From the original on medium.com

The screenshot shows the result: the account of the victim user has been spoofed. Spoofing here means making something appear to come from someone who did not do it, like sending a letter with a false return address.

The researcher notes that another user's identifier is easy to obtain in several ways, for example by commenting on a user's photos or by giving likes to photos. In other words, the value he swapped in is not secret; it is visible in ordinary public activity.

Why it worked

Changing user_id to another user's identifier caused the content to be attributed to that user. The cookies and the csrf token prove who is calling, but the server trusts the identifier supplied by the browser when deciding whose name to attach to the content. That is the IDOR described at the start: the object being referenced is the author's identity, and nothing ties it to the caller.

The anti-CSRF token did not prevent this, and it was never meant to. It was a valid token from the attacker's own session, used with the attacker's own cookies. CSRF protection only proves that a request came from the browser of the person who owns the session; it says nothing about whether the identity written in the body matches that session. In the modified request viewerNSID still held user A's identifier. Whether the server performs any check on whether the named user belongs to the group is not stated in the report.

Impact

A user could use the name of another user to write content in their group. In the author's words, this affects the confidentiality of the victim's account: content appears under the victim's identity without their consent. It requires knowing the victim's identifier, which the author says can be obtained in multiple ways, such as commenting on photos or giving likes.

Fix

The report does not describe a fix or the vendor's response.

Variants to test

If you want to look for similar problems yourself, these are the directions the technical write-up suggests. Each one is the same idea applied in a different place: change an identifier that names a person or a thing, and see whether the server checks it.

  1. Other write methods in the same API family: replay a legitimate call with the user_id (or equivalent author field) swapped for another account's identifier. A positive result is content attributed to the other account.
  2. Read methods with a user identifier: substitute another user's ID in calls that return private or semi-private data. A positive result is data belonging to the other account being returned to your session.
  3. Identity fields in other positions: try the same substitution in query strings, JSON bodies and headers, since the check may be missing only where the parameter is parsed differently.
  4. Cross-check parameters: where a request carries both a session-derived viewer identifier and a body-supplied user identifier, change only the latter and see whether the server reconciles them.
  5. Group membership boundaries: attempt the same substitution on groups where the attacker is an administrator but the victim is not a member, and on groups where the victim is a member, to map how far the missing check extends.

Glossary

  • API: a set of addresses and rules a website's pages use to fetch or save data on its servers, separate from the pages you see.
  • API endpoint: the specific address on a server that accepts a particular kind of request, here /services/rest.
  • API key: a value that identifies which application is making a call to an API.
  • Bug bounty programme: a scheme where a company invites independent researchers to find and report security problems, often with a reward.
  • Cookie: a small piece of text stored in your browser by a website and sent back with later requests, used to recognise you between pages.
  • CSRF (Cross-Site Request Forgery): an attack where a malicious page makes your browser send a request to a site where you are logged in, using your cookies without your knowledge.
  • CSRF token: a random value given to your browser and expected back with requests that change data, so that requests forged by other sites are rejected.
  • HTTP request: the message format browsers and servers use to communicate, made of a head (labels and values) and a body (the data).
  • IDOR (Insecure Direct Object Reference): a flaw where a program acts on an identifier supplied by the user without checking that this user is allowed to touch that object.
  • Impact: the practical harm a vulnerability can cause.
  • JSON: a common text format for structured data, often used in API answers.
  • NSID: Flickr's identifier format for a user or group, a short string ending in @N and two digits.
  • Parameter: a named value sent with a request, written as name=value.
  • POST: the HTTP method used to send data and change something on a server.
  • Referer: a request header saying which page the request came from.
  • REST: a common style of API where each request names an action and carries its data as parameters.
  • Root cause: the underlying mistake in the code that makes a vulnerability possible.
  • Session: the state of being logged in, kept alive by cookies so the site remembers your account between requests.
  • Spoofing: making something appear to come from someone who did not do it.
  • User-Agent: a request header identifying the browser and operating system that sent the request.
  • Vulnerability: a weakness in software that someone can use to make it behave in a way its owners did not intend.
  • Write operation: an action that creates or changes data on a server, as opposed to one that only reads it.

More by Samuel

View all

4 more disclosed reports, best first.

More from Flickr

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Insecure direct object reference (IDOR)

The lesson behind this report.

One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.