CVE-2024-12909

9.8 CRITICAL

📋 TL;DR

This SQL injection vulnerability in the FinanceChatLlamaPack allows attackers to execute arbitrary SQL queries through the database_agent's run_sql_query function. Exploitation can lead to remote code execution via PostgreSQL large object functionality. Users of run-llama/llama_index repository versions up to v0.12.3 are affected.

💻 Affected Systems

Products:
  • run-llama/llama_index FinanceChatLlamaPack
Versions: All versions up to v0.12.3
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Requires PostgreSQL database backend with large object functionality enabled.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full database compromise leading to remote code execution, data exfiltration, and complete system takeover.

🟠

Likely Case

Database manipulation, data theft, and potential privilege escalation within the database environment.

🟢

If Mitigated

Limited to database-level impact if proper input validation and parameterized queries are implemented.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

SQL injection to RCE chain is documented in public bounty reports.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 0.3.0

Vendor Advisory: https://github.com/run-llama/llama_index/commit/5d03c175476452db9b8abcdb7d5767dd7b310a75

Restart Required: Yes

Instructions:

1. Update llama_index to version 0.3.0 or later. 2. Restart the application. 3. Verify the fix by checking the version and testing SQL query functionality.

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Implement strict input validation and parameterized queries for all database operations.

Database Privilege Reduction

all

Restrict database user permissions to prevent large object functionality execution.

REVOKE ALL ON LARGE OBJECT FROM [username];

🧯 If You Can't Patch

  • Implement network segmentation to isolate the vulnerable component from critical systems.
  • Deploy a web application firewall with SQL injection detection rules.

🔍 How to Verify

Check if Vulnerable:

Check if using llama_index version <= v0.12.3 and FinanceChatLlamaPack is enabled.

Check Version:

pip show llama_index | grep Version

Verify Fix Applied:

Confirm version is >= 0.3.0 and test SQL query functionality with malicious inputs.

📡 Detection & Monitoring

Log Indicators:

  • Unusual SQL query patterns
  • Large object function calls in database logs
  • Multiple failed query attempts

Network Indicators:

  • Unusual database connection patterns
  • SQL injection payloads in application traffic

SIEM Query:

source="application.logs" AND ("run_sql_query" OR "FinanceChatLlamaPack") AND ("SELECT lo_" OR "CREATE FUNCTION")

🔗 References

📤 Share & Export