SQLInjection against CosmosDB in an Azure function

大城市里の小女人 提交于 2020-01-21 11:35:32

问题


I have implemented an Azure function that is triggered by a HttpRequest. A parameter called name is passed as part of the HttpRequest. In Integration section, I have used the following query to retrieve data from CosmosDB (as an input):

SELECT * FROM c.my_collection pm 
WHERE
Contains(pm.first_name,{name}) 

As you see I am sending the 'name' without sanitizing it. Is there any SQLInjection concern here?

I searched and noticed that parameterization is available but that is not something I can do anything about here.


回答1:


When the binding occurs (the data from the HTTP Trigger gets sent to the Cosmos DB Input bind), it is passed through a SQLParameterCollection that will handle sanitization.

Please view this article:

Parameterized SQL provides robust handling and escaping of user input, preventing accidental exposure of data through “SQL injection”

This will cover any attempt to inject SQL through the name property.



来源:https://stackoverflow.com/questions/48378681/sqlinjection-against-cosmosdb-in-an-azure-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!