GHSA-95m2-chm4-mq7m PHP-Textile has persistent XSS vulnerability in image link handling
Persistent XSS in PHP-Textile allows attackers to inject JavaScript via image links in restricted mode, requiring user interaction to execute.
- Exploited in the wild
- Not known
- Login needed
- Any signed-in user
- Attackable
- Over the internet
- Victim action needed
- A user has to click or open something
- Fix
- Available
What is GHSA-95m2-chm4-mq7m?
GHSA-95m2-chm4-mq7m is a cross-site scripting vulnerability in netcarver/textile, published on 7 Jan 2025. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Official description
Details
Persistent XSS vulnerability in image link handling of PHP-Textile versions 4.1.2 and older, when running the parser in restricted mode. In restricted mode it is expected that the input would be sanitized, allowing user-input (such as user comments) to be parsed and handled safely by the PHP-Textile library.
In restricted mode, the version 4.1.2 of the library does not sanitize or validate user-controllable href input in image links, but allows any link protocol or JavaScriptt links to be used. The vulnerability allows an attacker to add malicious JavaScript code to the page which is then executed when an unexpecting user clicks the link.
In non-restricted mode, the library allows mixed HTML input, and any link protocol by design. In restricted mode, text links were already handled correctly and the vulnerability only affects image links.
Resolution
This issue was fixed in PHP-Textile version 4.1.3. Version 4.1.3 disallows use of JavaScript in image links when the parser is ran in restricted mode. Restricted mode can be enabled with Parser::setRestricted() method prior to calling the parse method. For more information, see Parsing unstructed input in the project's README.
PoC
The following Textile input:
!securing.pl(Click Tu)!:javascript:document.innerHTML='<script>alert(1);</script>'+document.cookie)
Would render as the following HTML even in restricted mode:
<p><a href="javascript:document.innerHTML=&#39;&lt;script&gt;alert(1);&lt;/script&gt;&#39;+document.cookie"><img alt="Click Tu" src="securing.pl" title="Click Tu"></a>)</p>
Impact
The attacker can perform any operation in the application with user’s privileges or remotely control user’s browser with automated tools.
Which versions are affected by GHSA-95m2-chm4-mq7m?
2 open source packages ship an affected version, including netcarver/textile.
| Package | Affected | Fixed in |
|---|---|---|
netcarver/textile Packagist | All versions | 4.1.3 |
netcarver/textile Packagist | All versions | 4.1.3 |
How do I fix GHSA-95m2-chm4-mq7m?
Upgrade netcarver/textile to 4.1.3 or later.
Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.
Is GHSA-95m2-chm4-mq7m being exploited?
There is no known exploitation of GHSA-95m2-chm4-mq7m in the wild and no public exploit code.