Skip to content

Parameterize Azure Cosmos key-value queries - #3720

Merged
itowlson merged 1 commit into
spinframework:mainfrom
ChihweiLHBird:fix-cosmos-kv-sql-injection
Sep 17, 2026
Merged

itowlson merged 1 commit into
spinframework:mainfrom
ChihweiLHBird:fix-cosmos-kv-sql-injection

Conversation

@ChihweiLHBird

Copy link
Copy Markdown
Contributor

Keys and store ids were interpolated into the Cosmos SQL text, so a key containing ' could break out of the literal and read or match other rows. This binds them as query parameters via Query::with_params instead.

Verified against a live Cosmos DB container through get, exists, get_keys, get_many, increment and compare-and-swap with quoted and injection-shaped keys.

Keys and store ids were interpolated into the Cosmos SQL text, so a key containing a single quote could break out of the literal and read or match other rows. Bind them as query parameters instead.

Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
@itowlson

Copy link
Copy Markdown
Contributor

Nice! Thanks for finding this!

@itowlson
itowlson merged commit 0ce10ee into spinframework:main Sep 17, 2026
17 checks passed
@ChihweiLHBird
ChihweiLHBird deleted the fix-cosmos-kv-sql-injection branch September 17, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants