[BUG] SQL Injection through CVE Bypass in DB-GPT 0.7.0 (CVE-2024-10835 & CVE-2024-10901) #2650
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Version: 0.7.0
Description
An SQL injection vulnerability exists in DB-GPT 0.7.0 despite fixes for prior CVEs (CVE-2024-10835 and CVE-2024-10901). Both
/v1/editor/sql/run
and/v1/editor/chart/run
endpoints remain vulnerable to SQL injection. The previous patches implemented blacklist-based protections only for DuckDB connections, but failed to address the root cause: direct execution of user-provided SQL without proper parameterization.The incomplete fix:
Source - Sink Analysis
editor_sql_run()
in/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/editor/api_editor_v1.py
editor_sql_run()
conn.query_ex()
call ineditor_sql_run()
query_ex()
in/packages/dbgpt-core/src/dbgpt/datasource/rdbms/base.py
Proof of Concept
The CVE bypass can be demonstrated with the following requests:
For any non-DuckDB database (completely unprotected):
For the chart endpoint:
For DuckDB (bypassing the blacklist protection):
Impact
Despite the fixes implemented for CVE-2024-10835 and CVE-2024-10901, attackers can still: