
JBuzek864926 (Community Member) asked a question.
Hello,
My dev stack is .NET + SQL Server.
In the following stored procedure we use QUOTENAME() to mitigate CWE-89:
Static scan did not find any flaws in this stored procedure.
Can we use the same technique to mitigate CWE-89 in .NET code?
Simple example:
The QuoteIdentifier() method should provide same functionality as T-SQL QUOTENAME().
Thanks.
.png)
Hi @JBuzek864926 (Community Member),
Since the table name seems to come directly from the HTTP request, I would recommend validating it against a strict allow-list. At this point, it is not only about SQL Injection but also about an attacker potentially being able to insert data into arbitrary tables. Presumably, you have an idea what tables this functionality should be able to access. Please implement an allow-list to make sure that the provided table name conforms to this expectation.
Using an allow-list is something that Veracode Static Analysis can automatically detect and close the finding if applied in a certain way. The following Knowledge Article describes how to do this: https://community.veracode.com/s/article/Using-an-Allow-list-in-a-Way-Static-Analysis-can-Detect
Thanks,
Florian Walter