Proxy User Authentication and Connect Through in Oracle Databases
Connect to other database users without knowing their passwords using proxy users.
oracle miscconfigurationintermediate
by OracleDba
53 views
Connect to other database users without knowing their passwords using proxy users.
123456789101112131415161718192021222324252627282930313233343536373839
-- Connect to a privileged user.
conn sys/SysPassword1@//localhost:1521/pdb1 as sysdba
--drop user schema_owner cascade;
--drop user my_user_1 cascade;
-- Create SCHEMA_OWNER.
create user schema_owner identified by SecretPassword1;
grant create session to schema_owner;
-- Create proxy user.
create user my_user_1 identified by MyPassword1;
grant create session to my_user_1;
alter user schema_owner grant connect through my_user_1;
SQL> conn my_user_1[schema_owner]/MyPassword1@//localhost:1521/pdb1
SQL> show user
USER is "SCHEMA_OWNER"
SQL>
alter user schema_owner revoke connect through my_user_1;
-- Normal proxy.
alter user schema_owner grant connect through my_user_1;
-- Limit privileges to a specific role granted to the destination user.
alter user schema_owner grant connect through my_user_1 with role test_role;
-- Force authentication for authenticated roles.
alter user schema_owner grant connect through my_user_1 with role test_role authentication required;
-- Disable a specific role from the destination user.
alter user schema_owner grant connect through my_user_1 with role all except test_role;
-- Disable all roles from the destination user.
alter user schema_owner grant connect through my_user_1 with no roles;123456789101112131415161718192021222324252627282930313233343536373839404142
select * from proxy_users;
PROXY CLIENT AUT FLAGS
------------------------------ ------------------------------ --- -----------------------------------
MY_USER_1 SCHEMA_OWNER NO PROXY MAY ACTIVATE ALL CLIENT ROLES
SQL>
select s.sid, s.serial#, s.username, s.osuser, sci.authentication_type
from v$session s,
v$session_connect_info sci
where s.sid = sci.sid
and s.serial# = sci.serial#
and sci.authentication_type = 'PROXY';
select dbusername,
dbproxy_username
from unified_audit_trail
where dbproxy_username is not null;
DBUSERNAME DBPROXY_USERNAME
-------------------- --------------------
SCHEMA_OWNER MY_USER_1
SQL>
column session_user format a20
column session_schema format a20
column current_schema format a20
column proxy_user format a20
select sys_context('userenv','session_user') as session_user,
sys_context('userenv','session_schema') as session_schema,
sys_context('userenv','current_schema') as current_schema,
sys_context('userenv','proxy_user') as proxy_user
from dual;
SESSION_USER SESSION_SCHEMA CURRENT_SCHEMA PROXY_USER
-------------------- -------------------- -------------------- --------------------
SCHEMA_OWNER SCHEMA_OWNER SCHEMA_OWNER MY_USER_1
SQL>123456789101112131415161718192021222324252627282930313233343536373839
-- Get the current password hash.
conn / as sysdba
select password
from dba_users
where username = 'SCOTT';
PASSWORD
------------------------------
F894844C34402B67
1 row selected.
SQL>
-- Reset the password to a known value.
alter user scott identified by DummyPassword1;
-- use the known password to connect to the user and perform the task.
conn scott/DummyPassword1;
-- #### Do the task now. ####
-- Reset the password using the hash.
conn / as sysdba
alter user scott identified by values 'F894844C34402B67';
select password
from sys.user$
where name = 'SCOTT';
PASSWORD
------------------------------
F894844C34402B67
1 row selected.
SQL>Please to add comments
No comments yet. Be the first to comment!