Bypass subscription
The avatar selection endpoint checked the submitted avatar name against a paid-subscription list before trimming whitespace, so a name with a leading space passed the check and was then trimmed to the paid avatar. An attacker could equip a paid avatar without a subscription.
- Triaged in 41 hours
- Fixed in 6 days
- Paid in 4 days
- Disclosed after 36 days
Hello team! You can bypass avatar subscriptions. Thus, without connecting a subscription - it's free.
A list of all avatars is available at the address below, with a GET request:
:method: GET
:authority: api.imgur.com
:scheme: https
:path: /account/v1/accounts/me/avatars?client_id=YOU CLIENT ID
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36
dnt: 1
accept: */*
origin: https://imgur.com
sec-fetch-site: same-site
sec-fetch-mode: cors
sec-fetch-dest: empty
referer: https://imgur.com/
accept-encoding: gzip, deflate, br
accept-language: ru,en-US;q=0.9,en;q=0.8,uk;q=0.7
YOU COOKIE
But the subscription on the site is paid and without this trick it cannot be bypassed. We use " " - space in front of the icon name and get paid icon for free.
Below is the request to send
:method: PATCH
:authority: api.imgur.com
:scheme: https
:path: /account/v1/accounts/me?client_id=YOU CLIENT ID
accept: application/vnd.imgur.v1+json
dnt: 1
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36
content-type: application/vnd.imgur.v1+json
origin: https://imgur.com
sec-fetch-site: same-site
sec-fetch-mode: cors
sec-fetch-dest: empty
referer: https://imgur.com/
accept-encoding: gzip, deflate, br
accept-language: ru,en-US;q=0.9,en;q=0.8,uk;q=0.7
YOU COOKIE
Content-Length: 73
{
"avatar_id": " subscription/spooktober-pumpkin",
"id": YOU ID
}
__Small recommendation __
The point is that you use "TRIM" after checking by name. It turns out TRIM strips the space and it bypasses the check.
I think this information will be useful to you.
Impact
We connect a paid avatar - for free. Thus, we bypass the subscription.
Context
Imgur's account API exposes a set of avatars that a user can attach to their profile. Some of these avatars are part of a paid subscription offering, so selecting one is supposed to require an active subscription. The report describes a way to attach a paid avatar to an account without any subscription, using the account update endpoint on api.imgur.com.
The researcher frames the issue as a business logic error: the server checks the avatar by name, then applies TRIM, so the checked value and the stored value differ.
Setup
The report does not describe any special accounts, roles or tooling beyond an authenticated session. What is needed is:
- A valid Imgur session, represented in the requests by a cookie (shown as
YOU COOKIE). - A client ID for the API, shown as
YOU CLIENT IDin the query string. - The numeric account identifier, shown as
YOU IDin the request body.
The requests were sent with Chrome 86 on Windows, according to the user-agent header, and the API calls originate from https://imgur.com as the origin and referer indicate.
Finding it
The researcher first enumerated the avatars available to the account. A GET request to the avatars endpoint returns the full list, including the paid ones:
:method: GET
:authority: api.imgur.com
:scheme: https
:path: /account/v1/accounts/me/avatars?client_id=YOU CLIENT ID
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36
dnt: 1
accept: */*
origin: https://imgur.com
sec-fetch-site: same-site
sec-fetch-mode: cors
sec-fetch-dest: empty
referer: https://imgur.com/
accept-encoding: gzip, deflate, br
accept-language: ru,en-US;q=0.9,en;q=0.8,uk;q=0.7
YOU COOKIE
The endpoint is /account/v1/accounts/me/avatars, scoped to the current account by the me path segment, with the client ID passed as a query parameter. The response is not reproduced in the report, but the researcher states that the list of all avatars is available there, which is what makes the paid avatar identifiers known in the first place.
The researcher notes that the subscription on the site is paid and, without the trick described below, cannot be bypassed. The trick is a single space character placed in front of the avatar name.
Exploitation
Step 1: send the avatar update with a leading space
The account is updated with a PATCH request to /account/v1/accounts/me, again with the client ID in the query string and the session cookie attached:
:method: PATCH
:authority: api.imgur.com
:scheme: https
:path: /account/v1/accounts/me?client_id=YOU CLIENT ID
accept: application/vnd.imgur.v1+json
dnt: 1
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36
content-type: application/vnd.imgur.v1+json
origin: https://imgur.com
sec-fetch-site: same-site
sec-fetch-mode: cors
sec-fetch-dest: empty
referer: https://imgur.com/
accept-encoding: gzip, deflate, br
accept-language: ru,en-US;q=0.9,en;q=0.8,uk;q=0.7
YOU COOKIE
Content-Length: 73
{
"avatar_id": " subscription/spooktober-pumpkin",
"id": YOU ID
}
The body is JSON with two fields. avatar_id carries the paid avatar identifier subscription/spooktober-pumpkin, prefixed by a single space, so the value is " subscription/spooktober-pumpkin" rather than "subscription/spooktober-pumpkin". The id field carries the account identifier. The request declares application/vnd.imgur.v1+json as both the Content-Type and the accepted response type.
The report does not reproduce the response, only the outcome: the paid avatar is attached to the account for free.
Step 2: understand why it worked
The researcher's own explanation is that the server applies TRIM after checking the avatar by name. The check therefore sees the string with the leading space, and the subsequent TRIM strips it. The subsequent TRIM strips the space, and the stored value becomes the paid avatar identifier. In the researcher's words, TRIM strips the space and it bypasses the check.
Root cause
The validation and the persistence operate on different representations of the same input. The check is made against the untrimmed avatar_id, and TRIM is applied afterwards. In the demonstrated case, the leading space made the value differ at check time and TRIM then stripped it.
This is a canonicalisation ordering problem: normalisation happens after the security decision instead of before it. The report describes no other defence, and the leading space was enough in this case.
Impact
An authenticated user can attach a paid avatar to their own account without holding the subscription that the avatar is meant to require. The researcher summarises the impact as connecting a paid avatar for free and thereby bypassing the subscription. The report does not describe any effect beyond the attacker's own account, and it does not quantify revenue loss or describe abuse at scale.
Fix
The recommendation it gives is to apply TRIM after checking by name, so that the value compared is the same value that will be stored.
Variants to test
- Other whitespace and control characters around a restricted identifier: leading or trailing tabs, newlines, carriage returns, non-breaking spaces and zero-width characters. A positive result is the restricted avatar being stored while the check passes.
- Case variation of the restricted identifier, for example
Subscription/spooktober-pumpkin. A positive result is the avatar being accepted and stored under the canonical casing. - Duplicate or repeated separators inside the identifier, such as a doubled slash. A positive result is the server collapsing the path and storing the restricted avatar.
- The same leading-space technique on other fields of the same
PATCHbody, such asid. A positive result is a value being accepted at check time that differs from what is persisted. - The same technique on other endpoints that accept an identifier from a fixed catalogue, for example themes, badges or profile decorations. A positive result is a paid or privileged item being attached without entitlement.
Hunting notes
This kind of bug lives wherever a catalogue of items is split into free and paid tiers and the client sends an identifier that the server looks up. The signal during recon is an endpoint that accepts a named or path-like identifier (subscription/... in this case) and a separate endpoint that lists the full catalogue, including items the account is not entitled to. If the list endpoint returns paid items to unentitled users, the identifiers are known and only the check needs to be probed.
Testing is cheap: take a restricted identifier from the list, mutate its representation (whitespace, casing, separators), send it through the update endpoint, and then read the account state back to see which value was actually stored. The gap between what the check accepted and what was persisted is the bug.
The researcher states the outcome: a paid avatar attached to an account with no subscription. That is a direct, observable business consequence,
What happened, in plain words
Imgur is a site where people upload and share images. Every account can have a small picture next to its name, called an avatar. Most avatars are free, but some are part of a paid subscription: you are supposed to pay before you can wear them.
The researcher found that this rule could be dodged. By putting one single space character in front of the name of a paid avatar when sending the request that changes your avatar, the server accepted it and saved the paid avatar anyway, without any subscription. The site's own check looked at the name with the space, and the space was only removed afterwards. Later, the server removed the space, and what ended up stored on the account was the real paid avatar.
This kind of flaw is called a business logic error. It is not a broken lock or a leaked password; the program does exactly what it was told, but the rules it enforces ("paid avatars need a subscription") can be stepped around because two parts of the program look at the same input in slightly different ways.
Background you need
A few ideas come up again and again in this report. Here they are from zero.
API. A website like Imgur is really two things: the pages you see in your browser, and a behind-the-scenes service that stores and returns data. That behind-the-scenes service is the API (Application Programming Interface). Think of a restaurant: the dining room is the website, the kitchen is the API, and the waiter carries your order back and forth. When you click something on the page, the page quietly sends a request to the API and shows you the answer.
HTTP request. The message the browser (or a tool) sends to the API. It has a method (a verb saying what you want to do), an address (the path), some headers (extra labels with information), and sometimes a body (the actual data).
Methods. GET means "give me something". PATCH means "change part of something that already exists". So a GET reads, a PATCH writes.
Headers. Little labelled lines attached to a request. For example user-agent says which browser was used, origin and referer say which site the request came from, and content-type says what format the body is in.
Cookie. A small piece of text your browser stores after you log in and sends with every request so the server knows who you are. It works like a wristband at an event: show it at the door and you get in without proving who you are again. In this report the cookie is replaced with YOU COOKIE so the researcher's real login is not published.
Client ID. A public identifier that tells the API which application is calling it. It is not a password; it is more like the name badge of the app. Here it is shown as YOU CLIENT ID.
JSON. A simple text format for data, made of names and values in curly braces, like {"name": "value"}. APIs commonly send and receive JSON.
Endpoint. A specific address on the API that does a specific job, for example /account/v1/accounts/me/avatars for "list my avatars".
TRIM. A common operation in programming that removes spaces (and similar invisible characters) from the beginning and end of a piece of text. " hello" becomes "hello". It is meant for tidying input, not for security.
Canonicalisation. Turning different-looking spellings of the same thing into one standard form. Trimming spaces, lowercasing letters and collapsing doubled slashes are all examples. The danger is when the security check sees one spelling and the storage step uses another.
The setup
The report does not mention any special accounts, roles or tools. All you need is:
- A logged-in Imgur session, which appears in the requests as a cookie (written
YOU COOKIE). - A client ID for the API, written
YOU CLIENT IDin the address. - The numeric identifier of the account, written
YOU IDin the body of the change request.
According to the user-agent header, the requests were made with Chrome 86 on Windows, and they come from https://imgur.com, as the origin and referer headers show.
Step 1: get the list of avatars
The first thing the researcher did was ask the API for every avatar available to the account. This is a normal GET request, the same kind your browser makes when a page loads a list:
:method: GET
:authority: api.imgur.com
:scheme: https
:path: /account/v1/accounts/me/avatars?client_id=YOU CLIENT ID
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36
dnt: 1
accept: */*
origin: https://imgur.com
sec-fetch-site: same-site
sec-fetch-mode: cors
sec-fetch-dest: empty
referer: https://imgur.com/
accept-encoding: gzip, deflate, br
accept-language: ru,en-US;q=0.9,en;q=0.8,uk;q=0.7
YOU COOKIE
Line by line:
:method: GETsays "I only want to read something, I am not changing anything".:authority: api.imgur.comis the server being contacted, Imgur's API server.:scheme: httpsmeans the connection is encrypted.:path: /account/v1/accounts/me/avatars?client_id=YOU CLIENT IDis the address. The part before the?names the resource: the avatars of the account calledme, meaning "whoever is logged in". The part after the?is extra information, here the client ID.user-agenttells the server which browser and operating system were used.dnt: 1is a "do not track" preference sent by the browser.accept: */*says any response format is fine.origin: https://imgur.comsays the request was started by a page on imgur.com.sec-fetch-site,sec-fetch-modeandsec-fetch-destare labels modern browsers add automatically to describe the kind of request.referer: https://imgur.com/says which page the request came from.accept-encodinglists the compression formats the browser can handle, so the answer can be smaller.accept-languagelists the languages the user prefers.YOU COOKIEis the login cookie, the wristband that proves who is asking.
Why do this first? Because to ask for a paid avatar by name, you have to know its exact name. The list returned by this endpoint includes the paid avatars too, so it hands you the identifiers you need. The report does not show the response, but it states that the full list of avatars is available at this address.
The researcher also notes that the subscription on the site is paid and that, without the trick described next, it cannot be bypassed. That is the baseline: normally the paid avatars are out of reach.
Step 2: change the avatar with a space in front of the name
Now the actual change. The account is updated with a PATCH request to /account/v1/accounts/me, again with the client ID in the address and the login cookie attached:
:method: PATCH
:authority: api.imgur.com
:scheme: https
:path: /account/v1/accounts/me?client_id=YOU CLIENT ID
accept: application/vnd.imgur.v1+json
dnt: 1
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36
content-type: application/vnd.imgur.v1+json
origin: https://imgur.com
sec-fetch-site: same-site
sec-fetch-mode: cors
sec-fetch-dest: empty
referer: https://imgur.com/
accept-encoding: gzip, deflate, br
accept-language: ru,en-US;q=0.9,en;q=0.8,uk;q=0.7
YOU COOKIE
Content-Length: 73
{
"avatar_id": " subscription/spooktober-pumpkin",
"id": YOU ID
}
Line by line:
:method: PATCHsays "change part of my account". UnlikeGET, this one writes.:authority,:schemeand:pathare the same server and encryption as before; the address is now the account itself,/account/v1/accounts/me, with the client ID after the?.accept: application/vnd.imgur.v1+jsonsays the answer should come back in Imgur's own JSON format.content-type: application/vnd.imgur.v1+jsonsays the body being sent is in that same format. The server needs to know how to read the body.- The browser and language headers are the same as in the first request.
YOU COOKIEagain proves who is making the change.Content-Length: 73says the body is 73 bytes long, so the server knows how much to read.- The body is JSON with two fields.
avatar_idis the name of the avatar to wear.idis the account identifier.
The important detail is the value of avatar_id: " subscription/spooktober-pumpkin". There is one space between the opening quote and the word subscription. The real paid avatar is called subscription/spooktober-pumpkin; the request sends the same name with a space glued to the front. The subscription/ prefix is a hint that this avatar belongs to the subscription catalogue.
The space is placed in front of the avatar name, and the researcher explains that TRIM is applied after checking by name.
It only states the outcome: the paid avatar ends up attached to the account, for free.
Step 3: why it worked
The researcher's explanation is that the server applies TRIM after checking the avatar by name. So the order of events on the server is:
- The check compares the submitted name, space included, against the paid avatar list. No match, so the request is allowed.
TRIMremoves the leading space.- The cleaned name, now exactly
subscription/spooktober-pumpkin, is saved to the account.
In the researcher's words, TRIM strips the space and it bypasses the check. The check and the save are looking at two different versions of the same text, and only the second one is the real paid avatar.
A everyday comparison: a club has a guest list at the door and a second list at the bar. The door checks names exactly, so " Alice" with a space is not on the list and gets in. At the bar, someone tidies the name to "Alice" and serves the drink reserved for members. The rule existed, but it was applied to the wrong spelling.
The root cause
The validation and the saving work on different representations of the same input. The check is made against the untrimmed avatar_id, and TRIM is applied afterwards. In the demonstrated case, the leading space made the value differ at check time and TRIM then stripped it.
This is a canonicalisation ordering problem: the tidying happens after the security decision instead of before it. The report mentions no other protection, and the single leading space was enough in this case.
Impact
A logged-in user can attach a paid avatar to their own account without holding the subscription that the avatar is supposed to require. The researcher sums it up as connecting a paid avatar for free and thereby bypassing the subscription.
Fix
The recommendation it gives is to apply TRIM after checking by name, so that the value compared is the same value that will be stored.
Variants to test
Once you know the shape of the bug, there are obvious neighbours to try. In each case, a positive result means the restricted avatar is stored while the check passes.
- Other invisible or whitespace characters around a restricted name: leading or trailing tabs, newlines, carriage returns, non-breaking spaces and zero-width characters.
- Different capitalisation of the restricted name, for example
Subscription/spooktober-pumpkin. - Repeated separators inside the name, such as a doubled slash, in case the server collapses the path.
- The same leading-space trick on other fields of the same
PATCHbody, such asid. - The same trick on other endpoints that accept a name from a fixed catalogue, for example themes, badges or profile decorations.
Hunting notes
This kind of bug lives wherever a catalogue of items is split into free and paid tiers and the browser sends a name that the server looks up. During recon, the signal is an endpoint that accepts a named or path-like identifier (subscription/... in this case) plus a separate endpoint that lists the whole catalogue, including items the account is not entitled to. If the list endpoint hands paid items to users who have not paid, the names are known and only the check needs probing.
Testing is cheap: take a restricted name from the list, change its spelling slightly (whitespace, capitalisation, separators), send it through the update endpoint, then read the account state back to see which value was actually stored. The gap between what the check accepted and what was saved is the bug.
The researcher states the outcome: a paid avatar attached to an account with no subscription. That is a direct, visible business consequence,
Glossary
- API: the behind-the-scenes service a website uses to store and return data, separate from the pages you see.
- HTTP request: the message sent to a server asking it to read or change something.
- Method: the verb at the start of a request, such as
GET(read) orPATCH(change part of something). - Endpoint: a specific address on an API that performs a specific job.
- Header: a labelled line of extra information attached to a request, such as
user-agentorcontent-type. - Cookie: a small piece of text stored by the browser after login and sent with requests so the server knows who you are.
- Client ID: a public identifier telling the API which application is calling it; not a secret password.
- JSON: a text format for data made of names and values in curly braces.
- Body: the part of a request that carries actual data, such as the JSON being sent.
Content-Length: a header stating how many bytes long the body is.Content-Type: a header stating what format the body is in.origin/referer: headers saying which site a request came from.user-agent: a header saying which browser and operating system were used.accept: a header saying which response formats the client can handle.accept-encoding: a header listing compression formats the client can handle.accept-language: a header listing the languages the user prefers.dnt: a "do not track" preference sent by the browser.sec-fetch-*: labels modern browsers add automatically to describe the kind of request.- Avatar: the small picture shown next to an account name.
- Subscription: a paid plan that unlocks certain features or items, here including some avatars.
- Business logic error: a flaw where the program runs as written but its rules can be stepped around, rather than a broken lock or leaked secret.
- TRIM: an operation that removes spaces and similar invisible characters from the start and end of text.
- Canonicalisation: turning different spellings of the same thing into one standard form.
- Canonicalisation ordering problem: a bug where tidying happens after the security check instead of before, so the check and the storage see different values.
- Validation: the step where the server decides whether a request is allowed.
- Persistence: saving data so it stays stored, for example writing the chosen avatar to the account.
- CVSS: a standard scoring system for the severity of a security flaw.
- Bounty: a payment some programmes give researchers for valid reports.
- Recon: the early phase of looking around a target to find interesting endpoints and behaviour.