CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2024-4990

Behaving Badly: Unsafe Reflection & RCE in Yii2 Framework

Amit Schendel
Amit Schendel
Senior Security Researcher

Feb 26, 2026·6 min read·158 visits

Executive Summary (TL;DR)

The Yii2 framework's `__set()` magic method allows developers to attach 'behaviors' dynamically. However, prior to version 2.0.48, it failed to validate that user-supplied configurations were actually Behaviors before instantiating them. Attackers can exploit this via mass assignment to instantiate arbitrary classes (like Guzzle gadgets) and achieve Remote Code Execution.

A critical Unsafe Reflection vulnerability in the core `yii\base\Component` class of the Yii2 framework allows attackers to instantiate arbitrary objects via the framework's behavior attachment mechanism. By leveraging PHP magic methods and the dependency injection container, remote attackers can execute arbitrary code (RCE) or perform other malicious actions by manipulating request parameters.

The Hook: Magic Methods, Tragic Results

In the world of PHP frameworks, "Magic Methods" are the double-edged sword that developers love and security researchers drool over. Yii2, one of the heavyweights of the PHP ecosystem, relies extensively on __get, __set, and __call to implement its component-based architecture. This allows for mixins, dynamic properties, and event handling that feels almost like wizardry.

At the heart of this system is yii\base\Component. This class is the great-grandfather of nearly everything in a Yii2 application—Models, Controllers, Views, you name it. If you find a bug here, you aren't just breaking a feature; you are breaking the foundation.

CVE-2024-4990 allows us to abuse a specific feature of this component system: Behaviors. Behaviors are Yii2's way of injecting functionality into a class at runtime. The framework allows you to attach a behavior simply by setting a property that starts with as . For example, $model->{'as timestamp'} = TimestampBehavior::class;. It's a convenient piece of syntactic sugar, but as we're about to see, it's also a convenient entry point for Remote Code Execution.

The Flaw: Blind Trust in Dependency Injection

The vulnerability lies in how yii\base\Component::__set() handles these dynamic behavior assignments. The logic is simple: check if the property name starts with as , trim the prefix to get the behavior name, and then instantiate the value provided.

Here is the logic in pseudocode terms: "If the user sends me a property named as evil, take the value they sent, create an object out of it, and attach it to the component." The critical failure here is the order of operations. The code calls Yii::createObject($value)—a powerful factory method that wraps a Dependency Injection (DI) container—before checking if the resulting object is actually a valid Behavior.

Yii::createObject is incredibly flexible. If you pass it an array with a class key, it will instantiate that class. If you pass it arguments, it will feed them to the constructor. Because __set is reachable via user input (e.g., during mass assignment of POST data to a Model), an attacker can trick the application into instantiating any class available in the autoloader, not just the intended Behaviors. It's like a nightclub bouncer who lets people in before checking their ID.

The Code: Examining the Smoking Gun

Let's look at the vulnerable code in yii\base\Component.php prior to version 2.0.48. This snippet shows the __set implementation:

public function __set($name, $value)
{
    // ... standard setter logic ...
 
    // The Vulnerable Logic
    } elseif (strncmp($name, 'as ', 3) === 0) {
        // as behavior: attach behavior
        $name = trim(substr($name, 3));
        // DANGER: Yii::createObject is called on user-controlled $value
        $this->attachBehavior($name, $value instanceof Behavior ? $value : Yii::createObject($value));
        return;
    }
    // ...
}

The line $value instanceof Behavior ? $value : Yii::createObject($value) is the killer. If $value is an array (which it will be coming from a JSON payload), instanceof fails, so it proceeds to Yii::createObject($value). By the time the code realizes the object isn't a Behavior (inside attachBehavior), the object has already been created, and its constructor has already run.

