Onyx SQL Injection Vulnerability in Chat Interface Component
Vulnerability
A critical SQL injection vulnerability has been identified in Onyx versions through 0.29.1. The issue arises in the Chat Interface component, specifically within the 'generate_simple_sql' function of the file 'backend/onyx/agents/agent_search/kb_search/nodes/a3_generate_simple_sql.py'. This vulnerability allows remote attackers to inject arbitrary SQL code, potentially leading to unauthorized access to sensitive database information, such as user credentials.
Impact
Exploitation of this vulnerability allows for arbitrary SQL code execution, which could result in unauthorized data access, including sensitive user information and credentials. Additionally, if the database user has write permissions, there could be further implications, such as data modification or deletion.
Reproduction
To reproduce this vulnerability, send a crafted message through the application's chat interface API. The message should be designed to exploit the 'generate_simple_sql' function by injecting SQL payloads that manipulate the SQL query execution. This can be done by including SQL injection techniques, such as closing string literals and appending UNION SELECT statements, to extract data from the database.
Remediation
It is recommended to disable the vulnerable Knowledge Graph query tool in 'choose_tool.py' or implement strict input validation to block suspicious patterns. A definitive fix would involve refactoring the 'generate_simple_sql' function to prevent SQL injection, such as by using parameterized queries with a trusted library like SQLAlchemy.
Vulnerability Rating
Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.
