- Language: C#
- Platform: SonarQube Cloud
- Scanner: Azure Devops step (SonarCloudAnalyze@3)
In an azure function using the Isolated function model, when we use data from the HttpRequestData object to construct an sql query via concatenation, it should trigger S3649, but does not. No issues or security hotspots are flagged.
an edited down version of the relevant code is:
[Function("HttpTrigger")]
public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Function, "get")] HttpRequestData req)
{
var userId = req.Query["userId"];
var sqlQuery = $"SELECT * FROM Users WHERE UserId = '{userId}'";
var connectionString = _config.GetConnectionString("database");
using var sqlConnection = new SqlConnection(connectionString);
using var command = new SqlCommand(sqlQuery, sqlConnection);
await sqlConnection.OpenAsync();
await command.ExecuteReaderAsync();
return req.CreateResponse(System.Net.HttpStatusCode.OK);
}
or a pull request showing the vulnerable code is available at on github