SQL Server 2008 表值参数是否容易受到 SQL 注入攻击?
我一直在研究 SQL Server 2008 中的表值参数,我发现当将此类参数传递给存储过程时,会向数据库服务器发送如下所示的查询:
declare @p1 dbo.MyTypeName
insert into @p1 values(N'row1col1',N'row1col2')
insert into @p1 values(N'row2col1',N'row2col2')
insert into @p1 values(N'row3col1',N'row3col2')
insert into @p1 values(N'row4col1',N'row4col2')
insert into @p1 values(N'row5col1',N'row5col2')
exec StoredProcedureName @MyParam=@p1
我的问题是,针对 SQL 的安全性如何鉴于插入语句没有参数化,注入攻击是这样的吗?我尝试了对它进行最简单的攻击,并且引号被正确转义,但是有人进行了详尽的测试,或者这里还有其他事情可以保护我吗?
I have been investigating Table-Valued Parameters in SQL Server 2008, and I've discovered that when passing such a parameter to a stored procedure, a query such as the following is sent to the database server:
declare @p1 dbo.MyTypeName
insert into @p1 values(N'row1col1',N'row1col2')
insert into @p1 values(N'row2col1',N'row2col2')
insert into @p1 values(N'row3col1',N'row3col2')
insert into @p1 values(N'row4col1',N'row4col2')
insert into @p1 values(N'row5col1',N'row5col2')
exec StoredProcedureName @MyParam=@p1
My question is, how secure against SQL injection attacks is this, given that the insert statements are not parameterized? I tried the most trivial attack against it, and the quotes were properly escaped, but has anyone run an exhaustive test, or is there something else going on here that would protect me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无需担心 TVP 的 SQL 注入攻击。
来源:http://blogs.msdn.com/mikecha/archive/2009/08/07/two-fast-ways-to-bulk-insert-client- generated-data-to- sql-database.aspx
You don't need to worry about SQL Injection attacks with TVPs.
Source: http://blogs.msdn.com/mikecha/archive/2009/08/07/two-fast-ways-to-bulk-insert-client-generated-data-to-sql-database.aspx