Views
No views yet
| Field | Value |
|---|---|
| Repo | run-llama/llama_index |
| Package | llama-index-vector-stores-azurecosmosnosql |
| File | llama_index/vector_stores/azurecosmosnosql/base.py |
| Line | 315 |
| Commit | 9aa5ee5 (HEAD) |
| Platform | huntr.com |
1# azurecosmosnosql/base.py line 315 — VULNERABLE
2items = self._container.query_items(
3 query=f"SELECT c.id, c.id AS partitionKey FROM c "
4 f"WHERE c.{self._metadata_key}.ref_doc_id = '{ref_doc_id}'",
5 enable_cross_partition_query=True,
6)
7for item in items:
8 self._container.delete_item(item["id"], partition_key=item["partitionKey"])ref_doc_id is placed inside single quotes in a Cosmos SQL API query with no parameterization. Azure Cosmos SQL API supports SQL-like string literals and OR operators. The returned items are all deleted.vector_store.delete(ref_doc_id) → AzureCosmosNoSqlVectorStore.delete() → raw f-string query → Cosmos SQL API → deletes ALL returned itemspython3 poc_cosmos_sqli.pyWHERE c.metadata.ref_doc_id = 'doc_abc123' → deletes one itemWHERE c.metadata.ref_doc_id = '' OR '1'='1' → returns ALL items → deletes entire container1items = self._container.query_items(
2 query=(
3 "SELECT c.id, c.id AS partitionKey FROM c "
4 "WHERE c." + self._metadata_key + ".ref_doc_id = @ref_doc_id"
5 ),
6 parameters=[{"name": "@ref_doc_id", "value": ref_doc_id}],
7 enable_cross_partition_query=True,
8)