CVE-2019-8979

9.8 CRITICAL

📋 TL;DR

CVE-2019-8979 is a SQL injection vulnerability in Kohana PHP framework that allows attackers to execute arbitrary SQL commands by controlling the order_by() parameter. This affects all Kohana applications using vulnerable versions where user input reaches this parameter. Attackers can potentially read, modify, or delete database content.

💻 Affected Systems

Products:
  • Kohana PHP Framework
Versions: Through 3.3.6
Operating Systems: All platforms running PHP
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications using the vulnerable order_by() method with user-controlled input.

📦 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 through database functions.

🟠

Likely Case

Data exfiltration from database, authentication bypass, or data manipulation depending on application structure.

🟢

If Mitigated

Limited impact with proper input validation and parameterized queries in place.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

Exploitation requires user input to reach the order_by() parameter, which is common in sorting/filtering functionality.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 3.3.7 and later

Vendor Advisory: https://github.com/kohana/kohana/releases/tag/v3.3.7

Restart Required: No

Instructions:

1. Update Kohana to version 3.3.7 or later. 2. Replace all instances of order_by() with proper parameterized queries. 3. Review code for any custom implementations that might bypass framework protections.

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Implement strict input validation for all parameters passed to order_by() method

Parameterized Queries

all

Replace vulnerable order_by() calls with prepared statements or ORM methods

🧯 If You Can't Patch

  • Implement web application firewall (WAF) rules to block SQL injection patterns
  • Restrict database user permissions to minimum required for application functionality

🔍 How to Verify

Check if Vulnerable:

Check if Kohana version is 3.3.6 or earlier and if order_by() method accepts user input without validation.

Check Version:

Check Kohana version in application files or via phpinfo() if configured.

Verify Fix Applied:

Verify Kohana version is 3.3.7 or later and review code to ensure order_by() uses parameterized queries.

📡 Detection & Monitoring

Log Indicators:

  • Unusual SQL queries in database logs
  • Multiple failed login attempts after order_by parameter manipulation
  • Unexpected ORDER BY clauses in application logs

Network Indicators:

  • SQL error messages in HTTP responses
  • Unusual parameter values in order_by requests

SIEM Query:

search 'order_by' AND ('sql' OR 'error' OR 'syntax') in web server logs

🔗 References

📤 Share & Export