اوراکل 23ai- قابلیت Dictionary Protection

زمانی که یکی از مجوزهای system “ANY” privilege نظیر select any table، drop any table و … را به کاربری می دهیم، آن کاربر امکان دسترسی به objectهای شمای sys و جداول Data Dictionary را ندارد:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL*Plus: Release 10.1.0.4.2 - Production on Tue Jan 9 10:38:31 2024
SQL> show user
USER is "SYS"
SQL> create table sys.tb as select * from dual;
Table created.
SQL*Plus: Release 10.1.0.4.2 - Production on Tue Jan 9 10:38:31 2024 SQL> show user USER is "SYS" SQL> create table sys.tb as select * from dual; Table created.
SQL*Plus: Release 10.1.0.4.2 - Production on Tue Jan 9 10:38:31 2024
SQL> show user
USER is "SYS"
SQL> create table sys.tb as select * from dual;
Table created.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> create user usef identified by a;
User created.
SQL> grant create session,select any table to usef;
Grant succeeded.
SQL> create user usef identified by a; User created. SQL> grant create session,select any table to usef; Grant succeeded.
SQL> create user usef identified by a;
User created.
SQL> grant create session,select any table to usef;
Grant succeeded.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> conn usef/a
Connected.
SQL> select * from sys.tb;
ORA-00942: table or view does not exist
SQL> select * from v$datafile;
ORA-00942: table or view does not exist
SQL> conn usef/a Connected. SQL> select * from sys.tb; ORA-00942: table or view does not exist SQL> select * from v$datafile; ORA-00942: table or view does not exist
SQL> conn usef/a
Connected.
SQL> select * from sys.tb;
ORA-00942: table or view does not exist
SQL> select * from v$datafile;
ORA-00942: table or view does not exist

اگر تصمیم داریم این محدودیت را حداقل در مورد مجوز select any table برای یک کاربر برداریم، می توانیم مجوز SELECT ANY DICTIONARY را به آن کاربر اعطا کنیم:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> grant SELECT ANY DICTIONARY to usef;
Grant succeeded.
SQL> conn usef/a
Connected.
SQL> select * from sys.tb;
D
-
X
SQL> select file# from v$datafile where rownum=1;
FILE#
----------
1
SQL> grant SELECT ANY DICTIONARY to usef; Grant succeeded. SQL> conn usef/a Connected. SQL> select * from sys.tb; D - X SQL> select file# from v$datafile where rownum=1; FILE# ---------- 1
SQL> grant SELECT ANY DICTIONARY to usef;
Grant succeeded.
SQL> conn usef/a
Connected.
SQL> select * from sys.tb;
D
-
X
SQL> select file# from v$datafile where rownum=1;
     FILE#
----------
         1

البته از اوراکل 12c، دسترسی به بعضی از جداول Data Dictionary حتی با داشتن مجوز  SELECT ANY DICTIONARY  هم امکان پذیر نیست. لیست بعضی از این جداول را در قسمت زیر می بینید:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
USER$, ENC$ , DEFAULT_PWD$, LINK$, USER_HISTORY$, CDB_LOCAL_ADMINAUTH$, XS$VERIFIERS
USER$, ENC$ , DEFAULT_PWD$, LINK$, USER_HISTORY$, CDB_LOCAL_ADMINAUTH$, XS$VERIFIERS
USER$, ENC$ , DEFAULT_PWD$, LINK$, USER_HISTORY$, CDB_LOCAL_ADMINAUTH$, XS$VERIFIERS

نقش SELECT_CATALOG_ROLE هم می تواند دسترسی به ویوهای دیتادیکشنری را به کاربر اعطا کند که قبلا در مورد تفاوت این نقش با مجوز SELECT ANY DICTIONARY مطلبی را نوشته ایم.

