.net viewstate 免受 SQL 注入的影响吗?
我使用命令名和命令参数来控制排序(字段和方向)。视图状态免受 SQL 注入的安全性如何。
I am using commandname and commandargument to control sorting (field and direction). How secure is the viewstate from SQL injection.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
SQL注入是将用户输入的值直接放入查询中,从而允许恶意用户访问或破坏利用您的安全漏洞来攻击您的数据库。例如,您有一个要搜索的文本框,并且它们输入的值位于实际查询中。
除非您的命令参数是由用户动态输入的,否则 SQL 注入不会构成威胁。
SQL injection is where user-entered values are put directly into queries, allowing malicious users to access or damage your database by taking advantage of your security loopholes. For example, you have a textbox to search, and the value they enter goes inside the actual query.
Unless your command argument is dynamically entered by the user then SQL injection wouldn't be a threat.
如果您使用原始 SQL,那么您可能会使用
DataTable
对象,对吧?如果您使用的是 DataTable,则可以在使用DataView
从数据库中提取数据后对其进行排序,并将控件绑定到 DataView。这样,您就不会授予用户提交的 SQL 数据访问权限。所以,在你的代码中你会做这样的事情:If you are using raw SQL, then you are likely using
DataTable
objects, right? If you are using a DataTable, then you can sort that data after it's pulled from the database using aDataView
and bind your control to the DataView. That way, you're not giving user submitted data access to your SQL. So, in your code you'd do something like this:如果您要将 ViewState 中的值传递到串联 SQL 中,那么可以。但是,如果您使用绑定参数(您是,不是吗? ?)那么你就不用担心了。
差:
好:
If you are passing values from the ViewState into concatenated SQL, then yes. However, if you're using Bind Parameters (you are, aren't you?) then you don't have to worry about it.
Bad:
Good:
这取决于“直接放入 SQL 查询”是否意味着它们是参数化查询的参数或作为文字......如果作为文字,那么答案是否定的。
It depends whether "put directly into a SQL Query" means they are parameters of a parameterized Query or as literals... if as literals then the answer is NO.