CVE-2022-27386

7.5 HIGH

📋 TL;DR

CVE-2022-27386 is a SQL injection vulnerability in MariaDB Server that can cause a segmentation fault via sql/sql_class.cc, potentially leading to denial of service or arbitrary code execution. It affects MariaDB Server versions 10.7 and below. Database administrators running vulnerable MariaDB instances are affected.

💻 Affected Systems

Products:
  • MariaDB Server
Versions: 10.7 and below (including 10.6, 10.5, 10.4, etc.)
Operating Systems: All operating systems running MariaDB
Default Config Vulnerable: ⚠️ Yes
Notes: All default configurations are vulnerable. The vulnerability is in core SQL processing code.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote attacker could execute arbitrary code with database privileges, leading to complete system compromise, data theft, or ransomware deployment.

🟠

Likely Case

Denial of service through database crash, causing application downtime and potential data corruption.

🟢

If Mitigated

With proper network segmentation and least privilege, impact limited to database service disruption without lateral movement.

🌐 Internet-Facing: HIGH - Database servers exposed to internet are directly vulnerable to remote exploitation.
🏢 Internal Only: MEDIUM - Internal attackers or compromised systems could exploit this vulnerability to escalate privileges or cause service disruption.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires SQL injection capability. The vulnerability is triggered through crafted SQL queries.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: MariaDB 10.7.4, 10.6.9, 10.5.16, 10.4.25, 10.3.35, 10.2.44

Vendor Advisory: https://jira.mariadb.org/browse/MDEV-26406

Restart Required: Yes

Instructions:

1. Backup your database. 2. Stop MariaDB service. 3. Upgrade to patched version using your package manager. 4. Start MariaDB service. 5. Verify version and functionality.

🔧 Temporary Workarounds

Input Validation

all

Implement strict input validation and parameterized queries to prevent SQL injection attacks.

Use prepared statements in applications: $stmt = $conn->prepare('SELECT * FROM users WHERE id = ?'); $stmt->bind_param('i', $id);

Network Restrictions

linux

Restrict database access to only trusted application servers using firewall rules.

sudo iptables -A INPUT -p tcp --dport 3306 -s trusted_ip -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 3306 -j DROP

🧯 If You Can't Patch

  • Implement strict network segmentation to isolate MariaDB servers from untrusted networks
  • Deploy web application firewall (WAF) with SQL injection protection rules

🔍 How to Verify

Check if Vulnerable:

Run: mysql --version | grep -E '10\.[0-7]\.[0-9]+' (if output shows version 10.7 or below, you are vulnerable)

Check Version:

mysql --version

Verify Fix Applied:

Check version is at least: 10.7.4, 10.6.9, 10.5.16, 10.4.25, 10.3.35, or 10.2.44

📡 Detection & Monitoring

Log Indicators:

  • Segmentation fault errors in MariaDB logs
  • Unexpected database restarts
  • SQL syntax errors from unusual sources

Network Indicators:

  • Unusual SQL query patterns to MariaDB port 3306
  • Multiple connection attempts with malformed queries

SIEM Query:

source="mariadb.log" AND "segmentation fault" OR source="mariadb.log" AND "SIGSEGV"

🔗 References

📤 Share & Export