Yii 2 Local File Inclusion via View Parameter Name Collision (CVE-2026-39850)
A local file inclusion vulnerability (CVE-2026-39850) exists in Yii 2 versions prior to 2.0.55 due to the `View::renderPhpFile()` method's handling of the `_file_` parameter, allowing attackers to read arbitrary files and potentially achieve remote code execution if they can write PHP files.
Yii 2, a PHP framework, is vulnerable to a local file inclusion (LFI) vulnerability (CVE-2026-39850) affecting versions prior to 2.0.55. The vulnerability lies within the View::renderPhpFile() method, where the code calls extract($_params_, EXTR_OVERWRITE) before including the view file. This allows an attacker to control the _file_ parameter within the $params array and overwrite the internal local variable that dictates which file is included. This vulnerability can be exploited to read arbitrary files on the server. If an attacker possesses the capability to write PHP files to the server through a separate vulnerability or misconfiguration, they could potentially leverage this LFI to achieve remote code execution (RCE). This vulnerability impacts systems using the vulnerable versions of the Yii 2 framework and highlights the risks associated with uncontrolled variable extraction.
Attack Chain
- The attacker identifies a Yii 2 application running a version prior to 2.0.55.
- The attacker discovers a page or functionality that uses the
View::renderPhpFile()method to render a view. - The attacker crafts a request to this page, including a
_file_parameter within the$paramsarray. - The
extract($_params_, EXTR_OVERWRITE)function withinView::renderPhpFile()is called. - The attacker-controlled
_file_parameter overwrites the internal$filevariable, which should point to the intended view file. - The
requirestatement then includes the file specified by the attacker-controlled_file_parameter. - If the attacker specifies a path to an existing file, the contents of that file are exposed.
- If the attacker can also write PHP code to the server (via another vulnerability or misconfiguration), the attacker can specify the path to that file, resulting in arbitrary code execution.
Impact
Successful exploitation of this vulnerability allows attackers to read arbitrary files on the server. This can lead to information disclosure, including sensitive configuration files, source code, or user data. Furthermore, if an attacker can upload or create PHP files on the server, they can leverage this LFI vulnerability to achieve remote code execution, potentially leading to full system compromise. The number of potential victims depends on the number of applications using vulnerable versions of Yii 2.
Recommendation
- Upgrade to Yii 2 version 2.0.55 or later to patch CVE-2026-39850.
- Deploy the Sigma rule “Detect Yii2 LFI via file parameter overwrite” to your SIEM to detect exploitation attempts.
- Review application code that uses
View::renderPhpFile()and ensure that user-supplied input is not directly used to construct the$paramsarray, specifically the_file_parameter.
Detection coverage 2
Detect Yii2 LFI via file parameter overwrite
highDetects CVE-2026-39850 exploitation attempts by monitoring web server logs for requests containing a '_file_' parameter with suspicious path traversal sequences.
Detect Yii2 LFI via direct file access
mediumDetects CVE-2026-39850 exploitation by identifying direct access to sensitive files via HTTP requests that may indicate exploitation of the LFI.
Detection queries are available on the platform. Get full rules →