CVE-2020-21176: SQL Injection in thinkjs

thinkjs Updated 02 Oct 2025

Summary

19/11/2021
No i
High
9.8

CVE-2020-21176: SQL Injection in thinkjs. Affects thinkjs versions < 3.2.14. 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

ThinkJS is an open-source Node.js framework designed for building scalable and maintainable web applications. It provides a comprehensive set of features, including routing, middleware support, and database integration. However, ThinkJS versions 0 to 3.2.14 are vulnerable to a SQL injection attack in the model.increment and model.decrement functions. This vulnerability allows remote attackers to execute arbitrary SQL commands by manipulating the 'step' parameter. The impact of this vulnerability can be severe, as it enables unauthorized access to the database and potential data leakage or modification.

Vulnerability Detail

The SQL injection vulnerability in ThinkJS arises due to insufficient input validation and sanitization in the model.increment and model.decrement functions. By crafting a malicious 'step' parameter, an attacker can inject arbitrary SQL commands into the underlying database query. This can lead to various security issues, including unauthorized data access, data manipulation, and potentially remote code execution. The vulnerability has a CVSS score of 9.8, indicating its high severity.

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 the latest version is not immediately feasible, users can implement a workaround by manually validating and sanitizing the 'step' parameter before passing it to the model.increment and model.decrement functions. This can be achieved by using parameterized queries or prepared statements to prevent the injection of malicious SQL commands. Here is an example of how to implement parameterized queries in ThinkJS:

const step = think.validate('step', 'number');
const sql = `UPDATE table SET column = column + ? WHERE condition = ?`;
await think.model('model').query(sql, [step, condition]);

Conclusion

In conclusion, the SQL injection vulnerability in ThinkJS versions 0 to 3.2.14 poses a significant risk to the security of web applications built with this framework. It is crucial to promptly upgrade to ThinkJS version 3.2.15 or later to mitigate this vulnerability. Alternatively, implementing manual input validation and sanitization can provide temporary protection. For further assistance and support in addressing this vulnerability, please contact DevNack.com.

See every vulnerability recorded for thinkjs →

Share this vulnerability

FAQ

ThinkJS is an open-source Node.js framework for building web applications. It provides a range of features and tools to simplify the development process.

ThinkJS versions 0 to 3.2.14 are affected by this SQL injection vulnerability.

This vulnerability allows remote attackers to execute arbitrary SQL commands, potentially leading to unauthorized data access, data manipulation, and remote code execution.

To fix this vulnerability, it is recommended to upgrade ThinkJS to version 3.2.15 or later. Alternatively, you can implement manual input validation and sanitization for the 'step' parameter.

Yes, if upgrading to the latest version is not immediately feasible, you can manually validate and sanitize the 'step' parameter before using it in the vulnerable functions. Implementing parameterized queries or prepared statements can help prevent SQL injection.

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