Tale of a Misconfiguration in Password Reset
The password reset endpoint for agent accounts returned the reset token directly in the JSON response instead of only sending it by email. An attacker who knew an agent's email address could request a reset, read the token from the response, and use it to set a new password and take over the account.
#### Naveenroy
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
This is a short account of a password reset misconfiguration found in a popular help desk software product. The product supports two kinds of accounts, users and agents, and the password reset flow is exposed through an API endpoint on each team's own subdomain, of the form [team_name].redacted.com.
A password reset normally works like this: the client submits the account's email address, the server generates a reset token, stores it, and emails a link containing that token to the address on file. The token is the secret that authorises the password change, so it should only ever reach the owner of the mailbox. In this case the token came back in the HTTP response to the reset request itself, so anyone who could reach the endpoint could obtain it without access to the mailbox.
Setup
The report does not describe any special tooling. The precondition is simply an existing team name on the hosted service, because the reset endpoint and the reset link are both built on the team subdomain. The researcher notes that the token could be used irrespective of the team name, as long as an existing team name was used in the URL.
Two account types matter here: user accounts and agent accounts. The password reset endpoint for users was not vulnerable; the one for agents was. That difference is central to the finding.
Finding it
The researcher was looking at the password reset functionality and noticed that the response to the reset request contained the reset token. This was not the familiar leak through the Referer header, where a token-bearing URL is sent onward to a third party; the token was in the body of the response to the request itself.
That is wrong because the token is the credential for the reset. If the server returns it to the caller, the email step stops being a check on mailbox ownership and becomes a formality.
Exploitation
Step 1: request a password reset for an agent account
The researcher initiated a password reset for an account and sent the following request:
POST /api/v1/base/password/reset HTTP/1.1Host: [team_name].redacted.comUser-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:46.0) Gecko/20100101 Firefox/46.0Accept: application/json, text/javascript, */*; q=0.01Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflate, brContent-Type: application/x-www-form-urlencoded; charset=UTF-8X-Requested-With: XMLHttpRequestContent-Length: 26Connection: keep-aliveemail=[agent_email_address]
The request targets the team's API path /api/v1/base/password/reset and submits the agent's email address as a form-encoded body parameter, email=[agent_email_address]. The X-Requested-With: XMLHttpRequest header marks it as an AJAX call, and the Accept header asks for JSON.
Step 2: read the token out of the response
The server answered with a success response that included the token:
HTTP/1.1 200 OKServer: nginxDate: Tue, 25 Oct 2016 20:00:29 GMTContent-Type: application/jsonContent-Length: 2194Connection: keep-aliveCache-Control: private, max-age=0, must-revalidateExpires: 0X-API-Version: 1Date-ISO: 2016-10-25T20:00:29+00:00Access-Control-Expose-Headers: Date-ISOX-XSS-Protection: 1; mode=blockX-Content-Type-Options: nosniffDate-ISO: 2016-10-25T20:00:29+00:00Access-Control-Expose-Headers: Date-ISO{ "status": 200, "notifications": [ { "type": "SUCCESS", "message": "Password reset email sent to [Name]", "sticky": false } ], "auth_token": "[token]" }
The JSON body carries a notifications array with a SUCCESS message saying the reset email was sent, and alongside it an auth_token field. That auth_token is the same reset token that would arrive by email on a valid reset request.
Step 3: build the reset link
The password reset link had this format:
https://[team_name].redacted.com/Auth/ResetPassword/[auth_token]
Substituting the auth_token from the response into that URL, and using any existing team name, produced a working reset link for the account.
Step 4: reset the password and log in
Following the link allowed the password of that account to be reset. With the new password the researcher could log in to the account and take full control of it.
Root cause
The reset endpoint returned the secret reset token in its JSON response, in the auth_token field, instead of keeping it server-side and delivering it only through the email. The email notification was still sent, but it was no longer the only channel for the token, so the ownership check it represents was bypassed.
The report does not describe the server-side code, so the precise reason the field was serialised into the response is not stated. What the report does make clear is the inconsistency between account types: the user password reset endpoint was not vulnerable, while the agent endpoint was.
Impact
Anyone able to reach the reset endpoint could request a reset for an agent account, read the token from the response, reset that account's password and log in, taking full control of the account. The researcher describes this as an easy win, but notes that because the software is a help desk product, the impact is critical: the researcher notes that because the software is a help desk product, the impact is critical.
Fix
It says only that the team fixed the issue almost immediately, within two hours of the report. A fix would be to stop returning the reset token in the response body and deliver it solely through the email.
Variants to test
- Compare parallel account types. Where a product has more than one kind of account, such as users and agents here, send the reset request for each type and inspect the full response body for token-like fields. A positive result is a field such as
auth_token,token,reset_tokenorcodein the JSON that matches the value in the emailed link. - Inspect every response to a reset request, not just the email. A positive result is any response that contains the token, whether in the body, in a custom header, or in a redirect
Locationvalue. - Try the token against the reset URL with a different but existing team name. A positive result is a reset page that accepts the token and lets the password be changed.
- Check whether the token is bound to the requesting session or client. A positive result is a token obtained in one context being accepted in another.
- Test the same endpoint with and without the AJAX marker header (
X-Requested-With: XMLHttpRequest) and with differentAcceptvalues. A positive result is the token appearing in one variant but not another, which points to response formatting rather than a missing check.
What happened, in plain words
A security researcher was looking at the password reset feature of a popular help desk software product. Help desk software is the kind of tool a company uses to run its customer support: customers send in questions, and staff answer them from a shared inbox. The product in this story runs on the internet for many companies at once, and each company gets its own address of the form [team_name].redacted.com, where [team_name] is the company's chosen name.
The product has two kinds of accounts: users and agents. Both kinds of account have a password reset feature, which is what you click when you have forgotten your password.
A password reset normally works like this. You type your email address into a form. The server makes a long random secret called a reset token, keeps a copy, and emails you a link that contains that token. When you click the link, the site sees the token, checks it is valid, and lets you choose a new password. The whole point of the email is to prove that you really own the mailbox: only the person who can read the email can get the token.
In this product, the server made the token and emailed it, but it also put the token directly into the reply it sent back to whoever asked for the reset. So anyone who could reach the reset form could ask for a reset for an agent account and read the secret token straight out of the reply, without ever opening the mailbox. With that token they could set a new password, log in as the agent, and take over the account.
The researcher calls this a misconfiguration: the software was set up in a way that exposed something it should have kept private. The fix came within two hours of the report.
Background you need
What an API is
When you use a website, your browser and the server talk to each other. Sometimes the browser asks for a whole page, and the server sends back a page with buttons and text. Other times the browser asks for just data, and the server sends back a short structured answer. That second style of conversation is often called an API (Application Programming Interface). Think of it as the service counter at a shop: you hand over a small request slip, and you get back a small answer slip, rather than the whole shop.
The answer slip in this story is written in JSON, a simple text format for data. A JSON answer looks like a set of labels and values in curly brackets, for example "status": 200. It is easy for a program to read.
What a token is
A token is a long random string that acts like a temporary key. It is not your password; it is a one-time secret that proves you are allowed to do one specific thing. A reset token proves you are allowed to change the password of one specific account. Because it is a secret, it must only reach the person who is supposed to have it.
What a request and a response are
Every time your browser (or a tool) talks to a server, it sends a request and gets back a response. A request has a method (such as POST, meaning "here is some data, please act on it"), a path (which part of the site you are talking to), a host (which site), and some headers, which are extra labels with information about the request. A response has a status code (such as 200 OK, meaning success), its own headers, and a body, which is the actual content.
What the Referer header is, and why the researcher mentions it
When your browser follows a link from one page to another, it often tells the destination page where you came from, using a header called Referer. A common way reset tokens leak is that the token sits in a web address, and that address gets passed on to some other site through Referer. The researcher points out that this was not that kind of leak: the token was in the body of the reply to the reset request itself, which is even more direct.
Finding it
The researcher was testing the password reset feature and noticed that the reply to the reset request contained the reset token. That is wrong because the token is the credential for the reset. If the server hands it back to whoever asked, the email step stops being a check on who owns the mailbox and becomes a formality.
Exploitation
Step 1: request a password reset for an agent account
The researcher started a password reset for an agent account and sent this request:
POST /api/v1/base/password/reset HTTP/1.1Host: [team_name].redacted.comUser-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:46.0) Gecko/20100101 Firefox/46.0Accept: application/json, text/javascript, */*; q=0.01Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflate, brContent-Type: application/x-www-form-urlencoded; charset=UTF-8X-Requested-With: XMLHttpRequestContent-Length: 26Connection: keep-aliveemail=[agent_email_address]
Line by line:
POST /api/v1/base/password/reset HTTP/1.1is the first line.POSTmeans "I am sending data and asking you to act on it"./api/v1/base/password/resetis the path on the server that handles password resets.HTTP/1.1is the version of the web protocol being used.Host: [team_name].redacted.comsays which site the request is for. The[team_name]part is the company's own name on the shared service, so the request goes to that company's copy of the product.User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:46.0) Gecko/20100101 Firefox/46.0tells the server which browser and operating system the sender claims to be. Servers often use this to decide how to format the answer.Accept: application/json, text/javascript, */*; q=0.01says "I would prefer the answer as JSON data".Accept-Language: en-US,en;q=0.5says the sender prefers English.Accept-Encoding: gzip, deflate, brlists the compression formats the sender can handle, so the answer can be sent compactly.Content-Type: application/x-www-form-urlencoded; charset=UTF-8says the data being sent is in the simple form format, the same format a web form uses when you press submit.X-Requested-With: XMLHttpRequestis a marker that says "this request was made by a script inside a page, not by typing a web address". Servers sometimes treat these requests differently.Content-Length: 26says the data part is 26 bytes long.Connection: keep-aliveasks the server to keep the connection open for further requests.email=[agent_email_address]is the actual data being sent: the email address of the agent account whose password is being reset. This is the only piece of information the server needs to start a reset.
Why this step: the researcher wanted to see what the server sends back when a reset is requested. If the server is careful, the reply should say only "we sent an email" and nothing more.
Step 2: read the token out of the response
The server answered with a success response that included the token:
HTTP/1.1 200 OKServer: nginxDate: Tue, 25 Oct 2016 20:00:29 GMTContent-Type: application/jsonContent-Length: 2194Connection: keep-aliveCache-Control: private, max-age=0, must-revalidateExpires: 0X-API-Version: 1Date-ISO: 2016-10-25T20:00:29+00:00Access-Control-Expose-Headers: Date-ISOX-XSS-Protection: 1; mode=blockX-Content-Type-Options: nosniffDate-ISO: 2016-10-25T20:00:29+00:00Access-Control-Expose-Headers: Date-ISO{ "status": 200, "notifications": [ { "type": "SUCCESS", "message": "Password reset email sent to [Name]", "sticky": false } ], "auth_token": "[token]" }
Line by line:
HTTP/1.1 200 OKis the status line.200 OKmeans the request succeeded.Server: nginxsays which web server software is running.nginxis a common web server.Date: Tue, 25 Oct 2016 20:00:29 GMTis the time the answer was produced.Content-Type: application/jsonsays the body is JSON data.Content-Length: 2194says the body is 2194 bytes long.Connection: keep-alivesays the connection can stay open.Cache-Control: private, max-age=0, must-revalidateandExpires: 0tell browsers and caches not to store this answer.X-API-Version: 1says which version of the API answered.Date-ISO: 2016-10-25T20:00:29+00:00is the same time in a different format.Access-Control-Expose-Headers: Date-ISOis a rule about which headers a script on another site is allowed to read.X-XSS-Protection: 1; mode=blockandX-Content-Type-Options: nosniffare safety headers that tell the browser to be careful about how it handles the content.- The body is the JSON data.
"status": 200repeats the success."notifications"is a list of messages for the user, and the one shown has"type": "SUCCESS"and"message": "Password reset email sent to [Name]", which is the normal, harmless part."sticky": falseis a display setting for that message. "auth_token": "[token]"is the problem. This is the secret reset token, the same one that would arrive by email, sitting in the reply for anyone to read.
Why this step: the researcher read the whole reply, not just the friendly message. The friendly message says an email was sent, but the extra field hands over the secret that the email was supposed to protect.
Step 3: build the reset link
The password reset link had this format:
https://[team_name].redacted.com/Auth/ResetPassword/[auth_token]
Line by line:
https://means a secure web connection.[team_name].redacted.comis the company's own address on the shared service./Auth/ResetPassword/is the page that handles the password change.[auth_token]is where the secret token goes.
Why this step: the researcher now had the token from the reply. Putting it into this address produced a working reset link for the account. The researcher notes that the token worked irrespective of the team name, as long as an existing team name was used in the address.
Step 4: reset the password and log in
Following the link allowed the password of that account to be reset. With the new password the researcher could log in to the account and take full control of it.
Why this matters: the researcher never needed access to the agent's mailbox. The email was still sent, but it was no longer the only way to get the token, so the check it represents was bypassed.
Why it happened
The reset endpoint returned the secret reset token in its JSON reply, in the auth_token field, instead of keeping it on the server and delivering it only through the email. The email notification was still sent, but it was no longer the only channel for the token.
The report does not describe the server-side code, so the precise reason the field was included in the reply is not stated. What the report does make clear is the inconsistency between account types: the password reset for users was not vulnerable, while the one for agents was. The report does not explain why only the agent endpoint returned the token.
Impact
Anyone able to reach the reset endpoint could request a reset for an agent account, read the token from the reply, reset that account's password and log in, taking full control of the account. The researcher describes this as an easy win, but notes that because the software is a help desk product, the impact is critical: the researcher notes that because the software is a help desk product, the impact is critical.
Fix
It says only that the team fixed the issue almost immediately, within two hours of the report. A fix would be to stop returning the reset token in the reply body and deliver it solely through the email.
Things to try on other sites
- Compare parallel account types. Where a product has more than one kind of account, such as users and agents here, send the reset request for each type and look through the whole reply for token-like fields. A positive result is a field such as
auth_token,token,reset_tokenorcodein the JSON that matches the value in the emailed link. - Look at every reply to a reset request, not just the email. A positive result is any reply that contains the token, whether in the body, in a custom header, or in a redirect
Locationvalue. - Try the token against the reset address with a different but existing team name. A positive result is a reset page that accepts the token and lets the password be changed.
- Check whether the token is tied to the requesting session or client. A positive result is a token obtained in one context being accepted in another.
- Test the same endpoint with and without the AJAX marker header (
X-Requested-With: XMLHttpRequest) and with differentAcceptvalues. A positive result is the token appearing in one variant but not another, which points to how the reply is formatted rather than a missing check.
Glossary
- API: a way for programs to talk to a service by sending small requests and getting small structured answers, rather than whole web pages.
- Agent: in this product, a support staff account that answers customer questions.
- AJAX: a request made by a script inside a web page rather than by typing a web address; often marked with the
X-Requested-With: XMLHttpRequestheader. - Body: the actual content of a request or response, as opposed to its headers.
- Cache-Control / Expires: headers that tell browsers and caches whether they may store a response.
- Content-Type: a header saying what format the body is in, such as JSON or form data.
- Credential: a secret that proves you are allowed to do something, such as a password or a token.
- Header: an extra label sent with a request or response, carrying information about it.
- Help desk software: a product companies use to run customer support, where customers send questions and staff answer them.
- Host: the part of a request that says which site it is for.
- HTTP: the protocol browsers and servers use to exchange requests and responses.
- JSON: a simple text format for structured data, using labels and values in curly brackets.
- Misconfiguration: a setup mistake that leaves something exposed that should have been kept private.
- nginx: a common web server program.
- Password reset: the feature that lets you set a new password when you have forgotten the old one, usually by proving you can read an email.
- POST: an HTTP method meaning "here is some data, please act on it".
- Referer: a header that tells a site which page you came from; a common way tokens leak when they sit in web addresses.
- Request: the message a browser or tool sends to a server.
- Response: the message a server sends back.
- Session: a short-lived connection between a browser and a server that remembers who you are across several requests.
- Status code: a number in a response saying what happened, such as
200 OKfor success. - Subdomain: a part of a web address in front of the main domain, such as
[team_name]in[team_name].redacted.com. - Token: a long random string that acts as a temporary secret key, proving you are allowed to do one specific thing.
- User: in this product, a customer account that asks for help.
- X-Requested-With: a header that marks a request as coming from a script inside a page.
- X-XSS-Protection / X-Content-Type-Options: safety headers that tell the browser to be careful about how it handles content.