Skip to content
XSS Disclosed report Intermediate CVE-2023-1421

Reflected XSS in OAuth complete endpoints

The OAuth completion endpoints reflect the redirect_to value taken from the state query parameter into the page without sanitising it. An attacker could craft a link that runs JavaScript in the victim's browser and make requests on the victim's behalf.

zerodivisi0n Follow

Originally disclosed on HackerOne

Bounty$150 Low 3.5 View original
  • Disclosed after 19 months

Summary:

The following endpoints are vulnerable to reflected XSS:

GET /oauth/{service:[A-Za-z0-9]+}/complete
GET /api/v3/oauth/{service:[A-Za-z0-9]+}/complete
GET /signup/{service:[A-Za-z0-9]+}/complete
GET /login/{service:[A-Za-z0-9]+}/complete

The vulnerability exists due to the lack of sanitizing redirect_to field in state query param here.

Steps To Reproduce:

  1. Setup local mattermost instance e.g. on address http://localhost:8065 (server guide, webapp guide)
  2. Enable gitlab auth at Enable gitlab auth at http://localhost:8065/admin_console/authentication/gitlab. (There may be other ways to enable OAuth, this one seemed the easiest to me)
  3. Open the following link: http://mattermost:8065/login/gitlab/complete?code=x&state=eyJhY3Rpb24iOiJtb2JpbGUiLCJyZWRpcmVjdF90byI6InRlc3RcIj48c2NyaXB0PmFsZXJ0KGRvY3VtZW50LmRvbWFpbik8L3NjcmlwdD4ifQ==. This link contains base64-encoded payload in state param: {"action":"mobile","redirect_to":"test\"><script>alert(document.domain)</script>"}
  4. Get javascript alert with current domain.

Impact

An attacker can distribute a link in a chat with malicious javascript code. This code can send ajax requests on behalf of the user.

The original report as published on HackerOne, by zerodivisi0n. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

Likely the redirect_to value decoded from the state parameter is written into the response without output encoding or validation.

Impact

An attacker could send a link in a chat that runs JavaScript in the victim's browser, which could then send requests on the victim's behalf.

What the attacker needed

A Mattermost instance with an OAuth provider enabled; victim clicks a crafted link

How it was found

  1. Set up a local Mattermost instance.
  2. Enable GitLab authentication in the admin console.
  3. Open a login completion link whose state parameter carries a crafted redirect_to value.
  4. Observe the JavaScript alert showing the current domain.

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.

When you log in with another service such as GitLab, the site passes a small piece of data called state back and forth to remember where to send you afterwards. This report shows that the site put part of that data straight into the web page without cleaning it, so a crafted link could make the page run code written by the attacker. That code runs as the logged-in user and can act on their behalf.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by zerodivisi0n

View all

2 more disclosed reports, best first.

More from Mattermost

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.