Now, look at the initial patch (which was later bypassed, but we'll get to that):

// The "Fix"
if ($value instanceof Behavior) {
    $this->attachBehavior($name, $value);
} elseif (isset($value['class']) && is_subclass_of($value['class'], Behavior::class, true)) {
    // Checking class name before instantiation
    $this->attachBehavior($name, Yii::createObject($value));
} ...

The developers attempted to validate the class key before instantiation. However, they missed a crucial detail about their own DI container: Yii2 supports __class as an alias for class. This oversight led to CVE-2024-58136, a regression that kept the door wide open.

The Exploit: From JSON to Shell

To exploit this, we need a "Gadget Chain". Since we can instantiate any class, we need a class that does something dangerous in its __construct or __destruct methods. A classic favorite in the PHP ecosystem is GuzzleHttp\Psr7\FnStream.

When FnStream is destroyed (which happens when the script ends or the object is discarded), it executes a user-defined callback. This gives us instant RCE.

The Attack Flow:

  1. Identify a Target: Find an endpoint that populates a Yii2 Model using $model->load($_POST) or parses JSON into a component configuration.
  2. Craft the Payload: We send a property key as exploit to trigger the __set logic.
  3. Define the Object: We specify the malicious class and its arguments.

Proof of Concept (RCE via Guzzle):

{
  "User": {
    "username": "admin",
    "as exploit": {
      "class": "GuzzleHttp\\Psr7\\FnStream",
      "methods": {
        "close": "passthru",
        "args": ["id; ls -la"]
      }
    }
  }
}

When Yii2 processes this, it instantiates FnStream. The framework realizes FnStream isn't a Behavior and throws an exception or discards it. However, the object was created. When PHP creates the exception or finishes the request, the FnStream object is garbage collected. Its __destruct method fires, calling close(), which runs passthru('id; ls -la').

The Impact: Why This Matters

This is a Critical severity vulnerability because it requires zero authentication (if the vulnerable endpoint is public, like a registration or login page) and results in full Remote Code Execution.

Yii2 is used by massive enterprise applications, CRMs, and e-commerce platforms. An attacker exploiting this can:

  • Gain Shell Access: Execute system commands to take over the server.
  • Database Exfiltration: Instantiate a PDO object to connect to an external malicious MySQL server (SSRF) or simply use the shell access to dump the local database.
  • Lateral Movement: Use the compromised server as a pivot point into the internal network.

Because the vulnerability exists in the base Component class, the attack surface is effectively "everywhere mass assignment is used in the application." It transforms a standard development convenience into a catastrophic security hole.

The Fix: Closing the Window

The remediation journey for this bug was bumpy. The initial fix in 2.0.48 was incomplete because it only validated the class array key, ignoring the __class alias supported by Yii's DI container.

Immediate Action Required:

  1. Upgrade: You must upgrade to yiisoft/yii2 version 2.0.52 or later. Do not stop at 2.0.48 or 2.0.51, as they are still vulnerable to the bypass (CVE-2024-58136).
  2. Code Review: Audit your code for Mass Assignment. Do not use $model->load($_POST) blindly on sensitive models without a strict scenarios() definition or explicit attribute safe-listing.

Defense in Depth: If you cannot upgrade immediately, you can implement a WAF rule to block any HTTP request body containing keys matching the regex "as\s+[a-zA-Z0-9_]+". However, WAFs are bypassable (e.g., via JSON encoding tricks), so patching the root cause is the only real solution.

Official Patches

YiiSoftInitial Patch Commit
YiiSoftVersion 2.0.52 Release Notes (Fixing Regression)

Fix Analysis (1)

Technical Appendix

CVSS Score
9.1/ 10
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H
EPSS Probability
0.42%
Top 99% most exploited
50,000
via Shodan

Affected Systems

yiisoft/yii2 < 2.0.52Applications using Yii2 Component mass assignment

Affected Versions Detail

Product
Affected Versions
Fixed Version
yiisoft/yii2
Yii Software
< 2.0.522.0.52
AttributeDetail
CWE IDCWE-470
Attack VectorNetwork
CVSS9.1 (Critical)
ImpactRemote Code Execution (RCE)
Exploit StatusPoC Available / Weaponized
PrerequisitesNone (if endpoint exposes mass assignment)

MITRE ATT&CK Mapping

T1190Exploit Public-Facing Application
Initial Access
T1059.003Command and Scripting Interpreter: Windows Command Shell
Execution
T1203Exploitation for Client Execution
Execution
CWE-470
Unsafe Reflection

Use of Externally-Controlled Input to Select Classes or Code (Unsafe Reflection)

Known Exploits & Detection

GitHubAdvisory with PoC details regarding FnStream gadget usage.

Vulnerability Timeline

Vulnerability discovered and reported via Huntr
2024-05-01
Initial patch released in commit 628d406b
2024-05-30
Advisory Published (GHSA-cjcc-p67m-7qxm)
2024-06-03
Official NVD Publication
2025-03-20

References & Sources

  • [1]Huntr - Unsafe Reflection in Yiisoft/Yii2
  • [2]NVD - CVE-2024-4990 Detail
Related Vulnerabilities
CVE-2024-58136

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•3 days ago•CVE-2026-115895
8.8

CVE-2026-115895: Code Injection via Unsanitized Import Alias in Happy DOM ECMAScript Module Compiler

CVE-2026-115895 is a high-severity code injection vulnerability (CWE-94) in the happy-dom npm package prior to version 21.0.4. The vulnerability exists within the ECMAScriptModuleCompiler component, which transforms ECMAScript module syntax into executable Node.js functions when JavaScript evaluation is enabled. Due to an incomplete fix for CVE-2026-33943, the compiler failed to validate local named import aliases against legal JavaScript identifier rules. Attackers supplying crafted module imports—specifically utilizing destructuring default initializers alongside JSON module attributes—can inject arbitrary JavaScript expressions directly into the host Node.js runtime context.

Amit Schendel
Amit Schendel
8 views•10 min read
•3 days ago•CVE-2026-115883
6.0

CVE-2026-115883: Cross-Namespace Access via Dot-Delimited Labels in LangGraph Postgres and SQLite Stores

An improper input validation and authorization bypass vulnerability exists in the LangGraph storage layer affecting langgraph, langgraph-checkpoint-postgres, and langgraph-checkpoint-sqlite. Because relational store implementations serialize namespace tuples into dot-delimited strings without validating labels on read, search, delete, and batch operations, an attacker who controls a namespace label can inject periods (.) to traverse namespace boundaries and access, modify, or delete data belonging to other namespaces.

Amit Schendel
Amit Schendel
9 views•9 min read
•3 days ago•CVE-2026-115886
6.5

CVE-2026-115886: Unauthenticated Server-Side Request Forgery and Unsafe Reflection in MLflow Scorer Evaluation Endpoints

CVE-2026-115886 (GHSA-2wqp-q3c6-ccj5) is a Server-Side Request Forgery (SSRF) and Unsafe Reflection vulnerability in MLflow versions 3.12.0rc0 prior to 3.17.0. Unauthenticated REST API endpoints accept serialized third-party scorer JSON payloads that are dynamically deserialized and reflectively instantiated without sanitizing constructor keyword arguments. When optional dependencies such as trulens and trulens-providers-litellm are installed, attackers can inject egress-steering arguments into the scorer payload, forcing the MLflow server to dispatch outbound HTTP requests to arbitrary internal destinations or cloud metadata services.

Alon Barad
Alon Barad
13 views•10 min read
•3 days ago•CVE-2026-113872
7.5

CVE-2026-113872: Unauthenticated Process Crash in Express Multer via Late Busboy Stream Resumption

CVE-2026-113872 (GHSA-q7qp-rjg7-q26m) is a high-severity denial-of-service vulnerability affecting the multer multipart/form-data upload middleware for Node.js and Express in versions 2.0.0 through 2.4.0. When an endpoint is configured to accept multiple files using an asynchronous fileFilter callback, a crafted, truncated multipart HTTP request can trigger an unhandled error event on the underlying busboy stream parser after request teardown has already completed. Because all error listeners are stripped during teardown, Node.js treats the resulting error event as an uncaught exception and immediately terminates the server process.

Amit Schendel
Amit Schendel
10 views•12 min read
•3 days ago•CVE-2026-115897
2.1

CVE-2026-115897: Cross-Site Scripting via Function Body Boundary Bypass in serialize-javascript

CVE-2026-115897 (also tracked as GHSA-m5mm-p8h7-m29v and aliased as CVE-2026-115754) is a Cross-Site Scripting (XSS) vulnerability in the Yahoo serialize-javascript npm package prior to version 7.1.3. The flaw exists in the regular expression used by escapeFunctionBody() to neutralize HTML script closing tags within serialized JavaScript functions. Because function bodies are sanitized in isolation before structural formatting is applied, a function whose string representation terminates directly with the sequence '</script' bypasses the positive lookahead check. When combined with serialization formatting options that introduce whitespace delimiters and a subsequent property that supplies a closing bracket, an attacker can prematurely terminate an enclosing HTML <script> block and inject arbitrary HTML or JavaScript into the rendered document.

Amit Schendel
Amit Schendel
7 views•13 min read
•3 days ago•CVE-2026-109841
5.9

CVE-2026-109841: Subresource Integrity Verification Bypass in Node.js Undici

CVE-2026-109841 is a Subresource Integrity (SRI) verification bypass vulnerability in undici, the official HTTP/1.1 and HTTP/2 client library for Node.js that powers the global fetch() implementation. The flaw stems from improper handling of case sensitivity (CWE-178) when validating cryptographic hash algorithm tokens within SRI metadata. Because undici compared incoming algorithm identifiers against a strictly lowercase set without prior ASCII-lowercase normalization, valid uppercase or mixed-case tokens such as SHA256- or Sha384- were treated as unrecognized algorithms and discarded. Under SRI forward-compatibility rules, discarding all provided tokens results in an empty integrity list, causing undici to fail open and accept tampered HTTP response bodies without cryptographic verification.

Alon Barad
Alon Barad
17 views•9 min read