admin管理员组文章数量:1200986
My project needs to access a SQL Server which has hundreds databases in it. All those databases have same tables structure
So I need to query those data like this:
select *
from {0}.dbo.tableA
where fieldA = ?
The {0}
will be replaced with a dynamic database name before prepared statement is created.
Those dynamic database name comes from a server scan and users has no way to input.
VeraCode complains this code and think it has SQL injection risk.
But VeraCode didn't complain if this query has no dynamic database name. And VeraCode didn't complain if this query has no query parameter.
I also tried connection.setCatalog to avoid dynamic database name and found it is not allowed in VeraCode
I also tried to do DbName validation before replacing and still failed in VeraCode
I am confused how VeraCode decide if it has SQL injection risk.
My project needs to access a SQL Server which has hundreds databases in it. All those databases have same tables structure
So I need to query those data like this:
select *
from {0}.dbo.tableA
where fieldA = ?
The {0}
will be replaced with a dynamic database name before prepared statement is created.
Those dynamic database name comes from a server scan and users has no way to input.
VeraCode complains this code and think it has SQL injection risk.
But VeraCode didn't complain if this query has no dynamic database name. And VeraCode didn't complain if this query has no query parameter.
I also tried connection.setCatalog to avoid dynamic database name and found it is not allowed in VeraCode
I also tried to do DbName validation before replacing and still failed in VeraCode
I am confused how VeraCode decide if it has SQL injection risk.
Share Improve this question edited Jan 22 at 14:10 Justin asked Jan 21 at 20:19 JustinJustin 1,12011 silver badges31 bronze badges 8 | Show 3 more comments1 Answer
Reset to default 1If you have dbname validation you can ignore this issue. https://docs.veracode.com/r/Ignored_Issues
本文标签:
版权声明:本文标题:sql server - VeraCode complains SQL injection when my prepared statement has a dynamic database name - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738600616a2102044.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
[thing; do something bad here; --]
and another called[thing]]; do something bad here; --]
(just to cover the[{0}]
injection case). Theoretically, it might also be the case that someone exploits a vulnerability that only allows them to create an arbitrarily-named database. The SQL injection would be the missing link to gaining complete access (the needed hole in the swiss cheese model). – T N Commented Jan 22 at 4:28