Email Address Exposure via Gratipay Migration Tool
The migration tool at /migrate exposed the primary email address of any existing user when an attacker submitted a username that was already taken. An attacker could retrieve any user's email address without authorisation.
- Fixed in 37 hours
- Paid in 37 hours
- Disclosed after 37 hours
Through the /migrate route, an attacker can input the username of any user on the site and retrieve their primary email address without any authorization required.
Steps to reproduce:
Note: This cannot be performed with hackerone-target, because that account seems to return a None as an email.
- Craft and post an HTTP request that fakes step 1 of the migration process through Gratipay, with any email in the
email_addressfield and the target's username in theusernamefield.
POST /migrate?step=2 HTTP/1.1
Host: liberapay.com
Cookie: XXXXXXX
X-CSRF-TOKEN: XXXXXXX
Content-Type: application/x-www-form-urlencoded
[email protected]&username=suprnova
- Examine the HTML of the response.
<form action="" method="POST">
<input type="hidden" name="form.repost" value="true" />
<input type="hidden" name="email_address" value="[email protected]" />
<input type="hidden" name="username" value="suprnova" />
<div class="alert alert-danger">The username '<a href="/Suprnova/">Suprnova</a>' is already taken.</div>
<p>Does this existing account belong to you?</p>
<p class="buttons">
<button class="btn btn-default btn-lg"
name="log-in.id" value="[email protected]"
>Yes</button>
<button class="btn btn-default btn-lg"
name="ignore-conflict" value="true"
>No</button>
</p>
</form>
The value field for log-in.id has been automatically populated with the primary email address of the target.
Vulnerable Code
The problematic code can be found in the file www/migrate.spt:349.
<p class="buttons">
<button class="btn btn-default btn-lg"
name="log-in.id" value="{{ existing_account.email }}"
>{{ _("Yes") }}</button>
<button class="btn btn-default btn-lg"
name="ignore-conflict" value="true"
>{{ _("No") }}</button>
</p>
The website automatically displays the email address of the existing account, despite the current user's lack of authorization to view that information.
Mitigation:
To mitigate this exposure, the value for "log-in.id" could instead refer to the ID number of the account being referred to.
Impact
A malicious attacker could simply identify any user on the site and instantly access their email address from the database to be used elsewhere, regardless of the victim's privacy settings.
Context
Liberapay is a donation platform, and the report concerns its migration tool, reached through the /migrate route. The feature exists so that a user coming from Gratipay can bring their account over. The migration runs in steps, and step 2 is where the incoming user supplies an email address and a username. When the supplied username already belongs to an existing account, the application does not silently fail: it shows a conflict form asking whether the existing account belongs to the person doing the migration, offering a Yes and a No button.
The report describes an Insecure Direct Object Reference: the conflict form is rendered for any username, and it embeds the primary email address of that existing account in the page. No authorisation is required to trigger it.
Setup
The researcher used their own account and session against liberapay.com, with a valid session cookie and CSRF token. The request is a form post to the migration route. The only precondition is that the attacker is logged in well enough to hold a session and a CSRF token; the target is any username on the site.
One limit is stated up front: the test cannot be performed against hackerone-target, because that account appears to return None as an email. So the technique depends on the target account actually having a primary email address stored.
Finding it
The /migrate route accepts a username and, when that username is already taken, renders a conflict form. That form is meant to let the migrating user confirm ownership of the existing account. The problem is that the confirmation button carries the existing account's email address as its value, so the page discloses data the current user has no right to see. The route performs no check that the requester owns the username being submitted.
Exploitation
Step 1: post the migration form with the target's username
The researcher crafts an HTTP request that fakes step 1 of the Gratipay migration, putting any email in email_address and the victim's username in username:
POST /migrate?step=2 HTTP/1.1
Host: liberapay.com
Cookie: XXXXXXX
X-CSRF-TOKEN: XXXXXXX
Content-Type: application/x-www-form-urlencoded
email_address=[redacted]&username=suprnova
The request fakes step 1 of the Gratipay migration. The email_address value can be any email address. The username value is the target. The session cookie and the X-CSRF-TOKEN header are the attacker's own, which is enough because the route performs no check that the requester owns the username..
Step 2: read the email out of the response
The response contains the conflict form. The researcher examines its HTML:
<form action="" method="POST">
<input type="hidden" name="form.repost" value="true" />
<input type="hidden" name="email_address" value="[redacted]" />
<input type="hidden" name="username" value="suprnova" />
<div class="alert alert-danger">The username '<a href="/Suprnova/">Suprnova</a>' is already taken.</div>
<p>Does this existing account belong to you?</p>
<p class="buttons">
<button class="btn btn-default btn-lg"
name="log-in.id" value="[redacted]"
>Yes</button>
<button class="btn btn-default btn-lg"
name="ignore-conflict" value="true"
>No</button>
</p>
</form>
The alert confirms the username is taken. The Yes button, named log-in.id, has its value populated with the primary email address of the existing account. That is the disclosure: the attacker's own email appears in the hidden email_address field, but the victim's email appears in the log-in.id value. The attacker reads it straight from the response body.
Root cause
The vulnerable code is in www/migrate.spt at line 349, in the template that renders the conflict form:
<p class="buttons">
<button class="btn btn-default btn-lg"
name="log-in.id" value="{{ existing_account.email }}"
>{{ _("Yes") }}</button>
<button class="btn btn-default btn-lg"
name="ignore-conflict" value="true"
>{{ _("No") }}</button>
</p>
The template interpolates existing_account.email directly into the button value. The server renders this for whatever username was submitted, without checking that the requester is authorised to view that account's information. The site therefore displays the email address of the existing account despite the current user's lack of authorisation to view it.
Impact
An attacker can identify any user on the site and instantly retrieve that user's primary email address from the database, regardless of the victim's privacy settings. The address can then be used elsewhere. The condition is that the target account has an email stored, since an account returning None yields nothing. The report rates this as medium severity with a CVSS score of 5.3, and the program paid a bounty of 100.00 USD.
Fix
The report proposes a mitigation rather than describing a deployed patch: the value for log-in.id could instead refer to the ID number of the account being referred to. That keeps the conflict flow working while removing the email address from the response.
Variants to test
- Submit other usernames to the same conflict form and check whether any field other than
log-in.idcarries account data. A positive result is any value in the response that belongs to the target rather than the requester. - Try the same pattern on other multi-step import or migration flows, where a conflict with an existing account triggers a confirmation form. A positive result is a form field pre-populated with the existing account's private data.
- Check whether the conflict response differs for accounts with no email stored, as with
hackerone-targethere. A positive result is a different response shape that still leaks another attribute.
Hunting notes
This kind of bug hides in flows that compare an attacker-supplied identifier against existing records and then render a confirmation form. Migration, import, invitation and account-linking features are the usual places, because they must handle the case where the identifier is already taken. During recon, look for routes that accept a username or email and return a form asking whether an existing account belongs to you; that question is the signal that the server has looked up someone else's record. The researcher showed impact by demonstrating that a single request returns the victim's primary email in the response body.
What happened, in plain words
Liberapay is a website where people can receive donations. It used to have a tool that let someone move their account over from another site called Gratipay. That tool lives at a web address ending in /migrate.
The migration happens in steps. In step 2, the person types an email address and a username. If the username they type already belongs to someone else on Liberapay, the site does not just stop. It shows a small form that asks: does this existing account belong to you? There is a Yes button and a No button.
The problem is what the site puts inside that form. The Yes button secretly carries the email address of the existing account. So if you type someone else's username, the site hands you that person's email address in the page it sends back. You do not need to own the account, and you do not need any special permission. You only need to be logged in to your own account.
This kind of mistake has a name: an Insecure Direct Object Reference, or IDOR. The idea is simple. Imagine a hotel reception where you can ask for "the key to room 12" and the receptionist hands it over without checking whether room 12 is yours. The room number is a direct reference to something, and the check that should come with it is missing. Here, the username is the reference, and the check that the requester owns that username is missing.
The product and the feature
Liberapay is a donation platform. The report concerns its migration tool, which you reach through the /migrate route. A route is just a path on a website, the part after the site name, like a corridor in a building that leads to one particular room.
The feature exists so that a user coming from Gratipay can bring their account over. The migration runs in steps. Step 2 is where the incoming user supplies an email address and a username. When the supplied username already belongs to an existing account, the application does not silently fail. It shows a conflict form asking whether the existing account belongs to the person doing the migration, offering a Yes and a No button.
The report describes an IDOR: the conflict form is rendered for any username, and it embeds the primary email address of that existing account in the page. No authorisation is required to trigger it. "Primary email address" means the main email the account uses, the one the site treats as the account's own.
Setting up
The researcher used their own account and session against liberapay.com, with a valid session cookie and CSRF token. Two terms need unpacking here.
A session cookie is a small piece of text your browser stores after you log in. Your browser sends it with every request so the site knows which logged-in person is asking. Think of it as the wristband you get at an event: it proves you are inside, and you show it at every door.
A CSRF token is a secret value the site puts into its forms. When you submit a form, you send the token back, and the site checks it matches. Its purpose is to stop another website from quietly submitting forms on your behalf. Think of it as a numbered ticket that the site issued to you and expects to see again.
The request is a form post to the migration route. The only precondition is that the attacker is logged in well enough to hold a session and a CSRF token. The target can be any username on the site.
One limit is stated up front: the test cannot be performed against hackerone-target, because that account appears to return None as an email. In plain terms, that particular test account has no email value stored, so there is nothing to leak from it. The technique therefore depends on the target account actually having a primary email address stored.
Finding it
The /migrate route accepts a username and, when that username is already taken, renders a conflict form. That form is meant to let the migrating user confirm ownership of the existing account. The problem is that the confirmation button carries the existing account's email address as its value, so the page discloses data the current user has no right to see. The route performs no check that the requester owns the username being submitted.
Exploitation
Step 1: post the migration form with the target's username
The researcher crafts an HTTP request that fakes step 1 of the Gratipay migration, putting any email in email_address and the victim's username in username:
POST /migrate?step=2 HTTP/1.1
Host: liberapay.com
Cookie: XXXXXXX
X-CSRF-TOKEN: XXXXXXX
Content-Type: application/x-www-form-urlencoded
email_address=[redacted]&username=suprnova
Line by line, in plain words:
POST /migrate?step=2 HTTP/1.1is the request line.POSTmeans "I am sending data to the server", as opposed toGET, which means "I want to read a page"./migrateis the route, the migration tool.?step=2is a query parameter, a small piece of information attached to the address, and it moves the migration to the conflict-checking stage.HTTP/1.1is the version of the language the browser and server speak.Host: liberapay.comtells the server which website the request is for. One server can host many sites, so this line says which one.Cookie: XXXXXXXis where the session cookie would go. TheXXXXXXstands in for the real value, which is private. This is the attacker's own wristband, not the victim's.X-CSRF-TOKEN: XXXXXXXis the CSRF token, again with the real value hidden. It is the attacker's own ticket, issued to their own session.Content-Type: application/x-www-form-urlencodedsays how the data below is formatted. It is the ordinary format a web form uses when you press submit: pairs of names and values joined with&.- The blank line separates the headers from the body.
email_address=[redacted]&username=suprnovais the body, the actual data being sent.email_addressis any email the attacker chooses.usernameis the target, the name of the account whose email the attacker wants.
The session cookie and the X-CSRF-TOKEN header are the attacker's own, which is enough because the route performs no check that the requester owns the username.. That is the heart of the bug: the site checks that you are logged in, but not that the username you typed is yours.
Step 2: read the email out of the response
The response contains the conflict form. The researcher examines its HTML. HTML is the language web pages are written in, made of tags in angle brackets that describe elements such as forms, inputs and buttons.
<form action="" method="POST">
<input type="hidden" name="form.repost" value="true" />
<input type="hidden" name="email_address" value="[redacted]" />
<input type="hidden" name="username" value="suprnova" />
<div class="alert alert-danger">The username '<a href="/Suprnova/">Suprnova</a>' is already taken.</div>
<p>Does this existing account belong to you?</p>
<p class="buttons">
<button class="btn btn-default btn-lg"
name="log-in.id" value="[redacted]"
>Yes</button>
<button class="btn btn-default btn-lg"
name="ignore-conflict" value="true"
>No</button>
</p>
</form>
Line by line:
<form action="" method="POST">opens a form.action=""means it will submit back to the same address.method="POST"means the data will be sent in the body of the request, not in the address.- The first
<input type="hidden" ...>is a field the user never sees.name="form.repost"withvalue="true"is a marker telling the site this form is being sent again. - The second hidden input,
name="email_address", carries back the attacker's own email,[redacted]. This is the value the attacker typed in step 1, echoed back. - The third hidden input,
name="username", carries back the username,suprnova. - The
<div class="alert alert-danger">is the red warning box. It says the username is already taken, and it links to the existing account's page at/Suprnova/. The'pieces are just how HTML writes an apostrophe. <p>Does this existing account belong to you?</p>is the question the form is built around.- The first
<button>is the Yes button. Itsnameislog-in.id, and itsvalueis[redacted]. That value is the primary email address of the existing account. This is the leak. - The second
<button>is the No button, namedignore-conflictwith valuetrue, which simply tells the site to skip the conflict.
The alert confirms the username is taken. The Yes button, named log-in.id, has its value populated with the primary email address of the existing account. That is the disclosure: the attacker's own email appears in the hidden email_address field, but the victim's email appears in the log-in.id value. The attacker reads it straight from the response body, the part of the server's reply that contains the page itself.
Root cause
The vulnerable code is in www/migrate.spt at line 349, in the template that renders the conflict form. A template is a file that mixes fixed text with placeholders, and the server fills in the placeholders before sending the page.
<p class="buttons">
<button class="btn btn-default btn-lg"
name="log-in.id" value="{{ existing_account.email }}"
>{{ _("Yes") }}</button>
<button class="btn btn-default btn-lg"
name="ignore-conflict" value="true"
>{{ _("No") }}</button>
</p>
Line by line:
<p class="buttons">opens a paragraph that holds the buttons.- The first
<button>is the Yes button.class="btn btn-default btn-lg"only controls how it looks. name="log-in.id" value="{{ existing_account.email }}"is the important line. The double curly braces{{ ... }}mark a placeholder.existing_account.emailmeans "the email address of the account that already exists with this username". The server replaces the placeholder with that email before sending the page.>{{ _("Yes") }}</button>is the visible label._("Yes")is a translation helper, so the word can appear in the reader's language.- The second
<button>is the No button, namedignore-conflictwith valuetrue.
The template interpolates existing_account.email directly into the button value. The server renders this for whatever username was submitted, without checking that the requester is authorised to view that account's information. The site therefore displays the email address of the existing account despite the current user's lack of authorisation to view it.
Impact
An attacker can identify any user on the site and instantly retrieve that user's primary email address from the database, regardless of the victim's privacy settings. The address can then be used elsewhere. The condition is that the target account has an email stored, since an account returning None yields nothing. The report rates this as medium severity with a CVSS score of 5.3, and the program paid a bounty of 100.00 USD.
CVSS is a standard scoring system for how serious a security flaw is, and 5.3 falls in the medium band. A bounty is a payment a company makes to someone who reports a valid flaw.
Fix
The report proposes a mitigation rather than describing a deployed patch: the value for log-in.id could instead refer to the ID number of the account being referred to. An ID number is an internal label the site uses for an account, and it does not reveal anything private. That keeps the conflict flow working while removing the email address from the response.
Variants to test
- Submit other usernames to the same conflict form and check whether any field other than
log-in.idcarries account data. A positive result is any value in the response that belongs to the target rather than the requester. - Try the same pattern on other multi-step import or migration flows, where a conflict with an existing account triggers a confirmation form. A positive result is a form field pre-populated with the existing account's private data.
- Check whether the conflict response differs for accounts with no email stored, as with
hackerone-targethere. A positive result is a different response shape that still leaks another attribute.
Hunting notes
This kind of bug hides in flows that compare an attacker-supplied identifier against existing records and then render a confirmation form. Migration, import, invitation and account-linking features are the usual places, because they must handle the case where the identifier is already taken. During recon, look for routes that accept a username or email and return a form asking whether an existing account belongs to you. That question is the signal that the server has looked up someone else's record. The researcher showed impact by demonstrating that a single request returns the victim's primary email in the response body.
Glossary
- Route: a path on a website, the part after the site name, that leads to one particular feature.
- Migration tool: a feature that lets a user bring an account over from another service.
- Session cookie: a small piece of text your browser stores after login and sends with each request, so the site knows who is asking.
- CSRF token: a secret value placed in forms and checked on submit, to stop other sites from submitting forms on your behalf.
- HTTP request: the message a browser sends to a server to ask for a page or send data.
- POST: an HTTP method meaning "I am sending data to the server".
- GET: an HTTP method meaning "I want to read a page".
- Query parameter: a small piece of information attached to a web address after a
?. - Header: a line in an HTTP request or response carrying extra information, such as the host or a cookie.
- Body: the part of an HTTP request or response that carries the actual data or page content.
application/x-www-form-urlencoded: the ordinary format a web form uses, pairs of names and values joined with&.- HTML: the language web pages are written in, made of tags in angle brackets.
- Hidden input: a form field the user never sees but that is still sent with the form.
- Template: a file mixing fixed text with placeholders that the server fills in before sending the page.
- Interpolation: the act of replacing a placeholder in a template with a real value.
- IDOR (Insecure Direct Object Reference): a flaw where a request names an object directly, such as a username, and the server hands over its data without checking that the requester is allowed to see it.
- Authorisation: the check that a logged-in person is allowed to do or see a particular thing.
- Primary email address: the main email address an account uses.
- Response body: the part of the server's reply that contains the page itself.
- CVSS: a standard scoring system for how serious a security flaw is.
- Bounty: a payment a company makes to someone who reports a valid security flaw.
- Recon: the exploratory phase of looking around a site to find features worth testing.
- Mitigation: a change that reduces or removes a flaw.