Security Analysis of Mattermost
By Changze Cui & Weihao Dong
1
Security Analysis of Mattermost By Changze Cui & Weihao Dong 1 - - PowerPoint PPT Presentation
Security Analysis of Mattermost By Changze Cui & Weihao Dong 1 What is Mattermost 2 What is Mattermost 3 What is Mattermost 4 Key Difference between Mattermost and Slack Support Self-Hosting yes no Open Source yes no Mattermost
By Changze Cui & Weihao Dong
1
2
3
4
Support Self-Hosting yes no Open Source yes no
5
Mattermost envisions itself as an open source Slack alternative
8
9
Phase3
Acquired and deployed a trial of Enterprise Edition of Mattermost
Phase4
Conducted behavior analysis and source code analysis Network Capture, Static Analysis, Manual Analysis, POC generation
Phase1
Read Documentation Extracted features
Phase2
Came up with Threat Model
10 Notification Service Proxy Email Service
Internet
PC Web Experience
Mobile APP Experience Mobile Web Experience
Email Client https://docs.mattermost.com/deployment/deployment.html
Mattermost Server
HTTPS Secure Web Sockets
Database
(MySQL, Postgres)
File Store
(Amazon S3)
11 Notification Service Proxy Email Service
Internet
PC Web Experience
Mobile APP Experience Mobile Web Experience
Email Client https://docs.mattermost.com/deployment/deployment.html
RESTful API
Mattermost Server
Data Management Scalability Support
HTTPS Secure Web Sockets
Database
(MySQL, Postgres)
Password Hashing Encryption-at-rest
File Store
(Amazon S3)
OAuth2.0
12
Phase3
Acquired and deployed a trial of Enterprise Edition of Mattermost
Phase4
Conducted behavior analysis and source code analysis Network Capture, Static Analysis, Manual Analysis, POC generation
Phase1
Read Documentation Extract features
Phase2
Came up with Threat Model
13 Notification Service Proxy Email Service
Internet
PC Web Experience
Mobile APP Experience Mobile Web Experience
Email Client https://docs.mattermost.com/deployment/deployment.html
RESTful API
Mattermost Server
Data Management Scalability Support
HTTPS Secure Web Sockets
Database
(MySQL, Postgres)
Password Hashing Encryption-at-rest
File Store
(Amazon S3)
OAuth2.0
14 Notification Service Proxy Email Service
Internet
PC Web Experience
Mobile APP Experience Mobile Web Experience
Email Client https://docs.mattermost.com/deployment/deployment.html
RESTful API
Mattermost Server
Data Management Scalability Support
HTTPS Secure Web Sockets
Database
(MySQL, Postgres)
Password Hashing Encryption-at-rest
File Store
(Amazon S3)
OAuth2.0
15 Notification Service Proxy Email Service
Internet
PC Web Experience
Mobile APP Experience Mobile Web Experience
Email Client https://docs.mattermost.com/deployment/deployment.html
RESTful API
Mattermost Server
Data Management Scalability Support
HTTPS Secure Web Sockets
Database
(MySQL, Postgres)
Password Hashing Encryption-at-rest
File Store
(Amazon S3)
OAuth2.0
16 Notification Service Proxy Email Service
Internet
PC Web Experience
Mobile APP Experience Mobile Web Experience
Email Client https://docs.mattermost.com/deployment/deployment.html
RESTful API
Mattermost Server
Data Management Scalability Support
HTTPS Secure Web Sockets
Database
(MySQL, Postgres)
Password Hashing Encryption-at-rest
File Store
(Amazon S3)
OAuth2.0
17
Phase3
Acquired and deployed a trial of Enterprise Edition of Mattermost
Phase4
Conducted behavior analysis and source code analysis Network Capture, Static Analysis, Manual Analysis, POC generation
Phase1
Read Documentation Extract features
Phase2
Came up with Threat Model
18 Notification Service Proxy Email Service
Internet
PC Web Experience
Mobile APP Experience Mobile Web Experience
Email Client https://docs.mattermost.com/deployment/deployment.html
RESTful API
Mattermost Server
Data Management Scalability Support
HTTPS Secure Web Sockets
Database
(MySQL, Postgres)
Password Hashing Encryption-at-rest
File Store
(Amazon S3)
OAuth2.0
1. Credential breach 2. Session token stealing 3. Integrated applications can be compromised
19
Everything is readable. But is it the end of the nightmare?
20
Password
[1] Malvoni, Katja, and Josip Knezovic. “Are your passwords safe: Energy-efficient bcrypt cracking with low-cost parallel hardware.” 8th USENIXWorkshop on Offensive Technologies (WOOT 14). 2014. [2] Biryukov, Alex, Daniel Dinu, and Dmitry Khovratovich. "Argon2: new generation of memory-hard functions for password hashing
and other applications." 2016 IEEE European Symposium on Security and Privacy (EuroS&P). IEEE, 2016.
21
Password
[1] Malvoni, Katja, and Josip Knezovic. “Are your passwords safe: Energy-efficient bcrypt cracking with low-cost parallel hardware.” 8th USENIXWorkshop on Offensive Technologies (WOOT 14). 2014. [2] Biryukov, Alex, Daniel Dinu, and Dmitry Khovratovich. "Argon2: new generation of memory-hard functions for password hashing
and other applications." 2016 IEEE European Symposium on Security and Privacy (EuroS&P). IEEE, 2016.
22
Authentication and Security Services)
23
24
Realtime notification Show TODO list
25
26
27
28
30 Notification Service Proxy Email Service
Internet
PC Web Experience
Mobile APP Experience Mobile Web Experience
Email Client https://docs.mattermost.com/deployment/deployment.html
RESTful API
Mattermost Server
Data Management Scalability Support
HTTPS Secure Web Sockets
Database
(MySQL, Postgres)
Password Hashing Encryption-at-rest
File Store
(Amazon S3)
OAuth2.0
Target
Approach
etc.)
31
A solid step. But what’s next?
32
Session token is stored in cookies
Steal token by XSS attack - document.cookie;
RESTful API of role management
Send <script>XMLHttpRequest.open()</script> to the admin Send [click me](JavAsCripT:alert();) to the admin Token is set to be httponly <> will be escaped to > < URL will be checked before rendered
33
Session token is stored in cookies
Steal token by XSS attack - document.cookie;
RESTful API of role management
Send <script>XMLHttpRequest.open()</script> to the admin Send [click me](JavAsCripT:alert();) to the admin Token is set to be httponly <> will be escaped to > < URL will be checked before rendered
34
Session token is stored in cookies
Steal token by XSS attack - document.cookie;
RESTful API of role management
Send <script>XMLHttpRequest.open()</script> to the admin Send [click me](JavAsCripT:alert();) to the admin Token is set to be httponly <> will be escaped to > <
[click me](javascript:alert();) <a href=javascript:alert();>click me</a>
URL will be checked before rendered
35
Backend sends unescaped text file to user for file preview
Upload a malicious HTML file and trick the admin to preview it
File preview won’t be triggered for a link to the file
Bypass the frontend escape by posting a link to the HTML file Frontend escapes it Content-Disposition in the header is set to attachment
36
Backend sends unescaped text file to user for file preview
Upload a malicious HTML file and trick the admin to preview it
File preview won’t be triggered for a link to the file
Bypass the frontend escape by posting a link to the HTML file Frontend escapes it Content-Disposition in the header is set to attachment
37
Backend sends unescaped text file to user for file preview
Upload a malicious HTML file and trick the admin to preview it
File preview won’t be triggered for a link to the file
Bypass the frontend escape by posting a link to the HTML file Frontend escapes it Content-Disposition in the header is set to attachment
38
Backend sends unescaped text file to user for file preview
Upload a malicious HTML file and trick the admin to preview it
File preview won’t be triggered for a link to the file
Bypass the frontend escape by posting a link to the HTML file Frontend escapes it Content-Disposition in the header is set to attachment
39
content and display User-Agent: Mattermost 5.22
40
twittter.com
Aha! It’s Mattermost making link preview
41
twittter.com
Aha! It’s a normal user, gonna trick him
42
twittter.com
44
50 Notification Service Proxy Email Service
Internet
PC Web Experience
Mobile APP Experience Mobile Web Experience
Email Client https://docs.mattermost.com/deployment/deployment.html
RESTful API
Mattermost Server
Data Management Scalability Support
HTTPS Secure Web Sockets
Database
(MySQL, Postgres)
Password Hashing Encryption-at-rest
File Store
(Amazon S3)
OAuth2.0
51
52
53 https://www.ubisecure.com/uncategorized/difference-between-saml-and-oauth/
and Service Provider
54
Service Provider Identity Provider User
Exchange certificate access service Generate and sign the auth request Redirect user to identity provider along with the auth request User logs in Verify auth request and Redirect user to service provider along with auth response User logs in the service
1 2 3 5 4 7 8
Generate auth response
6
https://developers.onelogin.com/saml/examples/authnrequest 56
https://developers.onelogin.com/saml/examples/response 57
58
Identity Provider 2) Auth request 3) Eavesdropping Mattermost 1) visit 4) Sign the fake Auth Response
59
Hard but possible
60
61
http just for test
62
63
64
65
66
67
Exposed URL Application A Application B
72
admin’s account admin
73
Changze is our new team leader now, please add changze@evil.com to the github repo.
74 Notification Service Proxy Email Service
Internet
PC Web Experience
Mobile APP Experience Mobile Web Experience
Email Client https://docs.mattermost.com/deployment/deployment.html
RESTful API
Mattermost Server
Data Management Scalability Support
HTTPS Secure Web Sockets
Database
(MySQL, Postgres)
Password Hashing Encryption-at-rest
File Store
(Amazon S3)
OAuth2.0
Mattermost Server
271 open source projects in total 49 personal projects
76
77
○ Notification system ○ Client side software ○ Upgrading ○ License Management
78
79