CVE-2020-8521

9.8 CRITICAL

📋 TL;DR

This CVE describes a SQL injection vulnerability in phpzag's 'Live Add Edit Delete DataTables Records with Ajax PHP MySQL' script. Attackers can exploit the start and length parameters in Records.php to execute arbitrary SQL commands, potentially compromising the database. Any website using this vulnerable script is affected.

💻 Affected Systems

Products:
  • phpzag Live Add Edit Delete DataTables Records with Ajax PHP MySQL
Versions: All versions prior to patching
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: The vulnerability exists in the default installation of the script when used with MySQL databases.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete database compromise allowing data theft, modification, deletion, or full system takeover via SQL injection leading to remote code execution.

🟠

Likely Case

Database information disclosure, data manipulation, or authentication bypass leading to unauthorized access.

🟢

If Mitigated

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

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

The vulnerability is in publicly available parameters with no authentication required, making exploitation straightforward.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Updated script from phpzag website

Vendor Advisory: https://www.phpzag.com/live-add-edit-delete-datatables-records-with-ajax-php-mysql/

Restart Required: No

Instructions:

1. Download the updated script from phpzag.com. 2. Replace the vulnerable Records.php file. 3. Ensure all user inputs are properly sanitized. 4. Implement parameterized queries.

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Add server-side validation to sanitize start and length parameters before processing.

// PHP example: $start = filter_var($_POST['start'], FILTER_VALIDATE_INT);
// $length = filter_var($_POST['length'], FILTER_VALIDATE_INT);

Web Application Firewall (WAF) Rules

all

Configure WAF to block SQL injection patterns in POST parameters.

# ModSecurity example: SecRule ARGS "@detectSQLi" "id:1001,phase:2,deny"

🧯 If You Can't Patch

  • Implement strict input validation and parameterized queries in Records.php
  • Restrict database user permissions to minimum required privileges

🔍 How to Verify

Check if Vulnerable:

Review Records.php for direct use of $_POST['start'] and $_POST['length'] without proper sanitization or parameterized queries.

Check Version:

Check the file modification date of Records.php and compare with known vulnerable versions.

Verify Fix Applied:

Check that Records.php uses prepared statements with bound parameters for database queries.

📡 Detection & Monitoring

Log Indicators:

  • Unusual SQL queries in database logs
  • Multiple requests with SQL-like patterns in parameters

Network Indicators:

  • POST requests to Records.php with SQL injection payloads in parameters

SIEM Query:

source="web_logs" AND uri="*Records.php*" AND (param="*start=*" OR param="*length=*") AND (param="*UNION*" OR param="*SELECT*" OR param="*OR 1=1*")

🔗 References

📤 Share & Export