Executive brief
YOURLS is a popular URL shortening service that stores HTTP referrer information for analytics. An attacker can inject malicious JavaScript into the referrer data by sending a crafted HTTP header, which is then executed in the browser of administrators or users viewing link statistics. This allows attackers to steal sensitive information like API tokens, modify shortcut destinations, and perform unauthorized actions on behalf of the victim.
Technical details
The vulnerability is a stored cross-site scripting (XSS) flaw in YOURLS' referrer statistics page. The root cause lies in the `yourls_google_array_to_data_table()` function in `includes/functions-infos.php`, which manually concatenates referrer domain names into JavaScript array literals without escaping special characters like single quotes, backslashes, and bracket characters. An unauthenticated attacker can craft a URL with a malicious Referer header (e.g., `x',1],['marker',alert(1)],['z.tld`) which survives the insufficient sanitization in `yourls_sanitize_url_safe()` and gets stored in the database. When an authenticated user views the statistics page for that short URL, the payload breaks out of the JavaScript string context and executes arbitrary code in the victim's browser with full access to the authenticated session, allowing token theft, link manipulation, and CSRF attacks. The attack requires user interaction (clicking the stats page) but no authentication from the attacker. Fix: patched in version 1.10.4 by properly escaping JavaScript string literals.
Affected products
- YOURLS YOURLS >= 1.5.1, <= 1.10.3
Timeline
- 2026-08-01: disclosed
- 2026-08-21: advisory
- 2026-08-21: patched: Fixed in version 1.10.4