How to Prevent a User Granted the ALTER USER Privilege From Changing SYS/SYSTEM password and how to bypass it

I found the following nice article „How to Prevent a User Granted the ALTER USER Privilege From Changing SYS/SYSTEM password“ [271077.1] on My Oracle Support. As always if I see PL/SQL code I am looking for ways to find security problems or to bypass limitations.

SQL> connĀ  / as sysdba
Connected.

SQL> CREATE or REPLACE TRIGGER prohibit_alter_SYSTEM_SYS_pass
AFTER ALTER on SCOTT.schema
BEGIN
IF ora_sysevent=’ALTER‘ and ora_dict_obj_type = ‚USER‘ and
(ora_dict_obj_name = ‚SYSTEM‘ or ora_dict_obj_name = ‚SYS‘)
THEN
RAISE_APPLICATION_ERROR(-20003,
‚You are not allowed to alter SYSTEM/SYS user.‘);
END IF;
END;
/

Trigger created.

SQL> conn scott/tiger
Connected.

SQL>alter user system identified by alex;
alter user system identified by alex
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-20003: You are not allowed to alter SYSTEM/SYS user.
ORA-06512: at line 5

SQL> alter user sys identified by alex;
alter user sys identified by alex
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-20003: You are not allowed to alter SYSTEM/SYS user.
ORA-06512: at line 5

SQL> alter user dbsnmp identified by dbsnmp;
User altered.

Many Oracle users are not aware that the grant command can also be used to change passwords or even create users („grant dba to user1,user2 identified by user1,user2“). In our case we can use this technique to bypass the database trigger.
SQL> grant connect to sys identified by alex;
Grant succeeded.

SQL> grant connect to system identified by alex;
Grant succeeded.

To fix this problem we have to block grant commands as well….

Comments are closed.