Grant create any trigger vs grant create trigger

◇◆丶佛笑我妖孽 提交于 2019-12-11 08:02:11

问题


In Oracle you can grant system privileges like

GRANT CREATE TRIGGER TO MY_USER;

But you can as well grant privileges this way

GRANT CREATE ANY TRIGGER TO MY_USER;

As system privileges are system-wide, where is the difference between the 2 statements above. Does the additional ANY-keyword grant anything else more than system? If I add a Grant ... ON SCHEMA ... it's no system privilege anymore, is it?

Assumption is that there are multiple schemas/objects in the database from different users one cannot access without these privileges.

EDIT:

SELECT *
FROM DBA_SYS_PRIVS
WHERE grantee = 'MY_USER';

returns

GRANTEE      PRIVILEGE                              
------------ -------------
MY_USER      CREATE ANY TRIGGER
MY_USER      CREATE TRIGGER

(I omitted the columns ADMIN_OPTION and COMMON)

And the result is the same when querying this with MY_USER, MY_USER2 or any other user. I see no connection to a schema here. And it is also possible to only have the CREATE ANY TRIGGER-privilege.


回答1:


In most cases, the trigger owner is also the owner of the table (or view) on which the trigger is based. In those cases, the table owner, with CREATE TRIGGER can create create triggers on their own table.

CREATE ANY TRIGGER allows the user to create a trigger owned by any user on any table. It is a big security hole because they can create a trigger owned by a privileged user on a table that they own or can insert into. Because they can insert into that table, they can force the trigger to execute and the trigger executes with the privileges of the trigger owner. The effect is that a user with CREATE ANY TRIGGER privilege can create and execute code as a privileged user (similar to having CREATE ANY PROCEDURE plus EXECUTE ANY PROCEDURE).

Limit to as few as people as possible and audit appropriately.




回答2:


The first statements grants the right to create triggers in the schema of MY_USER. The owner will always by MY_USER.

The second statements grants the right to create triggers in ANY schema. The owner of the trigger can then be any user.

The last option is usually not wanted because it gives user MY_USERS the possibility to corrupt the data model.



来源:https://stackoverflow.com/questions/49256959/grant-create-any-trigger-vs-grant-create-trigger

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