Średnia

Reflected Cross-site Scripting in yiisoft/yii2 Debug mode

  • Ujawniono: 02.06.2024
  • Aktualizacja: 11.10.2026 10:22

During the internal penetration testing of our product based on Yii2, we discovered an XSS vulnerability within the framework itself. This issue is relevant for the latest version of Yii2 (2.0.49.3).

Conditions for vulnerability reproduction

  • The framework is in debug mode (YII_DEBUG set to true).
  • The php.ini setting zend.exception_ignore_args is set to Off (default value).
  • An attacker induces an exception in the application, leading to a stack trace page being displayed.

Vulnerability description

The issue lies in the mechanism for displaying function argument values in the stack trace. The vulnerability manifests when an argument's value exceeds 32 characters. For convenience, argument values exceeding this limit are truncated and displayed with an added "...". The full argument value becomes visible when hovering over it with the mouse, as it is displayed in the title attribute of a span tag. However, 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.

Demonstration example: http://31.184.254.143/about/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%22%20onmousemove=alert(1)%20style=%22width:%20100000px;%20height:%20100000px;%20position:%20absolute;%20top:%20-10000px;%20left:%200;%22

Impact of the vulnerability

This vulnerability allows an attacker to execute arbitrary JavaScript code in the security context of the victim's site via a specially crafted link. This could lead to the theft of cookies (including httpOnly cookies, which are accessible on the page), content substitution, or complete takeover of user accounts.

Technical analysis and mitigation suggestion

Upon analyzing the framework's source code, it was found that data handling for the title attribute is performed in the file framework/web/ErrorHandler.php. The identified problem is related to changes made in the commit https://github.com/yiisoft/yii2/commit/8cc9aeb2f0b2ffe02fb54a817064e9da75512706 , which led to the disabling of encoding for single and double quotes in the htmlEncode method (https://github.com/yiisoft/yii2/blob/8cc9aeb2f0b2ffe02fb54a817064e9da75512706/framework/web/ErrorHandler.php#L183) due to the addition of the ENT_NOQUOTES flag. To address this issue while preserving the functionality intended by the commit, we suggest modifying the htmlEncode method as follows:

    return htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5, 'UTF-8');

This change will effectively prevent the XSS vulnerability while maintaining the targeted functionality of the previous changes.

Conclusion

Based on the above, we strongly recommend implementing the suggested changes to the project's main code as soon as possible to protect framework users from potential attacks. I am ready to provide further information or assistance, including creating a pull request if necessary.

Czego dotyczy

Kliknij technologię, aby zobaczyć wszystkie dotyczące jej podatności.

PlatformaPaczkaPodatne wersjePoprawka w wersji
Paczka Composer yiisoft/yii2 >= 2.0.43, < 2.0.49.4 2.0.49.4

Odnośniki

Ocena CVSS 4.2/10
Wektor CVSS
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N
Słabość (CWE)
CWE-79
Platforma
Composer
Paczka
yiisoft/yii2
Ujawniono
02.06.2024
Aktualizacja
11.10.2026 10:22

Źródła i licencje

OSV / GitHub Advisory Database - GHSA-qg5r-95m4-mjgj - CC BY 4.0

Historia podatności: yiisoft/yii2

Wszystkie opisane podatności tej paczki (Paczka Composer), od najnowszej. Widać, czy to jednorazowa wpadka, czy paczka, której trzeba pilnować.

Wszystkie (12) w archiwum
Wszystkich wpisów
12
Pierwsza → ostatnia
09.2020 05.2026
Bez poprawki
0
Wykorzystywana w atakach
1

Rozkład istotności

  • Krytyczna 2
  • Wysoka 5
  • Średnia 5

Ujawnienia w latach

  1. 2020: 1
  2. 2021: 0
  3. 2022: 6
  4. 2023: 1
  5. 2024: 2
  6. 2025: 1
  7. 2026: 1
Istotność:
  1. Wysoka · 7.4 CVE-2026-39850 < 2.0.55 2.0.55
  2. Krytyczna · 9.0 Wykorzystywana w atakach CVE-2024-58136 < 2.0.52 2.0.52
  3. Wysoka · 8.1 CVE-2024-4990 < 2.0.49.4 2.0.49.4
  4. Reflected Cross-site Scripting in yiisoft/yii2 Debug mode ten wpis
    Średnia · 4.2 CVE-2024-32877 >= 2.0.43, < 2.0.49.4 2.0.49.4
  5. Wysoka · 8.8 CVE-2018-6009 >= 2.0, < 2.0.14 2.0.14
  6. Wysoka · 7.5 CVE-2018-6010 >= 2.0.0, < 2.0.14 2.0.14
  7. Wysoka · 8.9 CVE-2020-15148 < 2.0.38 2.0.38

Dowiedz się, które podatności dotyczą Twojej aplikacji

Po podłączeniu integracji DockRay i włączeniu raportowania oprogramowania DockRay porównuje zgłoszone wersje komponentów ze znanymi podatnościami i powiadamia o potwierdzonych dopasowaniach. Zakres zależy od obsługiwanej technologii i dostępnych biuletynów.

Podłącz swoją aplikację
Newsletter DockRay

Bezpieczeństwo aplikacji w Twojej skrzynce

Najważniejsze podatności, konkretne zalecenia i praktyczne wskazówki dla Twoich aplikacji. Wybierz technologie i śledź to, co ma znaczenie dla Twojego projektu.

  • Codzienne zestawienie nowych podatności, także krytycznych.
  • Powiadomienia o ważnych aktualizacjach.
  • Praktyczne porady o bezpieczeństwie i monitoringu aplikacji.

Pozostaw puste, aby otrzymywać informacje o wszystkich technologiach.

Zapis jest bezpłatny. Wypiszesz się jednym kliknięciem w wiadomości.