شکل پیشرفته تر از مجوز SELECT ANY DICTIONARY پارامتر o7_dictionary_accessibility است که با تنظیم این پارامتر به مقدار true، هر کاربری که هر کدام از مجوزهای system “ANY” privilege را دریافت می کرد، می توانست به جداول Data Dictionary هم در همان سطح دسترسی داشته باشد(البته مقدار پیش فرض این پارامتر به مقدار false تنظیم شده بود):

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL*Plus: Release 10.1.0.4.2 - Production on Tue Jan 9 11:26:57 2024
SQL> show parameter o7_dictionary_accessibility
NAME TYPE VALUE
------------------------------------ ----------- -------------------------
O7_DICTIONARY_ACCESSIBILITY boolean FALSE
SQL> alter system set O7_DICTIONARY_ACCESSIBILITY=true scope=spfile;
System altered.
SQL> startup force;
SQL*Plus: Release 10.1.0.4.2 - Production on Tue Jan 9 11:26:57 2024 SQL> show parameter o7_dictionary_accessibility NAME TYPE VALUE ------------------------------------ ----------- ------------------------- O7_DICTIONARY_ACCESSIBILITY boolean FALSE SQL> alter system set O7_DICTIONARY_ACCESSIBILITY=true scope=spfile; System altered. SQL> startup force;
SQL*Plus: Release 10.1.0.4.2 - Production on Tue Jan 9 11:26:57 2024
SQL> show parameter o7_dictionary_accessibility
NAME                                 TYPE        VALUE
------------------------------------ ----------- -------------------------
O7_DICTIONARY_ACCESSIBILITY          boolean     FALSE
SQL> alter system set O7_DICTIONARY_ACCESSIBILITY=true scope=spfile;
System altered.
SQL> startup force;
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> create user usef identified by a;
User created.
SQL> grant create session,select any table to usef;
Grant succeeded.
SQL> select file# from v$datafile where rownum=1;
FILE#
----------
1
SQL> select * from sys.tb;
D
-
X
SQL> create user usef identified by a; User created. SQL> grant create session,select any table to usef; Grant succeeded. SQL> select file# from v$datafile where rownum=1; FILE# ---------- 1 SQL> select * from sys.tb; D - X
SQL> create user usef identified by a;
User created.
SQL> grant create session,select any table to usef;
Grant succeeded.
SQL> select file# from v$datafile where rownum=1;
     FILE#
----------
         1
SQL> select * from sys.tb;
D
-
X

این پارامتر از نسخه 19c به صورت کامل حذف شده است.

در نسخه 23c، اوراکل دامنه این محدودیتها را افزایش داده و Dictionary Protection را برای کاربران زیر هم فعال کرده است:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> select username,ORACLE_MAINTAINED from dba_users where dictionary_protected='YES';
USERNAME ORACLE_MAINTAINED
------------------ --------------------
SYSRAC Y
XS$NULL Y
LBACSYS Y
CTXSYS Y
DVF Y
DVSYS Y
AUDSYS Y
GSMADMIN_INTERNAL Y
GGSHAREDCAP Y
XDB Y
SYSBACKUP Y
SYSKM Y
SYSDG Y
13 rows selected.
SQL> select username,ORACLE_MAINTAINED from dba_users where dictionary_protected='YES'; USERNAME ORACLE_MAINTAINED ------------------ -------------------- SYSRAC Y XS$NULL Y LBACSYS Y CTXSYS Y DVF Y DVSYS Y AUDSYS Y GSMADMIN_INTERNAL Y GGSHAREDCAP Y XDB Y SYSBACKUP Y SYSKM Y SYSDG Y 13 rows selected.
SQL> select username,ORACLE_MAINTAINED from dba_users where dictionary_protected='YES';
USERNAME           ORACLE_MAINTAINED
------------------ --------------------
SYSRAC             Y
XS$NULL            Y
LBACSYS            Y
CTXSYS             Y
DVF                Y
DVSYS              Y
AUDSYS             Y
GSMADMIN_INTERNAL  Y
GGSHAREDCAP        Y
XDB                Y
SYSBACKUP          Y
SYSKM              Y
SYSDG              Y
13 rows selected.

بنابرین اگر کاربری یکی از مجوزهای system “ANY” privilege را داشته باشد، نمی تواند صرفا با داشتن این مجوزها، به جداول هر کدام از اسکیماهای فوق دسترسی داشته باشد.

