缺少sql注入攻击有错误吗?
如果我们使用最安全的方式来执行查询,例如准备好的语句或参数化查询来防止SQL注入攻击,是否可以保证在执行过程中不会发生任何数据库错误? 例如,在插入记录时发送给定类型的无效参数会导致错误,而不是使用默认值。你能举个例子吗?
If we use best secure way for executing query such as prepared statement or parameterized query to prevent SQL injection attacks, is there guarantee to not any database error occure in executing it?
for example, sending invalid parameter for a given type in inserting record, cause error instead of use default value. can you bring an example?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
参数化查询无法防止数据库错误的一个例子是,用户可以提供不适合数据库类型的输入,例如用户名字段中限制为 50 个字符的 100,000 字文章。
此外,参数化查询无法防止重复的主键错误,例如,他们在注册表单上请求的用户名已被占用。
参数化查询仅确保值不会被解释为 SQL,它不会防止任何其他形式的错误(例如由于数据库磁盘空间不足而导致 SQL 语句失败)
One example, where parameterised queries doesn't prevent database errors is a user could provide input so long it won't fit inside the database type such as a 100,000 words essay in a username field limited to 50 characters.
Also, parameterised queries won't protect against duplicate primary key errors, if say, a username they request on a registration form is already taken.
parameterised queries only ensure the values aren't interpreted as SQL, it won't prevent any other form of error (such as the SQL statement failing because the database is out of disk space)
这取决于您正在使用的数据库,但一般来说,根据类型而发生的转换通常是隐式的,因此您可以很好地传入在运行时可能无法转换为正确值的字符串。
就 SQL 注入攻击而言,只要您不希望参数包含随后动态调用的 SQL,那么您就是安全的。
This depends on the database you're using but yes in general, the conversions that happens depending on types and such are often implicit, so you could very well pass in strings that could fail at run-time to convert to a proper value.
As far as SQL injection attacks goes, as long as you don't expect parameters to contain SQL which you then invoke dynamically, you're safe.
不,不能保证某些运行时错误(如果没有其他错误的话,想想“触发”)会发生。
No there is no guarantee that some runtime error (think, 'trigger' if nothing else) will go off.