Rust has Critical Stored XSS in Preview Modal, leading to Administrative Account Takeover

Description

Summary

A Stored Cross-Site Scripting (XSS) vulnerability in the RustFS Console allows an attacker to execute arbitrary JavaScript in the context of the management console. By bypassing the PDF preview logic, an attacker can steal administrator credentials from localStorage, leading to full account takeover and system compromise.

Details

The vulnerability exists due to improper validation of the response content type during the file preview process and a lack of origin separation between the S3 object delivery and the management console.

  1. Origin of Credentials: The RustFS Console stores highly sensitive S3 credentials (AccessKey, SecretKey, SessionToken) in the browser's localStorage.
    - File: console/composables/useAuth.ts
    - Evidence: Lines 14 and 18-25 show that credentials are held in useLocalStorage('auth.credentials', {}) and useLocalStorage('auth.permanent', undefined).
  2. Insecure Preview Implementation: In console/components/object/preview-modal.vue, the application identifies a PDF file based on its extension or metadata and renders it using an <iframe>.
  3. Same-Origin Vulnerability: RustFS typically hosts the management console and the S3 API on the same origin (e.g., the same IP and port).
  4. Bypass Attack: An attacker can upload a file named xss.pdf but set its Content-Type metadata to text/html. Because the iframe is hosted on the same origin as the console, the executed script has unrestricted access to the parent window's localStorage.

PoC

<img width="6006" height="3096" alt="CleanShot 2026-02-01 at 18 36 54@2x" src="https://github.com/user-attachments/assets/f2f5dae6-1e19-4133-9a69-f7d8ec604dad" />

This PoC demonstrates how to steal a victim's administrative credentials by tricking them into previewing a malicious file.

1. Create the malicious payload (xss.html):

&lt;script&gt;
  alert(&#x27;XSS Success!\nLocalStorage Data: &#x27; + JSON.stringify(window.parent.localStorage));
&lt;/script&gt;

2. Setup the environment and upload the payload:

# 1. Create a target bucket
mc mb rustfs/my-bucket

# 2. Upload the HTML file as a PDF with HTML content type
mc cp xss.html rustfs/my-bucket/xss.pdf --attr &quot;Content-Type=text/html&quot;

3. Trigger the vulnerability:
1. Login to the RustFS Console as an administrator.
2. Navigate to my-bucket.
3. Click the "Preview" button for the xss.pdf file.
4. The JavaScript executes, demonstrating access to the administrative session data.

Impact

  • Character: Stored Cross-Site Scripting (XSS).
  • Target: System Administrators using the Console.
  • Result: Full Account Takeover (ATO). An attacker gains the victim's AccessKeyId, SecretAccessKey, and SessionToken. This allows the attacker to perform any administrative action, including deleting data, creating backdoors, or downloading the entire filesystem via the S3 API.

Proposed Mitigation

  1. Origin Separation: Implement a dedicated domain for data delivery (e.g., *.data.rustfs.io) that is different from the console domain. This leverages the Same-Origin Policy (SOP) to isolate user-uploaded content.
  2. Security Headers: Implement strict security headers in the backend:
    - Content-Security-Policy (CSP): Disallow inline scripts and restrict script execution.
    - X-Content-Type-Options: nosniff: Prevent browsers from sniffing and executing content that differs from the declared type.

Basic information

Type
reviewed
Severity
critical
Advisory on GitHub
Open advisory ↗
Repository advisory
Open repository advisory ↗
Source code
Browse source ↗
Published (advisory)
2026-02-25 23:00:18 UTC
Updated
2026-02-25 23:00:19 UTC
GitHub reviewed
2026-02-25 23:00:18 UTC
NVD published
2026-02-24

EPSS Score

Score Percentile
0.04% 11.41%

CVSS Scores

Base score Version Severity Vector
9.1 3.1
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:H Click to expand
Attack vector (AV:N)
Could be attacked over the internet or any normal routed network—not just someone sitting at the machine.
Attack complexity (AC:L)
Once they can reach the bug, pulling it off is straightforward—no weird race conditions or rare setup.
Privileges required (PR:L)
A normal user session is enough; they don’t have to be admin.
User interaction (UI:R)
A real person has to do something—click, install, enable—otherwise it doesn’t land.
Scope (S:C)
Breaking this can reach past the original component and bite other resources—bigger blast radius.
Confidentiality (C:H)
Serious risk that confidential data gets exposed in a big way.
Integrity (I:H)
They could widely tamper with or forge data—trust in the data is badly hurt.
Availability (A:H)
Could take the service down hard or make it unusable for people who depend on it.

Identifiers

CWEs

CWE id Name
CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

Credits

  • naoyashiga (reporter)

Affected packages (1)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
rust rustfs < 1.0.0-alpha.83 1.0.0-alpha.83

References

cvelogic Threat Intelligence