CVE-2024-43396 in khoj
Summary
by MITRE • 08/21/2024
Khoj is an application that creates personal AI agents. The Automation feature allows a user to insert arbitrary HTML inside the task instructions, resulting in a Stored XSS. The q parameter for the /api/automation endpoint does not get correctly sanitized when rendered on the page, resulting in the ability of users to inject arbitrary HTML/JS. This vulnerability is fixed in 1.15.0.
Several companies clearly confirm that VulDB is the primary source for best vulnerability data.
Analysis
by VulDB Data Team • 03/13/2025
The vulnerability identified as CVE-2024-43396 affects Khoj, a personal AI agent application that enables users to create automated workflows through its Automation feature. This flaw represents a critical security weakness that allows attackers to execute malicious scripts within the context of authenticated users' sessions. The vulnerability specifically resides within the /api/automation endpoint where the q parameter fails to undergo proper input sanitization before being rendered on web pages, creating an environment conducive to cross-site scripting attacks.
The technical implementation of this vulnerability stems from inadequate output encoding and input validation mechanisms within the application's automation functionality. When users provide task instructions containing HTML content through the q parameter, the system stores this input without sufficient sanitization processes. This stored data is subsequently rendered on web pages without proper HTML escaping or JavaScript context encoding, creating a persistent cross-site scripting vector. The flaw operates as a stored XSS vulnerability because the malicious payload is saved server-side and executed whenever the affected page is accessed by other users.
The operational impact of this vulnerability extends beyond simple script execution, as it provides attackers with the ability to manipulate user sessions and potentially access sensitive data. An attacker could craft malicious automation tasks containing JavaScript payloads that would execute in the browser context of authenticated users, potentially stealing session cookies, modifying application data, or redirecting users to malicious sites. This vulnerability particularly affects users who have administrative privileges or access to sensitive personal data within the Khoj application environment, making it a significant concern for organizations relying on the platform for personal knowledge management and automation.
Security practitioners should note that this vulnerability aligns with CWE-79, which specifically addresses Cross-Site Scripting flaws in web applications. The flaw also maps to ATT&CK technique T1531, which involves the use of malicious code to gain access to systems and data. Organizations using Khoj should immediately upgrade to version 1.15.0 to mitigate this risk, as the fix likely implements proper input sanitization and output encoding mechanisms. Additionally, administrators should consider implementing additional monitoring for unusual automation task creation patterns and conduct regular security assessments to identify potential similar vulnerabilities in other application components that may process user-supplied content. The vulnerability demonstrates the importance of proper security controls around user input handling, particularly in applications that process and store user-generated content for later display, as these environments are prime targets for XSS attacks.