XSS via /api/v1/chat.postMessage
A chat message attachment field could contain HTML that was rendered without encoding, so an attacker could send a crafted message that runs script in the recipient's client. The report shows a proof of concept that triggers an alert when the message is viewed.
- Fixed in 5 hours
- Disclosed after 7.3 years
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: An attacker can craft a custom message using the REST API that, once seen by the observer, executes arbitrary code in the context of the client user.
Description: According to the API documentation chat messages can have attachments. These attachments then can have fields which contain a title and subtitle for the attachment. When the attachment has an image_url assigned, the first field's value can be used to inject HTML tags. For example <img onload=""> can be used to execute arbitrary code. < must be the leading character of the field's value property.
Releases Affected:
- Client App (OSX)
- Firefox 48 (Debian)
- Firefox 52 (OSX)
- Chrome 58 (OSX)
Steps To Reproduce (from initial installation to vulnerability):
- Create a Channel or get obtain a RoomId of a private conversation
- Login to the Rest API
- Send crafted message
Supporting Material/References:
# Login to get Auth Token and User Id
curl http://127.0.0.1:3000/api/v1/login -d "username=<USER_NAME>&password=<PASSWORD>"
# Send crafted message
curl -H "X-Auth-Token: <USER_TOKEN>" -H "X-User-Id: <USER_ID>" http://127.0.0.1:3000/api/v1/chat.postMessage -d "channel=<CHANNEL_NAME>&attachments[0][image_url]=/assets/logo&attachments[0][fields][0][title]=&attachments[0][fields][0][value]=<img src=/assets/logo width=1 height=1 onload=alert('XSS4') />You're Pwned!"
Suggested mitigation
- Encode all user inputs to HTML entities
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 attachment field value was inserted into the page without HTML encoding, allowing injected markup to be interpreted by the browser.
Impact
An attacker could execute arbitrary code in the context of a client user who views the crafted message, though the report only demonstrates an alert and does not show theft of data or account takeover.
What the attacker needed
Ability to send a message via the REST API; victim views the crafted message
How it was found
- Create a channel or obtain the room ID of a private conversation.
- Log in to the REST API to get an auth token and user ID.
- Send a crafted message through the chat postMessage endpoint with an attachment field containing HTML.
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 chat attachment field was inserted into the page as raw HTML, so a sender could include a tag that runs JavaScript when the message is viewed.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.