Skip to content

CVE-2026-39850: Verified Repro With Script Download

CVE-2026-39850: Yii2: local file inclusion via View::renderPhpFile extract of caller-controlled params

CVE-2026-39850 is verified against yiisoft/yii2 · composer. Affected versions: <= 2.0.54. Fixed in 2.0.55. This high reproduction includes runnable sandbox proof, artifacts, and a plain-text agent view under REPRO-2026-00156.

REPRO-2026-00156 yiisoft/yii2 · composer May 23, 2026 CVE entry ↗ .txt
Severity
HIGH
CVSS
7.4
Reproduced in
15m 11s
Tool calls
120
Spend
$0.62
01 · Overview

What Is CVE-2026-39850?

CVE-2026-39850 (GHSA-5vpg-rj7q-qpw2) is a high-severity local file inclusion / code injection vulnerability (CWE-98/CWE-94) in Yii2's View::renderPhpFile() method. Pruva reproduced it (reproduction REPRO-2026-00156).

02 · Severity & CVSS

CVE-2026-39850 Severity & CVSS Score

CVE-2026-39850 is rated high severity, with a CVSS base score of 7.4 out of 10.

HIGH threat level
7.4 / 10 CVSS base
Weakness CWE-98 / CWE-94 (LFI / Code Injection)

High — serious impact or readily exploitable. Prioritize remediation.

03 · Affected Versions

Affected yiisoft/yii2 Versions

yiisoft/yii2 · composer versions <= 2.0.54 are affected.

How to Reproduce CVE-2026-39850

$ pruva-verify REPRO-2026-00156
or curl -O https://pruva.dev/api/v1/reproductions/REPRO-2026-00156/artifacts/reproduction_steps.sh && chmod +x reproduction_steps.sh && ./reproduction_steps.sh
Run in a VM or disposable container. This exploits a real vulnerability.
06 · Proof of Reproduction

Proof of Reproduction for CVE-2026-39850

Reproduced by Pruva's autonomous agents — 120 tool calls over 15 min. Full root-cause analysis and the complete transcript are below.

How the agent worked 422 events · 120 tool calls · 15 min
15 minDuration
120Tool calls
99Reasoning steps
422Events
2Dead-ends
Agent activity over 15 min
Support
26
Repro
157
Variant
234
0:0015:11

Root Cause and Exploit Chain for CVE-2026-39850

Summary

CVE-2026-39850 is a Local File Inclusion (LFI) vulnerability in Yii2's View::renderPhpFile() method. The method uses extract($_params_, EXTR_OVERWRITE) before require $_file_, which allows a malicious _file_ key in the params array to overwrite the local $_file_ variable. This redirects the require statement to an attacker-controlled file path, enabling arbitrary file inclusion.

Impact

  • Package: yiisoft/yii2
  • Affected versions: <= 2.0.54
  • Fixed version: 2.0.55
  • CWE: CWE-98 / CWE-94 (LFI / Code Injection)
  • Risk level: High (CVSS 3.1 base 7.4)
  • Consequences: Attackers who control any part of the params array passed to renderPhpFile can read arbitrary files and potentially execute arbitrary PHP code if the included file contains PHP.

Root Cause

In yii\base\View::renderPhpFile(), the vulnerable code sequence was:

extract($_params_, EXTR_OVERWRITE);
require $_file_;

Because EXTR_OVERWRITE is used, variables in $_params_ overwrite existing local variables with the same name. If $_params_ contains a key named _file_, the local $_file_ variable (which holds the intended template path) is overwritten with the attacker-supplied value immediately before the require executes.

The fix (commit 109878b491dbffa541032bc99fb5e26d12cd0375) isolates the extract and require inside a closure:

$_renderer_ = function () {
    extract(func_get_arg(1), EXTR_OVERWRITE);
    require func_get_arg(0);
};
call_user_func_array($_renderer_, [$_file_, $_params_]);

Because extract runs inside the closure's local scope, it can only overwrite variables within that scope, not the $_file_ variable in the parent renderPhpFile scope. Thus the intended template path is preserved.

A similar fix was applied to yii\web\ErrorHandler::renderFile().

Reproduction Steps

The reproduction script is repro/reproduction_steps.sh.

