Security against select expressions in SQL

空扰寡人 提交于 2019-12-25 04:17:56

问题


Considering that you can use a select expression in a query

    select table1.ID, (select table2.salary, table1.id from table2 inner join...
from table1

and retrieve data that you don't have to reference in the from statement, how is this guarded against as far as security is concerned in enterprise DBMSs? do table permissions work so that you can not allow any references to them (since this case it isn't in your from statement)


回答1:


You can enforce column-level permissions. So that it doesn't matter if the request came from the select list, a subquery, where exists, etc.:

DENY SELECT ON OBJECT::dbo.table2(salary) TO [user/role];

You can also deny select on the underlying table entirely, and create a view that only exposes the columns you wish users to see. Or allow them to execute a stored procedure that only selects a subset.



来源:https://stackoverflow.com/questions/11595312/security-against-select-expressions-in-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!