CVE-2018-18530: ThinkPHP SQLi Vulnerability

topthink/framework Updated 02 Oct 2025

Summary

14/05/2022
No i
Critical
9.8

CVE-2018-18530: ThinkPHP SQLi Vulnerability. Affects topthink/framework versions < 5.1.25. No fix is published. How to fix ↓

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

ThinkPHP is a popular PHP framework used for developing web applications. It provides a range of features and functionalities to simplify the development process. However, ThinkPHP version 5.1.25 is vulnerable to a SQL Injection attack. This vulnerability occurs due to mishandling of the aggregate variable in the library/think/db/Query.php file. An attacker can exploit this vulnerability by manipulating the 'count' parameter in the attack URI. It is important to note that the attack URI requires a backquote character for successful exploitation.

Vulnerability Detail

The SQL Injection vulnerability in ThinkPHP 5.1.25 allows an attacker to execute arbitrary SQL queries, potentially leading to unauthorized access, data leakage, or data manipulation. By injecting malicious SQL code through the 'count' parameter, an attacker can bypass input validation and gain unauthorized access to the database. This can result in the exposure of sensitive information, such as user credentials, personal data, or other confidential data stored in the database. The severity of this vulnerability is rated as 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

If upgrading to a patched version is not immediately feasible, a temporary workaround can be implemented by adding input validation and sanitization measures to the affected code. By properly validating and sanitizing user input, the risk of SQL Injection can be mitigated. Here is an example of how to implement input validation in PHP:

$param = $_GET['count'];

// Validate and sanitize the input
if (!is_numeric($param)) {
    // Handle the error
    exit('Invalid input');
}

// Use the sanitized input in the query
$query = "SELECT * FROM table WHERE count = " . $param;

Conclusion

The ThinkPHP SQL Injection vulnerability in version 5.1.25 can lead to unauthorized access, data leakage, and data manipulation. It is crucial to upgrade to a patched version of ThinkPHP or implement input validation and sanitization measures to mitigate the risk. For further support on vulnerability remediation, you can contact DevNack.com.

See every vulnerability recorded for topthink/framework →

Share this vulnerability

FAQ

ThinkPHP 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 web application vulnerability where an attacker can manipulate input parameters to execute arbitrary SQL queries. This can lead to unauthorized access, data leakage, or data manipulation.

The ThinkPHP SQL Injection vulnerability occurs due to mishandling of the aggregate variable in the library/think/db/Query.php file. An attacker can exploit this vulnerability by manipulating the 'count' parameter in the attack URI.

The potential consequences of this vulnerability include unauthorized access to the database, data leakage, and data manipulation. An attacker can execute arbitrary SQL queries, potentially exposing sensitive information stored in the database.

To mitigate the risk of this vulnerability, it is recommended to upgrade to a patched version of ThinkPHP beyond 5.1.25. Additionally, implementing input validation and parameterized queries can help prevent SQL Injection attacks.

Related vulnerabilities

Recent vulnerabilities recorded for topthink/framework.

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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback