CVE-2024-9900
📋 TL;DR
This Cross-Site Scripting (XSS) vulnerability in mudler/localai v2.21.1 allows attackers to inject malicious JavaScript code through the search functionality. When exploited, this can lead to session hijacking, cookie theft, or redirection to malicious sites. Users running the vulnerable version of localai are affected.
💻 Affected Systems
- mudler/localai
📦 What is this software?
Localai by Mudler
⚠️ Risk & Real-World Impact
Worst Case
Complete account takeover through session cookie theft, data exfiltration, or installation of malware on user systems via browser exploitation.
Likely Case
Session hijacking leading to unauthorized access to user accounts and potential data theft.
If Mitigated
Limited impact with proper input validation and output encoding, potentially only affecting non-sensitive functionality.
🎯 Exploit Status
XSS vulnerabilities are commonly exploited and tooling exists for automated exploitation.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Fixed in commit a1634b219a4e52813e70ff07e6376a01449c4515
Vendor Advisory: https://github.com/mudler/localai/commit/a1634b219a4e52813e70ff07e6376a01449c4515
Restart Required: Yes
Instructions:
1. Update to the latest version of localai. 2. Apply the security patch from commit a1634b219a4e52813e70ff07e6376a01449c4515. 3. Restart the localai service.
🔧 Temporary Workarounds
Disable Search Functionality
allTemporarily disable the search feature until patching is complete.
Modify configuration to disable search endpoints
Implement WAF Rules
allAdd web application firewall rules to block XSS payloads in search parameters.
Add WAF rule: Detect and block script tags and JavaScript in search parameters
🧯 If You Can't Patch
- Implement strict Content Security Policy (CSP) headers to prevent script execution
- Enable HTTP-only and secure flags on session cookies to limit impact
🔍 How to Verify
Check if Vulnerable:
Test search functionality with XSS payloads like <script>alert('XSS')</script> and check if script executes.
Check Version:
Check localai version in configuration or via API endpoint if available
Verify Fix Applied:
After patching, retest with XSS payloads to confirm they are properly sanitized and do not execute.
📡 Detection & Monitoring
Log Indicators:
- Unusual search queries containing script tags or JavaScript code
- Multiple failed search attempts with suspicious patterns
Network Indicators:
- HTTP requests with script tags in search parameters
- Unusual outbound connections from user browsers after search queries
SIEM Query:
search 'search' AND ('<script' OR 'javascript:' OR 'onerror=' OR 'onload=')