Search code examples
oracle-databasevieworacle11gprivilegessql-grant

Bypass table privilege and WITH GRANT OPTION by creating views


In Oracle, users only need privileges on view to be able to SELECT from it, more precisely, what the view see from the table. Privileges on table are not required.

Let's consider this scenario :

Table T belongs to A
A GRANT SELECT ON T to B (without GRANT OPTION)
B CREATE VIEW V AS SELECT * FROM A.T
B GRANT SELECT ON V TO C
C performing SELECT * FROM B.V

According to the rule above, C will be able to select from V, therefore equivalent to selecting from T. Is that kind of cheating ? B is effectively letting C seeing A.T although C does not have the right on T and B does not have GRANT OPTION. Is there a security hole somewhere ?


Solution

  • What you've described doesn't work. As user A:

    create table t (id number);
    
    Table T created.
    
    grant select on t to b;
    
    Grant succeeded.
    

    As user B:

    create view v as select * from a.t;
    
    View V created.
    
    grant select on v to c;
    
    SQL Error: ORA-01720: grant option does not exist for 'A.T'
    01720. 00000 -  "grant option does not exist for '%s.%s'"
    *Cause:    A grant was being performed on a view or a view was being replaced
               and the grant option was not present for an underlying object.
    *Action:   Obtain the grant option on all underlying objects of the view or
               revoke existing grants on the view.
    

    This is mentioned in the documetation:

    Note:
    To grant SELECT on a view to another user, either you must own all of the objects underlying the view or you must have been granted the SELECT object privilege WITH GRANT OPTION on all of those underlying objects. This is true even if the grantee already has SELECT privileges on those underlying objects.

    Even the grant any object privilege privilege doesn't bypass this; though there must be some (powerful) privilege that does as a full DBA can do grant select on b.v to c.