What the script does:

  1. Clones the yiisoft/yii2 repository.
  2. Creates a benign template (safe.php) and a secret file (secret.txt).
  3. Checks out the vulnerable tag 2.0.54.
  4. Runs a PHP CLI script that instantiates yii\base\View and calls renderPhpFile('safe.php', ['_file_' => 'secret.txt']).
  5. Captures the output.
  6. Checks out the fixed tag 2.0.55 and repeats the test.

Expected evidence:

  • On 2.0.54 (vulnerable), the output contains SECRET_DATA_LINE from the secret file, proving LFI.
  • On 2.0.55 (fixed), the output contains SAFE OUTPUT from the intended template, proving the fix works.

Evidence

Vulnerable build (2.0.54)
  • Log: logs/vulnerable_2.0.54.log
  • Excerpt:
    === RESULT ===
    SECRET_DATA_LINE
    === END ===
    VULNERABLE: _file_ param was able to override local variable and include secret file
    
Fixed build (2.0.55)
  • Log: logs/fixed_2.0.55.log
  • Excerpt:
    === RESULT ===
    SAFE OUTPUT
    === END ===
    FIXED: _file_ param did not override local variable, safe.php was rendered
    
Environment

Recommendations / Next Steps

  • Immediate: Upgrade yiisoft/yii2 to >= 2.0.55.
  • Defense in depth: Sanitize or validate user-controlled data before passing it as view params. Avoid passing raw user input directly to renderPhpFile or renderFile.
  • Testing: Add regression tests that pass _file_ and other internal variable names in view params to ensure future changes do not reintroduce scope leakage.

Additional Notes

  • Idempotency: The reproduction script was run twice consecutively and produced identical results both times.
  • Edge cases: The same vulnerability pattern existed in yii\web\ErrorHandler::renderFile(), which was fixed in the same commit. The reproduction focuses on View::renderPhpFile() as the primary attack surface.
  • No web server required: The issue is reproducible entirely via PHP CLI, making automated testing straightforward.

CVE-2026-39850 Reproduction Transcript

The agent's step-by-step process — every tool call, every handoff, the moment the exploit fired.

Full session Replay every step — scrub the timeline or play it back.

Event 1/40
0:001:58
0:00
session startedaccounts/fireworks/models/kimi-k2p6 · cve-2026-39850 · cve-2026
0:15
0:16
0:22
0:23
web search
0:54
0:54
extract_facts
no facts extracted
0:54
error

Unknown error

1:36
1:36
extract_facts
no facts extracted
1:36
error

Unknown error

1:51
1:51
extract_facts
no facts extracted
1:52
1:52
1:52
supportrepro
1:54
1:54
1:55
1:55
1:55
1:58

Artifacts and Evidence for CVE-2026-39850

Scripts, logs, diffs, and output captured during the reproduction.

No artifacts available

08 · How to Fix

How to Fix CVE-2026-39850

Upgrade yiisoft/yii2 · composer to 2.0.55 or later.

Coming soon

Step-by-step mitigation and hardening guidance for CVE-2026-39850 — configuration checks, workarounds where no patch exists, and how to verify you're protected — is on the way.

10 · FAQ

FAQ: CVE-2026-39850

How does the CVE-2026-39850 local file inclusion exploit work?

An attacker who controls any subset of the params array passed to renderPhpFile includes a _file_ key pointing at an arbitrary path. extract($_params_, EXTR_OVERWRITE) overwrites the intended template path stored in $_file_, so the subsequent require $_file_ loads the attacker-chosen file instead — reading arbitrary files, or executing arbitrary PHP if the included file contains PHP code.

Which Yii2 versions are affected by CVE-2026-39850, and where is it fixed?

Yii2 versions up to and including 2.0.54 are affected. It is fixed in 2.0.55, via commit 109878b491dbffa541032bc99fb5e26d12cd0375, which isolates the extract and require calls inside a closure so injected _file_ keys can no longer overwrite the file path.

How severe is CVE-2026-39850?

It is rated high severity: attackers who control any part of the params array passed to renderPhpFile can read arbitrary files and potentially execute arbitrary PHP code.

How can I reproduce CVE-2026-39850?

Download the verified script from this page and run it in an isolated environment against Yii2 <= 2.0.54. It calls View::renderPhpFile() with a params array containing a _file_ key pointing at an attacker-chosen file and shows that file being included instead of the intended template.
11 · References

References for CVE-2026-39850

Authoritative sources for CVE-2026-39850 — official vulnerability databases and the upstream advisory. Pruva's reproduction verifies the issue firsthand; these are the primary records to corroborate it.