CVE-2022-28111

9.8 CRITICAL

📋 TL;DR

This CVE describes a time-blind SQL injection vulnerability in MyBatis PageHelper. Attackers can exploit the orderBy parameter to execute arbitrary SQL commands, potentially leading to data theft, modification, or deletion. All applications using vulnerable versions of MyBatis PageHelper are affected.

💻 Affected Systems

Products:
  • MyBatis PageHelper
Versions: v1.x.x-v3.7.0, v4.0.0-v5.0.0, v5.1.0-v5.3.0
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Affects all configurations using the vulnerable orderBy parameter functionality.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete database compromise including data exfiltration, modification, deletion, and potential remote code execution via database functions.

🟠

Likely Case

Data extraction from the database, including sensitive information like user credentials, personal data, and business records.

🟢

If Mitigated

Limited impact due to proper input validation, parameterized queries, and database permission restrictions.

🌐 Internet-Facing: HIGH - Web applications using vulnerable versions expose database to external attackers.
🏢 Internal Only: MEDIUM - Internal applications still vulnerable to insider threats or compromised internal systems.

🎯 Exploit Status

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

Time-blind SQL injection requires timing analysis but is well-documented and relatively easy to exploit.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: v5.3.1 and later

Vendor Advisory: https://github.com/pagehelper/Mybatis-PageHelper/issues/674

Restart Required: Yes

Instructions:

1. Update MyBatis PageHelper dependency to version 5.3.1 or later. 2. Update pom.xml or build.gradle with new version. 3. Rebuild and redeploy application. 4. Restart application server.

🔧 Temporary Workarounds

Input Validation Filter

all

Implement server-side validation to sanitize orderBy parameter inputs

Implement custom filter/interceptor to validate orderBy parameter against whitelist of allowed column names

Database Permission Reduction

all

Restrict database user permissions to minimum required

REVOKE unnecessary privileges from application database user

🧯 If You Can't Patch

  • Implement WAF rules to block SQL injection patterns in orderBy parameter
  • Deploy database firewall to monitor and block suspicious SQL queries

🔍 How to Verify

Check if Vulnerable:

Check project dependency file (pom.xml or build.gradle) for MyBatis PageHelper version within vulnerable ranges

Check Version:

grep -i pagehelper pom.xml || grep -i pagehelper build.gradle

Verify Fix Applied:

Confirm MyBatis PageHelper version is 5.3.1 or later in dependency file and verify application functions correctly

📡 Detection & Monitoring

Log Indicators:

  • Unusual SQL queries with time delays
  • Multiple failed orderBy parameter attempts
  • Suspicious orderBy parameter values

Network Indicators:

  • HTTP requests with crafted orderBy parameters containing SQL keywords
  • Unusually long response times for orderBy requests

SIEM Query:

web_access_logs | where orderBy contains any('sleep', 'waitfor', 'benchmark', 'pg_sleep')

🔗 References

📤 Share & Export