برای مثال، جدولی را برای اسکیمای SYSDG ایجاد می کنیم با توجه به آنکه قابلیت Data Dictionary Protection برای این Schema فعال شده است، جداول این Schema هم همانند جداول دیتا دیکشنری برای کاربر c##usef که مجوز select any table دارد، قابل رویت نخواهد بود:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Tue Jan 9 13:25:56 2024
SQL> create user c##usef identified by a;
User created.
SQL> grant create session,select any table to c##usef;
Grant succeeded.
SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Tue Jan 9 13:25:56 2024 SQL> create user c##usef identified by a; User created. SQL> grant create session,select any table to c##usef; Grant succeeded.
SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Tue Jan 9 13:25:56 2024
SQL> create user c##usef identified by a;
User created.
SQL> grant create session,select any table to c##usef;
Grant succeeded.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> grant unlimited tablespace to SYSDG;
Grant succeeded.
SQL> create table SYSDG.tb as select * from dual;
Table created.
SQL> grant unlimited tablespace to SYSDG; Grant succeeded. SQL> create table SYSDG.tb as select * from dual; Table created.
SQL> grant unlimited tablespace to SYSDG;
Grant succeeded.
SQL> create table SYSDG.tb as select * from dual;
Table created.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> conn c##usef/a
Connected.
SQL> select * from SYSDG.tb;
ORA-00942: table or view does not exist
SQL> conn c##usef/a Connected. SQL> select * from SYSDG.tb; ORA-00942: table or view does not exist
SQL> conn c##usef/a
Connected.
SQL> select * from SYSDG.tb;
ORA-00942: table or view does not exist

اما همین سناریو در نسخه 21c به خطا نخواهد خورد:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Tue Jan 9 13:25:56 2024
SQL> create user c##usef identified by a;
User created.
SQL> grant create session,select any table to c##usef;
Grant succeeded.
SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Tue Jan 9 13:25:56 2024 SQL> create user c##usef identified by a; User created. SQL> grant create session,select any table to c##usef; Grant succeeded.
SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Tue Jan 9 13:25:56 2024
SQL> create user c##usef identified by a;
User created.
SQL> grant create session,select any table to c##usef;
Grant succeeded.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> grant unlimited tablespace to SYSDG;
Grant succeeded.
SQL> create table SYSDG.tb as select * from dual;
Table created.
SQL> grant unlimited tablespace to SYSDG; Grant succeeded. SQL> create table SYSDG.tb as select * from dual; Table created.
SQL> grant unlimited tablespace to SYSDG;
Grant succeeded.
SQL> create table SYSDG.tb as select * from dual;
Table created.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> conn c##usef/a
Connected.
SQL> select * from SYSDG.tb;
D
-
X
SQL> conn c##usef/a Connected. SQL> select * from SYSDG.tb; D - X
SQL> conn c##usef/a
Connected.
SQL> select * from SYSDG.tb;
D
-
X

قابلیت Data dictionary protection برای هر کاربری نمی تواند فعال شود و کاربر باید از نوع Oracle maintained  باشد:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> alter user C##usef enable dictionary protection;
ORA-40374: Dictionary protection feature is supported for only Oracle maintained users.
SQL> alter user C##usef enable dictionary protection; ORA-40374: Dictionary protection feature is supported for only Oracle maintained users.
SQL>  alter user C##usef enable dictionary protection;
ORA-40374: Dictionary protection feature is supported for only Oracle maintained users.

البته امکان فعال کردن این قابلیت برای همه Oracle maintained userها هم وجود ندارد و اسکیما باید از نوع NO AUTHENTICATION هم باشد:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> alter user SYSTEM enable dictionary protection;
ORA-40369: Only NO AUTHENTICATION user can be marked as dictionary protected.
SQL> alter user SYSTEM enable dictionary protection; ORA-40369: Only NO AUTHENTICATION user can be marked as dictionary protected.
SQL> alter user SYSTEM enable dictionary protection;
ORA-40369: Only NO AUTHENTICATION user can be marked as dictionary protected.

کاربر DGPDB_INT این شرایط را دارد:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> select USERNAME,dictionary_protected,AUTHENTICATION_TYPE,ORACLE_MAINTAINED from dba_users where username=’DGPDB_INT’;
USERNAME DIC AUTHENTI ORACLE_MAINTAINED
---------- --- -------- ------------------
DGPDB_INT NO NONE Y
SQL> select USERNAME,dictionary_protected,AUTHENTICATION_TYPE,ORACLE_MAINTAINED from dba_users where username=’DGPDB_INT’; USERNAME DIC AUTHENTI ORACLE_MAINTAINED ---------- --- -------- ------------------ DGPDB_INT NO NONE Y
SQL>  select USERNAME,dictionary_protected,AUTHENTICATION_TYPE,ORACLE_MAINTAINED from dba_users where  username=’DGPDB_INT’;
USERNAME   DIC AUTHENTI ORACLE_MAINTAINED
---------- --- -------- ------------------
DGPDB_INT  NO  NONE     Y

