SQL Server 2008 表值参数是否容易受到 SQL 注入攻击?

发布于 2024-08-05 12:46:49 字数 510 浏览 3 评论 0原文

我一直在研究 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怪我鬧 2024-08-12 12:46:49

您无需担心 TVP 的 SQL 注入攻击。

这看起来像是一群单身人士
打电话但事实并非如此。正如我的大学
Microsoft CSS 的 Keith Elmore 指出
出,这只是使用的约定
允许显示数据或
复制/粘贴到查询窗口中并
跑步。 TVP实际上并不是
以这种方式实现——行是
像一大堆东西一样流过
插入——但它可能导致了这个
印象中它确实很简单
插入。

来源: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.

This seems like a bunch of singleton
calls but it's not. As my colleage
Keith Elmore at Microsoft CSS pointed
out, that is just the convention used
to allow the data to be displayed or
copied/pasted into a query window and
run. The TVP isn’t actually
implemented in that way—the rows are
streamed across just like a bulk
insert—but it may have led to this
impression that it does simple
inserts.

Source: http://blogs.msdn.com/mikecha/archive/2009/08/07/two-fast-ways-to-bulk-insert-client-generated-data-to-sql-database.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文