CVE-2018-7269: Yii SQL injection vulnerability in yiisoft/yii2-dev
Summary
CVE-2018-7269: Yii SQL injection vulnerability. Affects yiisoft/yii2-dev across 3 version ranges.
< 2.0.12.1
>= 2.0.13, < 2.0.13.2
>= 2.0.14, < 2.0.15
Fixed in 2.0.12.1, 2.0.13.2 or 2.0.15, depending on the release line you run. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Yii is a high-performance PHP framework used for developing web applications. The yiisoft/yii2-dev package is a development version of Yii 2.x. It provides various tools and features for developers to build robust and secure web applications. However, this package is vulnerable to a SQL injection attack due to a flaw in the findByCondition function in the framework/db/ActiveRecord.php file.
Vulnerability Detail
The vulnerability allows remote attackers to conduct SQL injection attacks by exploiting the findOne() or findAll() calls in the Yii framework. This can lead to unauthorized access, data leakage, and potential manipulation of the database. The issue arises when array input is not properly sanitized, which can be overlooked by developers who are unaware of the need to sanitize such input.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
< 2.0.12.12.0.12.1composer require yiisoft/yii2-dev:2.0.12.1 -
>= 2.0.13, < 2.0.13.22.0.13.2composer require yiisoft/yii2-dev:2.0.13.2 -
>= 2.0.14, < 2.0.152.0.15composer require yiisoft/yii2-dev:2.0.15
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
A workaround for this vulnerability is to manually sanitize the array input before using the findOne() or findAll() functions. Here is an example of how to sanitize the input using the Yii framework's built-in methods:
$condition = Yii::$app->db->createCommand()->bindParam(':param', $param)->getRawSql();
$model = Model::findOne($condition);
By using the bindParam() method, the input is properly sanitized and the vulnerability is mitigated.
Conclusion
The Yii SQL injection vulnerability in the yiisoft/yii2-dev package can lead to unauthorized access, data leakage, and potential manipulation of the database. It is crucial for developers to upgrade to the fixed versions of the package (2.0.12.1, 2.0.13.2, or 2.0.15) or manually sanitize the array input to mitigate the vulnerability. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for yiisoft/yii2-dev →
FAQ
The vulnerability allows remote attackers to execute arbitrary SQL queries, potentially leading to unauthorized access, data leakage, and manipulation of the database.
You can use the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Simply provide your composer.lock file, and Vulert will analyze it for any open-source vulnerabilities, including this Yii SQL injection vulnerability.
At the time of this report, there are no known public exploits specifically targeting this vulnerability. However, it is important to patch your application as soon as possible to prevent any potential attacks.
Yes, the CVSS score for this vulnerability is 9.8, indicating a critical severity level.
You can find more information about this vulnerability, including the affected versions and fixed versions, in the GitHub Advisory Database: https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2022/05/GHSA-hhg2-g6h6-c266/GHSA-hhg2-g6h6-c266.json
Related vulnerabilities
Recent vulnerabilities recorded for yiisoft/yii2-dev.
Follow Vulert in Google
Get more Vulert vulnerability and dependency-security updates in Google Search and AI results.