CVE-2021-37522

9.8 CRITICAL

📋 TL;DR

This CVE describes a SQL injection vulnerability in Locke-Bot 2.0.2, a Discord bot, that allows remote attackers to execute arbitrary SQL commands. Attackers can exploit this by sending crafted strings to specific JavaScript files, potentially compromising the bot's database. Anyone running the vulnerable version of Locke-Bot is affected.

💻 Affected Systems

Products:
  • HKing2802 Locke-Bot
Versions: 2.0.2
Operating Systems: All platforms running Node.js
Default Config Vulnerable: ⚠️ Yes
Notes: The vulnerability exists in the default configuration as it involves improper input handling in the source code.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete database compromise including data theft, data manipulation, privilege escalation, and potential remote code execution if database functions allow it.

🟠

Likely Case

Unauthorized data access and modification, potential exposure of sensitive information stored in the bot's database.

🟢

If Mitigated

Limited impact with proper input validation and parameterized queries preventing SQL injection.

🌐 Internet-Facing: HIGH - Discord bots are internet-facing services that process user input from untrusted sources.
🏢 Internal Only: LOW - Discord bots are designed to be internet-facing services, not internal-only applications.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Public proof-of-concept code exists showing SQL injection payloads. Exploitation requires sending specially crafted messages to the Discord bot.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Unknown

Vendor Advisory: No official vendor advisory found

Restart Required: Yes

Instructions:

1. Check for updated version from the developer. 2. If no patch available, manually fix vulnerable code files. 3. Replace vulnerable files with secure versions using parameterized queries. 4. Restart the bot application.

🔧 Temporary Workarounds

Manual Code Fix

all

Replace vulnerable SQL queries with parameterized queries in the affected JavaScript files

Replace raw SQL concatenation with prepared statements using database libraries

Input Validation

all

Implement strict input validation for all user inputs before processing

Add input sanitization functions before SQL query construction

🧯 If You Can't Patch

  • Immediately disable the vulnerable bot until a fix can be applied
  • Implement network-level restrictions to limit bot access to only necessary database permissions

🔍 How to Verify

Check if Vulnerable:

Check if running Locke-Bot version 2.0.2 and examine /src/db.js, /commands/mute.js, /modules/event/messageDelete.js for SQL concatenation without parameterization.

Check Version:

Check package.json for version or run: node -e "console.log(require('./package.json').version)"

Verify Fix Applied:

Verify that all SQL queries in affected files use parameterized queries or prepared statements instead of string concatenation.

📡 Detection & Monitoring

Log Indicators:

  • Unusual SQL queries in database logs
  • Error messages containing SQL syntax errors
  • Multiple failed login attempts or unusual database operations

Network Indicators:

  • Unusual database connections from bot server
  • Suspicious SQL payloads in Discord message logs

SIEM Query:

source="discord_bot_logs" AND (message="SQL" OR message="database error")

🔗 References

📤 Share & Export