CVE-2018-16385: ThinkPHP SQL Injection vulnerability

topthink/framework Updated 02 Oct 2025

Summary

14/05/2022
Yes i
Critical
9.8

CVE-2018-16385: ThinkPHP SQL Injection vulnerability. Affects topthink/framework versions < 5.1.23. Fixed in 5.1.23. 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 Penetration testing for web, API and mobile 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, an SQL Injection vulnerability has been identified in ThinkPHP versions before 5.1.23. This vulnerability can be exploited through the public/index/index/test/index query string, allowing an attacker to execute arbitrary SQL queries and potentially gain unauthorized access to the database.

Vulnerability Detail

The SQL Injection vulnerability in ThinkPHP before 5.1.23 arises due to inadequate input validation and sanitization. By manipulating the public/index/index/test/index query string, an attacker can inject malicious SQL code into the application's database queries. This can lead to various security issues, including unauthorized data access, data manipulation, and even remote code execution.

How To Fix

Minimum fixed version

5.1.23

This is the first release that contains the fix.

composer require topthink/framework:5.1.23

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If upgrading to the latest version is not immediately feasible, developers can implement input validation and sanitization techniques to mitigate the risk of SQL Injection attacks. It is crucial to properly validate and sanitize user-supplied input before using it in database queries. This can be achieved by using parameterized queries or prepared statements to separate the SQL code from the user input.

Conclusion

The ThinkPHP SQL Injection vulnerability (CVE-2018-16385) allows attackers to execute arbitrary SQL queries and potentially gain unauthorized access to the application's database. It is crucial to upgrade ThinkPHP to version 5.1.23 or later to mitigate this vulnerability. Alternatively, developers can implement input validation and sanitization techniques to reduce the risk of SQL Injection attacks. For further support and assistance in vulnerability remediation, contact DevNack.com.

See every vulnerability recorded for topthink/framework →

Share this vulnerability

FAQ

ThinkPHP is a PHP framework used for web application development. It provides a range of features and tools to simplify the development process.

SQL Injection is a type of security vulnerability where an attacker can manipulate SQL queries to execute arbitrary SQL code. This can lead to unauthorized access, data manipulation, and other security issues.

If your application is using an affected version of ThinkPHP, it is vulnerable to SQL Injection attacks. Attackers can exploit this vulnerability to execute arbitrary SQL queries and potentially gain unauthorized access to your application's database.

To fix the vulnerability, you should upgrade ThinkPHP to version 5.1.23 or later. This version includes the necessary patches to mitigate the SQL Injection vulnerability. Alternatively, you can implement input validation and sanitization techniques to mitigate the risk until you can upgrade.

If upgrading to the latest version is not immediately feasible, you can implement input validation and sanitization techniques to mitigate the risk. Properly validate and sanitize user-supplied input before using it in database queries.

Related vulnerabilities

Recent vulnerabilities recorded for topthink/framework.

How To Fix

Minimum fixed version

5.1.23

This is the first release that contains the fix.

composer require topthink/framework:5.1.23

Tip — Not sure which version your app runs? Vulert can match this fix to it. 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