XSS in image with user-controlled src
Canvas used an outdated jQuery version vulnerable to CVE-2015-9251, which executes JavaScript from responses with a JavaScript content type. An attacker could host a malicious image URL that, when loaded in rich content, triggers the broken image handler to fetch the URL via XHR and execute arbitrary JavaScript in victims' browsers.
Originally disclosed on Bugcrowd
- Accepted in 16 days
- Fixed in 23 days
- Disclosed after 3 months
Summary by sesamestrong
Cross-site-scripting vulnerability
I discovered a vulnerability in how Canvas handles broken images, which allows a cross-site-scripting attack on any Rich Content, like a post in a class discussion, a submission for an assignment, a description of an assignment, or an ePortfolio.
This vulnerability, like similar Rich Content Editor-based XSS vulnerabilities, could allow students to change their grades, find quiz answers, take control of their teacher's account, or make a worm that spreads throughout their school system, giving them access to many students' and teachers' accounts.
I noticed that Canvas used an old version of jQuery, which is vulnerable to CVE-2015-9251; this means that when making an XHR, if the server specifies a Content-Type of application/javascript, jQuery will execute whatever JS is in the response.
I found a way to trigger this vulnerability using Canvas' broken image handler, which detects broken images, then makes an XHR via jQuery to the image URL in order to detect the status code.
In order to trigger this, an attacker must set up a web server that checks the Accept header of an incoming request. If the header is for an image, then the server will wait a couple of seconds before throwing a 404. Then, to deliver the JS payload via jQuery, when the Accept header is consistent with an XHR, the server sends a Content-Type of application/javascript and delivers the payload.
Then the attacker inserts an image into the Rich Content Editor with a src pointing to the web server URL, and posts it; whenever a student or teacher sees the post, their browser will run whatever Javascript code the attacker specified.
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 use of an outdated jQuery version (vulnerable to CVE-2015-9251) that automatically executes JavaScript from cross-origin responses with a JavaScript content type, combined with a broken image handler that makes XHR requests to user-supplied image URLs.
Impact
This could allow students to change their grades, find quiz answers, take control of their teacher's account, or create a worm that spreads throughout their school system, giving access to many students' and teachers' accounts.
What the attacker needed
Attacker-controlled web server; ability to post rich content (e.g., discussion, assignment); victim views the malicious post
How it was found
- Set up a web server that checks the Accept header of incoming requests.
- If the Accept header indicates an image, wait a few seconds and then return a 404 response.
- If the Accept header indicates an XHR, respond with a Content-Type of application/javascript and deliver the JavaScript payload.
- Insert an image into the Rich Content Editor with a src pointing to the attacker's web server URL and post it.
- When a student or teacher views the post, their browser runs the attacker's JavaScript.
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.
Canvas, a learning platform, used an old version of a JavaScript library called jQuery. This old version had a known flaw: if a web server responded to a background request with a special content type, jQuery would run the returned code as JavaScript. An attacker could trick Canvas into making such a request by embedding a broken image, leading to malicious code running in other users' browsers.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.