Yii2 · Yii2 · CVE-2024-32877
**Name of the Vulnerable Software and Affected Versions**
Yii2 versions 2.0.49.3 and earlier
**Description**
The issue lies in the mechanism for displaying function argument values in the stack trace, specifically when an argument's value exceeds 32 characters. The vulnerability manifests when an attacker induces an exception in the application, leading to a stack trace page being displayed. The use of a double quote (") allows an attacker to break out of the title attribute's value context and inject their own attributes into the span tag, including malicious JavaScript code through event handlers such as `onmousemove`. This vulnerability allows an attacker to execute arbitrary JavaScript code in the security context of the victim's site via a specially crafted link, potentially leading to the theft of cookies, content substitution, or complete takeover of user accounts.
**Recommendations**
For versions 2.0.49.3 and earlier, upgrade to version 2.0.50 to address the vulnerability. As a temporary workaround, consider modifying the `htmlEncode` method in the `ErrorHandler.php` file to effectively prevent the XSS vulnerability while maintaining the targeted functionality of the previous changes. The suggested modification is to change the `htmlEncode` method to use `htmlspecialchars($text, ENT QUOTES | ENT SUBSTITUTE | ENT HTML5, 'UTF-8')`.