如果我的数据库用户是只读的,为什么我需要担心sql注入?
他们(恶意用户)可以描述表格并获取重要信息吗?如果我将用户锁定到特定表怎么办?我并不是说我想要 sql 注入,但我想知道我们的旧代码很容易受到影响,但 db 用户已被锁定。谢谢。
编辑:我明白你在说什么,但如果我没有其他数据的response.write,他们怎么能看到它。爬行和执行操作是有道理的,其他人也是如此,但他们如何实际看到数据呢?
Can they (malicious users) describe tables and get vital information? What about if I lock down the user to specific tables? I'm not saying I want sql injection, but I wonder about old code we have that is susceptible but the db user is locked down. Thank you.
EDIT: I understand what you are saying but if I have no response.write for the other data, how can they see it. The bringing to crawl and dos make sense, so do the others but how would they actually see the data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
有人可以注入 SQL 来导致授权检查返回 true 而不是 false 的等效值,从而获得对本应禁止访问的内容的访问权限。
或者,他们可以将目录表的连接注入到自身 20 或 30 次,从而使数据库性能变得极其缓慢。
或者他们可以调用一个以不同数据库用户身份运行的存储过程,会修改数据。
Someone could inject SQL to cause an authorization check to return the equivalent of true instead of false to get access to things that should be off-limits.
Or they could inject a join of a catalog table to itself 20 or 30 times to bring database performance to a crawl.
Or they could call a stored procedure that runs as a different database user that does modify data.
是的,您应该将它们锁定为仅它们实际上应该能够看到的数据(表/视图),特别是如果它是公开的。
Yes, you should lock them down to only the data (tables/views) they should actually be able to see, especially if it's publicly facing.
仅当您不介意任意用户读取整个数据库时。例如,这是一个简单的可注入登录序列:
我只需使用任何用户名和密码 ' 或 1 = 1 登录即可以该用户身份登录。
Only if you don't mind arbitrary users reading the entire database. For example, here's a simple, injectable login sequence:
I just have to log in with any username and password ' or 1 = 1 to log in as that user.
要特别小心。我假设您已经删除了 drop table、alter table、create table 和 truncate table,对吗?
基本上,通过良好的 SQL 注入,您应该能够更改依赖于数据库的任何内容。这可能是授权、许可、对外部系统的访问……
您是否曾经将从数据库检索到的数据写入磁盘?在这种情况下,他们可以上传 perl 等可执行文件和 perl 文件,然后执行它们以更好地访问您的盒子。
您还可以通过利用预期特定返回值的情况来确定数据是什么。即如果SQL返回true,则继续执行,如果不是,则停止执行。然后,您可以在 SQL 中使用二分搜索。选择 count(*) 其中 user_password > 'H';如果计数> 0 继续。现在,您可以找到准确的纯文本密码,而无需将其打印在屏幕上。
此外,如果您的应用程序没有针对 SQL 错误进行强化,则可能会出现这样的情况:它们可以在 SQL 或结果的 SQL 中注入错误,并在错误处理程序期间将结果显示在屏幕上。第一个 SQL 语句收集了一个很好的用户名和密码列表。第二条语句尝试在不适合的 SQL 条件中利用它们。如果 SQL 语句显示在这种错误情况下,...
Jacob
Be very careful. I am assuming that you have removed drop table, alter table, create table, and truncate table, right?
Basically, with good SQL Injection, you should be able to change anything that is dependent on the database. This could be authorization, permissions, access to external systems, ...
Do you ever write data to disk that was retrieved from the database? In that case, they could upload an executable like perl and a perl file and then execute them to gain better access to your box.
You can also determine what the data is by leveraging a situation where a specific return value is expected. I.e. if the SQL returns true, execution continues, if not, execution stops. Then, you can use a binary search in your SQL. select count(*) where user_password > 'H'; If the count is > 0 it continues. Now, you can find the exact plain text password without requiring it to ever be printed on the screen.
Also, if your application is not hardened against SQL errors, there might be a case where they can inject an error in the SQL or in the SQL of the result and have the result display on the screen during the error handler. The first SQL statement collects a nice list of usernames and passwords. The second statement tries to leverage them in a SQL condition for which they are not appropriate. If the SQL statement is displayed in this error condition, ...
Jacob
我阅读了这个问题和答案,因为我正在使用只读用户创建一个 SQL 教程网站允许最终用户运行任何 SQL。
显然这是有风险的,而且我犯了几个错误。以下是我在前 24 小时内了解到的内容(是的,其他答案涵盖了大部分内容,但这些信息更具可操作性)。
Postgres:
您想要的架构:
Postgres:
Postgres:
Postgres:
编辑:请注意,通过完全删除对系统表的访问,您将不再允许用户进行诸如cast()之类的调用。因此,您可能需要再次运行此命令以允许访问:
I read this question and answers because I was in the process of creating a SQL tutorial website with a readonly user that would allow end users to run any SQL.
Obviously this is risky and I made several mistakes. Here is what I learnt in the first 24 hours (yes most of this is covered by other answers but this information is more actionable).
Postgres:
the schema you want:
Postgres:
Postgres:
Postgres:
Edit: Note by completely removing access to system tables you no longer allow the user to make calls like cast(). So you may want to run this again to allow access:
是的,继续担心SQL注入。 恶意 SQL 语句不仅仅涉及写入。
想象一下,如果存在链接服务器或编写查询来访问跨数据库资源。 IE
Yes, continue to worry about SQL injection. Malicious SQL statements are not just about writes.
Imagine as well if there were Linked Servers or the query was written to access cross-db resources. i.e.
Oracle 存在一个错误,允许您通过调用带有错误参数的公共(但未记录)方法来使实例崩溃。
There was an Oracle bug that allowed you to crash the instance by calling a public (but undocumented) method with bad parameters.