برای این کاربر می توانیم قابلیت Data Dictionary Protection را فعال کنیم قبل از این کار، دسترسی کاربر c##usef را بر روی جداول این Schema تست می کنیم:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Tue Jan 9 14:23:29 2024
SQL> create table DGPDB_INT.tb as select * from dual;
Table created.
SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Tue Jan 9 14:23:29 2024 SQL> create table DGPDB_INT.tb as select * from dual; Table created.
SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Tue Jan 9 14:23:29 2024
SQL> create table DGPDB_INT.tb as select * from dual;
Table created.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> conn c##usef/a
Connected.
SQL> select * from DGPDB_INT.tb;
D
-
X
SQL> conn c##usef/a Connected. SQL> select * from DGPDB_INT.tb; D - X
SQL> conn c##usef/a
Connected.
SQL> select * from DGPDB_INT.tb;
D
-
X

کاربر c##Usef به جداول این اسکیما دسترسی دارد. قابلیت Data Dictionary Protection را برای این اسکیما فعال می کنیم:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> alter user SYSTEM enable dictionary protection;
ORA-40369: Only NO AUTHENTICATION user can be marked as dictionary protected.
SQL> alter user DGPDB_INT enable dictionary protection;
User altered.
SQL> alter user SYSTEM enable dictionary protection; ORA-40369: Only NO AUTHENTICATION user can be marked as dictionary protected. SQL> alter user DGPDB_INT enable dictionary protection; User altered.
SQL> alter user SYSTEM enable dictionary protection;
ORA-40369: Only NO AUTHENTICATION user can be marked as dictionary protected.

SQL> alter user DGPDB_INT enable dictionary protection;
User altered.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> conn c##usef/a
Connected.
SQL> select * from DGPDB_INT.tb;
ORA-00942: table or view does not exist
SQL> conn c##usef/a Connected. SQL> select * from DGPDB_INT.tb; ORA-00942: table or view does not exist
SQL> conn c##usef/a
Connected.
SQL> select * from DGPDB_INT.tb;
ORA-00942: table or view does not exist

با کمک پارامتر مخفی oracle_script_ هم می توان اسکیمای oracle maintain ساخت و این قابلیت را برای آن فعال کرد:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> show con_name
CON_NAME
--------------------
CDB$ROOT
SQL> alter session set "_oracle_script"=true;
Session altered.
SQL> create user usef;
User created.
SQL> show con_name CON_NAME -------------------- CDB$ROOT SQL> alter session set "_oracle_script"=true; Session altered. SQL> create user usef; User created.
SQL> show con_name
CON_NAME
--------------------
CDB$ROOT
SQL> alter session set "_oracle_script"=true;
Session altered.
SQL> create user usef;
User created.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> select USERNAME,dictionary_protected,AUTHENTICATION_TYPE,ORACLE_MAINTAINED from dba_users where username='USEF';
USERNAME DIC AUTHENTI ORACLE_MAINTAINED
---------- --- -------- --------------------
USEF NO NONE Y
SQL> select USERNAME,dictionary_protected,AUTHENTICATION_TYPE,ORACLE_MAINTAINED from dba_users where username='USEF'; USERNAME DIC AUTHENTI ORACLE_MAINTAINED ---------- --- -------- -------------------- USEF NO NONE Y
SQL>  select USERNAME,dictionary_protected,AUTHENTICATION_TYPE,ORACLE_MAINTAINED from dba_users where  username='USEF';
USERNAME   DIC AUTHENTI ORACLE_MAINTAINED
---------- --- -------- --------------------
USEF       NO  NONE     Y
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SQL> alter user USEF enable dictionary protection;
User altered.
SQL> alter user USEF enable dictionary protection; User altered.
SQL> alter user USEF enable dictionary protection;
User altered.

ارائه خدمات مشاوره ، پشتیبانی و نصب و راه اندازی پایگاه داده اوراکل در سراسر کشور...................... تلفن: 09128110897 ایمیل:vahidusefzadeh@gmail.com

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *