fix: Fix vulerability by using query parameters instead of string formatting - #233
Merged
Conversation
twishabansal
approved these changes
Jul 14, 2026
divyang-dalal
approved these changes
Jul 14, 2026
This was referenced Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR addresses a SQL injection vulnerability in
AsyncPostgresVectorStoreand improves type safety across the vector store queries.Previously,
ref_doc_iddelete operations andMetadataFiltersused 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
adelete,adelete_nodes,__query_columns,__parse_metadata_filters_recursively, and__parse_metadata_filterinasync_vector_store.pyto usebind_params.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 safeARRAY[]wrapper, preventingasyncpgtype 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_idmanipulation)