6.9medium
Craft has Reflective XSS via incomplete return URL sanitization
- Severity
- 6.9medium CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.22% (higher than 12% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-fvwq-45qv-xvhv
Description
Craft is a content management system (CMS). The fix for CVE-2025-35939 in craftcms/cms introduced a strip_tags() call in src/web/User.php to sanitize return URLs before they are stored in the session. However, strip_tags() only removes HTML tags (angle brackets) -- it does not inspect or filter URL schemes. Payloads like javascript:alert(document.cookie) contain no HTML tags and pass through strip_tags() completely unmodified, enabling reflected XSS when the return URL is rendered in an href attribute. This vulnerability is fixed in 5.9.7 and 4.17.3.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| craftcms cms | >= 4.15.3, < 4.17.3, >= 5.7.5, < 5.9.7 | CVE List |
| craftcms/cms (Packagist) | from 4.15.3 before 4.17.3, from 5.7.5 before 5.9.7 | GitHub Advisory Database |
| craftcms craft_cms | from 4.15.3 before 4.17.3, from 5.7.5 before 5.9.7 | NVD |
All scores
| GitHub_M | 6.9medium CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N |
| GitHub | medium CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N |
| NVD | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
Classification
What each source says
CVE List
Craft is a content management system (CMS). The fix for CVE-2025-35939 in craftcms/cms introduced a strip_tags() call in src/web/User.php to sanitize return URLs before they are stored in the session. However, strip_tags() only removes HTML tags (angle brackets) -- it does not inspect or filter URL schemes. Payloads like javascript:alert(document.cookie) contain no HTML tags and pass through strip_tags() completely unmodified, enabling reflected XSS when the return URL is rendered in an href attribute. This vulnerability is fixed in 5.9.7 and 4.17.3.
GitHub Advisory Database
Summary
The fix for CVE-2025-35939 in craftcms/cms introduced a strip_tags() call in src/web/User.php to sanitize return URLs before they are stored in the session. However, strip_tags() only removes HTML tags (angle brackets) -- it does not inspect or filter URL schemes. Payloads like javascript:alert(document.cookie) contain no HTML tags and pass through strip_tags() completely unmodified, enabling reflected XSS when the return URL is rendered in an href attribute.
Details
The patched code in is:
public function setReturnUrl($url): void
{
parent::setReturnUrl(strip_tags($url));
}
strip_tags() removes HTML tags (e.g., <script>, <img>) from a string, but it is not a URL sanitizer. When the sanitized return URL is subsequently rendered in an href attribute context (e.g., <a href="{{ returnUrl }}">), the following dangerous payloads survive strip_tags() completely unmodified:
-
javascript:protocol URLs --javascript:alert(document.cookie)contains no HTML tags, sostrip_tags()returns it verbatim. When placed in anhref, clicking the link executes the JavaScript. -
data:URIs --data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==uses Base64 encoding and contains no tags at all, bypassingstrip_tags()entirely. -
Protocol-relative URLs --
//evil.com/stealcontains no tags and is passed through unchanged. When rendered as anhref, the browser resolves it relative to the current page’s protocol, redirecting the user to an attacker-controlled domain.
The core issue is that strip_tags() operates on HTML syntax (angle brackets) while the threat model here requires URL scheme validation. These are fundamentally different security concerns.
Impact
Reflected XSS via crafted return URL. An attacker constructs a malicious link such as https://target.example.com/craft/?returnUrl=javascript:alert(document.cookie) and sends it to a victim. The attack flow is:
- Victim clicks the link, visiting the Craft CMS site.
- The application calls
setReturnUrl()with the attacker-controlled value. strip_tags()processes the URL but finds no HTML tags -- it passes through unchanged.- The URL is stored in the session and later rendered in an
hrefattribute (e.g., a "Return" or "Continue" link). - When the victim clicks that link,
javascript:alert(document.cookie)executes in the context of the Craft CMS origin.
This enables:
- Session hijacking via cookie theft (
document.cookie) - Data exfiltration via
fetch()to an attacker-controlled server - Phishing by redirecting to a lookalike domain (protocol-relative URL)
- CSRF by performing actions on behalf of the authenticated user
NVD (es)
Craft es un sistema de gestión de contenidos (CMS). La corrección para CVE-2025-35939 en craftcms/cms introdujo una llamada a strip_tags() en src/web/User.php para depurar las URL de retorno antes de que se almacenen en la sesión. Sin embargo, strip_tags() solo elimina las etiquetas HTML (corchetes angulares); no inspecciona ni filtra los esquemas de URL. Las cargas útiles como javascript:alert(document.cookie) no contienen etiquetas HTML y pasan por strip_tags() sin sufrir ninguna modificación, lo que permite un XSS reflejado cuando la URL de retorno se representa en un atributo href. Esta vulnerabilidad se ha corregido en las versiones 5.9.7 y 4.17.3.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-31859 changed 2026-03-12 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-fvwq-45qv-xvhv changed 2026-03-13 | CC-BY-4.0 |
| NVD | CVE-2026-31859 changed 2026-06-17 | Public domain |