CVE-2021-44350: ThinkPHP5 SQL Injection vulnerability
Summary
CVE-2021-44350: ThinkPHP5 SQL Injection vulnerability. Affects topthink/framework versions >= 5.0, <= 5.1.22. No fix is published. 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
ThinkPHP5 is a popular PHP framework used for developing web applications. It provides a range of features and functionalities to simplify the development process. However, versions 5.0.x through 5.1.22 of ThinkPHP5 are vulnerable to a SQL Injection attack. This vulnerability arises from a flaw in the parseOrder function in Builder.php.
Vulnerability Detail
The SQL Injection vulnerability in ThinkPHP5 allows an attacker to manipulate SQL queries and potentially gain unauthorized access to the database. By exploiting this vulnerability, an attacker can execute arbitrary SQL commands, extract sensitive information, modify or delete data, and even take control of the affected system. The vulnerability has a severity rating of CRITICAL with a CVSS score of 9.8.
How To Fix
No fixed version is published for this vulnerability.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
As a temporary workaround, developers can manually sanitize and validate user input before using it in SQL queries. This involves using parameterized queries or prepared statements to separate the SQL code from the user input. Here is an example of how to use parameterized queries in PHP to mitigate the SQL Injection vulnerability:
$pdo = new PDO('mysql:host=localhost;dbname=mydatabase', 'username', 'password');
$stmt = $pdo->prepare('SELECT * FROM users WHERE username = :username');
$stmt->bindParam(':username', $username);
$stmt->execute();
$result = $stmt->fetchAll();
Conclusion
The ThinkPHP5 SQL Injection vulnerability poses a significant risk to applications built on this framework. It is crucial to promptly update to a version higher than 5.1.22 to mitigate the vulnerability. Additionally, developers should implement proper input validation and sanitization techniques to prevent SQL Injection attacks. For further support and assistance in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for topthink/framework →
FAQ
ThinkPHP5 is a PHP framework used for developing web applications. It provides a range of features and functionalities to simplify the development process.
SQL Injection is a type of security vulnerability that allows an attacker to manipulate SQL queries and potentially gain unauthorized access to the database.
This vulnerability has a severity rating of CRITICAL with a CVSS score of 9.8.
To fix this vulnerability, it is recommended to upgrade ThinkPHP5 to a version higher than 5.1.22.
As a temporary workaround, developers can manually sanitize and validate user input before using it in SQL queries.
References
Related vulnerabilities
Recent vulnerabilities recorded for topthink/framework.