Dark Mode
Capec-209 Detail
XSS Using MIME Type Mismatch
Detailed Software Typical Severity: Medium
Parents: 592
Not present
| External ID | Source | Link | Description |
|---|---|---|---|
| CAPEC-209 | capec | https://capec.mitre.org/data/definitions/209.html | |
| CWE-79 | cwe | http://cwe.mitre.org/data/definitions/79.html | |
| CWE-20 | cwe | http://cwe.mitre.org/data/definitions/20.html | |
| CWE-646 | cwe | http://cwe.mitre.org/data/definitions/646.html | |
| REF-78 | reference_from_CAPEC | http://www.owasp.org/index.php/Testing_for_Stored_Cross_site_scripting_(OWASP-DV-002) | OWASP Testing Guide (v4), The Open Web Application Security Project (OWASP) |
Explore
-
Survey the application for stored user-controllable inputs: Using a browser or an automated tool, an adversary follows all public links and actions on a web site. They record all areas that allow a user to upload content through an HTTP POST request. This is typically found in blogs or forums.
| Techniques |
|---|
| Use a spidering tool to follow and record all links and analyze the web pages to file upload features |
| Use a proxy tool to record all links visited during a manual traversal of the web application. |
| Use a browser to manually explore the website and analyze how it is constructed. Many browsers' plugins are available to facilitate the analysis or automate the discovery. |
Experiment
-
Probe identified potential entry points for MIME type mismatch: The adversary uses the entry points gathered in the "Explore" phase as a target list and uploads files with scripting content, but whose MIME type is specified as a file type that cannot execute scripting content. If the application only checks the MIME type of the file, it may let the file through, causing the script to be executed by any user who accesses the file.
-
Store malicious XSS content: Once the adversary has determined which file upload locations are vulnerable to MIME type mismatch, they will upload a malicious script disguised as a non scripting file. The adversary can have many goals, from stealing session IDs, cookies, credentials, and page content from a victim.
| Techniques |
|---|
| Upload a script file with a MIME type of text/plain to a forum and then access the uploaded file to see if the script is executed. If possible, the script displays a unique identifier so the adversary knows for certain it was executed when testing. |
| Techniques |
|---|
| Use a tool such as BeEF to store a hook into the web application. This will alert the adversary when the victim has accessed the content and will give the adversary control over the victim's browser, allowing them access to cookies, user screenshot, user clipboard, and more complex XSS attacks. |
Exploit
-
Get victim to view stored content: In order for the attack to be successful, the victim needs to view the stored malicious content on the webpage.
| Techniques |
|---|
| Send a phishing email to the victim containing a URL that will direct them to the malicious stored content. |
| Simply wait for a victim to view the content. This is viable in situations where content is posted to a popular public forum. |
- The victim must follow a crafted link that references a scripting file that is mis-typed as a non-executable file.
- The victim's browser must detect the true type of a mis-labeled scripting file and invoke the appropriate script interpreter without first performing filtering on the content.
- The adversary must have the ability to source the file of the incorrect MIME type containing a script.
Not present
Not present
- For example, the MIME type text/plain may be used where the actual content is text/javascript or text/html. Since text does not contain scripting instructions, the stated MIME type would indicate that filtering is unnecessary. However, if the target application subsequently determines the file's real type and invokes the appropriate interpreter, scripted content could be invoked.
- In another example, img tags in HTML content could reference a renderable type file instead of an expected image file. The file extension and MIME type can describe an image file, but the file content can be text/javascript or text/html resulting in script execution. If the browser assumes all references in img tags are images, and therefore do not need to be filtered for scripts, this would bypass content filters.