Skip to content

fix: Fix vulerability by using query parameters instead of string formatting - #233

Merged
dishaprakash merged 3 commits into
mainfrom
fix-vulnerability
Jul 21, 2026
Merged

fix: Fix vulerability by using query parameters instead of string formatting#233
dishaprakash merged 3 commits into
mainfrom
fix-vulnerability

Conversation

@dishaprakash

@dishaprakash dishaprakash commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Description

This PR addresses a SQL injection vulnerability in AsyncPostgresVectorStore and improves type safety across the vector store queries.

Previously, ref_doc_id delete operations and MetadataFilters used f-string interpolation to construct SQL queries, which allowed unescaped user-controlled values to be directly injected into the SQL statement. This PR migrates all raw string concatenations to use SQLAlchemy's secure parameter binding (:param).

Key Changes

  • SQL Injection Fix: Refactored adelete, adelete_nodes, __query_columns, __parse_metadata_filters_recursively, and __parse_metadata_filter in async_vector_store.py to use bind_params.
  • Array Operator Support: Updated parameterization logic for Postgres array operations (IN, NIN, ANY, ALL). The fix dynamically unpacks Python lists into individual scalar variables (e.g., :param_0_0, :param_0_1) and constructs a safe ARRAY[] wrapper, preventing asyncpg type serialization errors.

Impact

Prevents potential data exfiltration and unauthorized deletion (e.g., bypassing tenant isolation by injecting metadata parameters or dropping entire tables via ref_doc_id manipulation)

@dishaprakash
dishaprakash requested review from a team as code owners July 14, 2026 11:16
@product-auto-label product-auto-label Bot added the api: alloydb Issues related to the googleapis/llama-index-alloydb-pg-python API. label Jul 14, 2026
@twishabansal twishabansal added the priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. label Jul 21, 2026
@dishaprakash
dishaprakash merged commit 18f0247 into main Jul 21, 2026
17 checks passed
@dishaprakash
dishaprakash deleted the fix-vulnerability branch July 21, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: alloydb Issues related to the googleapis/llama-index-alloydb-pg-python API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants