We have a SQL statement that uses the SqlBuilder
set the table name in the from clause. The database is SQL Server 2008 and up.
var sqlBuilder = new SqlBuilder();
sqlBuilder.Select("*").From(tableName);
sqlBuilder.Where("...");
Connection.BuilderQuery<dynamic>(sqlBulder).Select(Map);
I am wondering if this is a SQL injection risk? and how can I mitigate that risk? Or does the SqlBuilder
take care of these things?
Could I mitigate the risk simply by wrapping the table name in square brackets? e.g.
sqlBuilder.From("[" + tableName + "]");
Also it would be most appreciated if someone could provide some examples of a SQL injection attack in the FROM
clause so that I can understand how it works and create tests.