28
1 LOGO DBMS : Database Security and Database Security and Authorization Authorization SUCHADA PUNNOI Dept. of Computer Science & Information Technology http://computer.pcru.ac.th/suchada/ Chapter 6

DBMS : Database Security and Authorization

Embed Size (px)

DESCRIPTION

Chapter 6. DBMS : Database Security and Authorization. SUCHADA PUNNOI Dept. of Computer Science & Information Technology http :// computer . pcru . ac . th / suchada/. Database Security and Authorization ความปลอดภัยของฐานข้อมูล และการกำหนดสิทธิ. ความปลอดภัยของข้อมูล ( security ). - PowerPoint PPT Presentation

Citation preview

Page 1: DBMS :  Database Security and Authorization

1

LOGO

DBMS : Database Security and Database Security and AuthorizationAuthorization

SUCHADA PUNNOIDept. of Computer Science & Information Technologyhttp://computer.pcru.ac.th/suchada/

Chapter 6

Page 2: DBMS :  Database Security and Authorization

2

LOGO

Database Security and AuthorizationDatabase Security and Authorization ความปลอดภัยของฐานข�อม�ล และความปลอดภัยของฐานข�อม�ล และการก�าหนดสิ�ทธิ�การก�าหนดสิ�ทธิ�

Page 3: DBMS :  Database Security and Authorization

3

ความปลอดภัยของข�อม�ล (security)

การป�องกนข�อม�ลจากผู้��ไม�ม�สิ�ทธิ�ในการประมวลผู้ลหร!อปฏิ�บัติ�การการกบัข�อม�ลเข�ามากระท&าการติ�างๆ เก�นสิ�ทธิ�ท�(สิามารถกระท&าได�

Page 4: DBMS :  Database Security and Authorization

4

Introduction to Database Introduction to Database Security IssuesSecurity Issues

ชน�ดของความปลอดภัยของข�อม�ล ชน�ดของความปลอดภัยของข�อม�ล ((Types of SecurityTypes of Security)) ด�านกฎหมายและจร�ยธิรรม (Legal and ethical issues)

• สิ�ทธิ�ท�(สิามารถเข�ามาใช้�งาน information

นโยบัาย (Policy issues) ระดบัรฐบัาล หร!อ สิถาบัน ระบับั (System)

• ระดบักายภัาพ H/W,

• ระดบั OS

• ระดบั DBMS

ในบัางองค0กรม�การก&าหนดความปลอดภัยหลายระดบัรวมถ1งจดกล2�มของ data และกล2�มของผู้��ใช้�ท�(จะเข�ามาใช้�งานข�อม�ล

Page 5: DBMS :  Database Security and Authorization

5

การค�กคามฐานข�อม�ล (Threats to Database)

การค2กคามฐานข�อม�ลน&าไปสิ��การสิ�ญหายหร!อการเสิ!(อมติ�อไปน�4 integrity, availability, และ confidentially. การสิ�ญเสิ�ยความคงสิภัาพ (Loss of integrity)

การสิ�ญเสิ�ยสิภัาพพร�อมใช้�งาน (Loss of availability)

การสิ�ญเสิ�ยความเป5นสิ�วนติว (Loss of confidentially)

Page 6: DBMS :  Database Security and Authorization

6

การสิ�ญเสิ�ยความคงสิภัาพ การสิ�ญเสิ�ยความคงสิภัาพ ((Loss of integrityLoss of integrity))

Integrity เป5นความติ�องการให�ข�อม�ลหร!อ information ถ�กปกป�องจากเปล�(ยนแปลง(Modification) ท�(ไม�ถ�กติ�อง/ไม�เหมาะสิม

Modification of data ประกอบัด�วย การสิร�าง (Creation) , การเพ�(ม (Insertion) , การแก�ไข (Modification), การลบั

(Deletion), การเปล�(ยนสิถานะของข�อม�ล (Change the status of data)

Integrity จะสิ�ญเสิ�ยไปถ�าผู้��ไม�ม�สิ�ทธิ� (unauthorized) ท&าการเปล�(ยนแปลงข�อม�ลไม�ว�าจะเป5นไปโดยติ4งใจหร!ออ2บัติ�เหติ2ก6ติาม

และหากม�การใช้�งานข�อม�ลในระบับัท�(ม�ป7ญหา (contaminated system)

หร!อ corrupt data ติ�อไป จะน&าไปสิ��ผู้ลลพธิ0 ความไม�ถ�กติ�อง (inaccuracy) และน&าไปสิ��การติดสิ�ทธิ�ใจท�(ผู้�ดพลาดได� (erroneous

decision)

Page 7: DBMS :  Database Security and Authorization

7

การสิ�ญเสิ!ยสิภัาพพร�อมใช�งาน (Loss of availabilityLoss of availability))

สิภัาพพร�อมใช้�งานของฐานข�อม�ล ค!อการม�ข�อม�ลพร�อมสิ&าหรบัผู้��ใช้�หร!อโปรแกรมท�(ม�สิ�ทธิ�ในการใช้�งานโดยช้อบั (legitimate right) สิามารถเร�ยกใช้�งานได�

Page 8: DBMS :  Database Security and Authorization

8

การสิ�ญเสิ!ยความเป$นสิ%วนตัว (Loss of confidentiallyLoss of confidentially))

Database confidentially หมายถ1ง การป�องกนการเป8ดเผู้ยข�อม�ล ติ�อผู้��ท�(ไม�ม�สิ�ทธิ�เข�ามาใช้�งาน (unauthorized).

ผู้��ท�(ไม�ม�สิ�ทธิ�สิามารถสิามารถท&าให�เก�ดการสิ�ญเสิ�ยความเป5นสิ�วนติว

Page 9: DBMS :  Database Security and Authorization

9

ท&าอย�างไรถ1งจะป�องกนฐานข�อม�ลท&าอย�างไรถ1งจะป�องกนฐานข�อม�ล((How to protect databaseHow to protect database))

การป�องกน ควบัค2มการเข�าถ1งข�อม�ล (Access control)

ควบัค2มอน2มาน (Inference control)

ควบัค2มการไหล (Flow control)

การเข�ารหสิลบั (Encryption)

Page 10: DBMS :  Database Security and Authorization

10

ในระบับัผู้��ใช้�หลายคนระบับัจดการฐานข�อม�ลจะม� “database security and authorization subsystem” ท&าหน�าท�(ในการป�องกนผู้��ไม�ม�สิ�ทธิ�เข�ามาใช้�งานฐานข�อม�ล

ซึ่1(ง database security mechanism ม� 2 ประเภัทค!อ Discretionary security mechanisms Mandatory security mechanisms

Page 11: DBMS :  Database Security and Authorization

11

Database security mechanismsDatabase security mechanisms

Discretionary security mechanisms เป5นการก&าหนดให�สิ�ทธิ�กบัผู้��ใช้�ในการใช้�งาน (Grant

privilege to users) ประกอบัด�วย• สิามารถเข�าถ1งแฟ้�มข�อม�ล ระเบั�ยนหร!อเขติข�อม�ลท�(ก&าหนด

ในโหมดท�(ก&าหนด (insert, read, delete, update) ได�

Mandatory security mechanisms เป5นแนวทางท�(ใช้�การก&าหนดระดบัการใช้�งาน โดยม�การจด

แบั�งกล2�มของข�อม�ลและกล2�มผู้��ใช้�ข�อม�ลติามระดบัสิ�ทธิ� ข14นกบันโยบัายขององค0กร Example

• นโยบัายท�(อน2ญาติให�ผู้��ใช้�แติ�ละกล2�มสิามารถเห6นข�อม�ลเฉพาะในกล2�มของตินเอง

• Role-based security

Page 12: DBMS :  Database Security and Authorization

12

Database security and the DBADatabase security and the DBA

ในระบับัจดการฐานข�อม�ล DBA จะม� DBA account ถ�กเร�ยกว�า “system” หร!อ “superuser” account ม�ความสิามารถหร!อสิ�ทธิ�มากกว�า regular database accounts

และ users. DBA privilege commands ประกอบัด�วยค&าสิ(งติ�อไปน�4

ให�สิ�ทธิ� (granting privilege) และ ยกเล�กสิ�ทธิ� (revoking privilege) แก� individual accounts, users หร!อกล2�มของผู้��ใช้� user groups

ท&างานติ�อไปน�4• สิร�าง Account creation• ก&าหนดสิ�ทธิ� (Privilege granting)• เร�ยกสิ�ทธิ�ท�(ให�ไปค!อ (Privilege revocation)• ก&าหนดระดบัความปลอดภัย (Security level assignment)

DBA รบัผู้�ดช้อบัเร!(องของ ความปลอดภัยของระบับัฐานข�อม�ลท4งหมด

Page 13: DBMS :  Database Security and Authorization

13

Access Protection, User accounts, and Database Audits

1. เม!(อผู้��ใช้�ติ�องการใช้�งานฐานข�อม�ล (access database)2. DBA สิร�าง user account และก�าหนด password3. เม!(อ user login เข�าใช้�งาน DBMS โดยใสิ� user account และ

password4. DBMS ตัรวจสิอบว%า account และ password valid หร!อไม�

หาก user ม�สิ�ทธิ�ใช้�งาน DBMS อน2ญาติให�เข�าใช้�งานได�5. DBMS เก6บัข�อม�ล accounts และ passwords โดยม�การเข�ารหสิ

(encrypted) ติารางท�(เก6บั Account and Password. ติารางน�4ถ�กด�แลโดย DBMS.

เม!(อ create new user, ข�อม�ลถ�กบันท1กในติารางดงกล�าว เม!(อ account ถ�กยกเล�ก,รายการดงกล�าวจะถ�กลบัไป

Page 14: DBMS :  Database Security and Authorization

14

Keep track of operation

6. BDMS เก6บั track of operations ท�(เก�ดข14นในฐานข�อม�ล(database)

Create login session เม)*อ user log in

เก6บั track of sequence of database interactions จากเวลาติ4งแติ�ม�การ logging จนถ1งเวลาท�(ม�การ logging out

เม!(อ user log in, DBMS ท&าการบันท1ก user’s account และ terminal

ท2กปฏิ�บัติ�การท�(เก�ดข14น จาก terminal ท�(ถ�กสิ(งโดย user’s

account ดงกล�าวจนกระท(ง log off

บันท1ก track ของการ update

หากฐานข�อม�ลม�ป7ญหา DBA สิามารถหา user ท�ท&าให�เก�ดป7ญหาได�

Page 15: DBMS :  Database Security and Authorization

15

เก6บั ปฏิ�บัติ�การท�(เก�ดข14นใน system log

System log ประกอบัด�วย แติ�ละปฏิ�บัติ�การท�(เก�ดข14นกบัฐานข�อม�ล ท�(เป5นติ�องใช้�ในการ recovery หากเก�ด transaction failure หร!อ system crash ข14น

หากม�การพยายามกระท&าการท�(ไม�ถ�กติ�องกบัฐานข�อม�ล, ติ�องม�การติรวจสิอบัการใช้�งาน (database audit), ซึ่1(งในสิ�วนน�4ประกอบัด�วย reviewing the log เพ!(อด� all accesses และปฏิ�บัติ�การท�(เก�ดข14นกบัฐานข�อม�ลในช้�วงเวลาดงกล�าว

หากม�การติรวจพบัผู้��ไม�ม�สิ�ทธิ�กระท&าการกบัฐานข�อม�ล DBA สิามารถติรวจสิอบัได� determine the account user

Database audits ม!ความสิ�าคญสิ�าหรบ sensitive database ท!*ม!การupdate โดยหลาย transaction และ หลาย users. Audit trail ค!อ database log ท�(ใช้�เพ!(อจ2ดประสิงค0ในการเร!(องความปลอดภัยของข�อม�ล

System log

Page 16: DBMS :  Database Security and Authorization

16

Example : dba_audit_trail

Name Null? Type ----------------------------------------- -------- ------------- OS_USERNAME VARCHAR2(255) USERNAME VARCHAR2(30) USERHOST VARCHAR2(128) TERMINAL VARCHAR2(255) TIMESTAMP NOT NULL DATE OWNER VARCHAR2(30) OBJ_NAME VARCHAR2(128) ACTION NOT NULL NUMBER ACTION_NAME VARCHAR2(27) NEW_OWNER VARCHAR2(30) NEW_NAME VARCHAR2(128) OBJ_PRIVILEGE VARCHAR2(16) SYS_PRIVILEGE VARCHAR2(40) ADMIN_OPTION VARCHAR2(1) GRANTEE VARCHAR2(30) AUDIT_OPTION VARCHAR2(40) SES_ACTIONS VARCHAR2(19) LOGOFF_TIME DATE LOGOFF_LREAD NUMBER LOGOFF_PREAD NUMBER LOGOFF_LWRITE NUMBER LOGOFF_DLOCK VARCHAR2(40) COMMENT_TEXT VARCHAR2(4000 SESSIONID NOT NULL NUMBER ENTRYID NOT NULL NUMBER STATEMENTID NOT NULL NUMBER RETURNCODE NOT NULL NUMBER PRIV_USED VARCHAR2(40)

Page 17: DBMS :  Database Security and Authorization

17

Discretionary Access control Based on Granting and Revoking Privilege

ช้น�ดของ Discretionary Privilege ระดบผู้��ใช� (Account level): DBA ก&าหนดสิ�ทธิ�

(privilege) ในการใช้�งานให�กบัแติ�ละ account

ระดบข�อม�ล (Relation level): DBA/owner สิามารถก&าหนด privileges ในการเข�าถ1งข�อม�ลสิ&าหรบัแติ�ละ relation หร!อ view ในฐานข�อม�ล

Page 18: DBMS :  Database Security and Authorization

18

Account level

Create user User_name identified by Password;

Grant privilege/role to User_name;

ตัวอย%างเช%น Create user A identified by A; Grant connect, resource to A; Create user B identified by B; Grant DBA to B; (with grant option)

Page 19: DBMS :  Database Security and Authorization

19

Relation level

A: Create table (A เป5นเจ�าของติาราง:Owner) A: สิามารถก&าหนดสิ�ทธิ� (grant privilege) ในการใช้�

งาน Table ท�( A สิร�างให�กบั user อ!(นๆได� Grant อาจเป5นแบับั grant with grant option

Page 20: DBMS :  Database Security and Authorization

20

SQL

SELECT privilege on R: ให� account ม�สิ�ทธิ�ในการ เร�ยกใช้�(retrieval privilege)

MODIFY privileges on R: ให� account ม�สิ�ทธิ�ในการแก�ไขระเบั�ยน R ได� (ไม�ว�าจะเป5น Update, Delete, insert Privilege)

REFERENCES privileges on R: ให� account สิามารถ อ�างอ�ง relation R เม!(อม�การก&าหนด integrity constraints

ซึ่1(ง privilege สิามารถระบั2ในระดบั attribute ของ R ได� **Remark: create view, account จะติ�องม�สิ�ทธิ�ในการเร�ยก

ใช้�งาน (select privilege) ท2กๆ relations ท�(เก�(ยวข�อง ใน view definition

Page 21: DBMS :  Database Security and Authorization

21

ก�าหนด Privilege โดยใช� VIEW

ว�ธิ�การท�(ก&าหนดสิ�ทธิ� users ในการ manipulate ข�อม�ล ถ�า user A ตั�องการให� user B สิามารถ retrieve

เฉพาะบาง field ของ relation R (ซึ่1(งถ�กสิร�างโดยA) สิามารถท&าโดยให� A ท&าการ สิร�าง view V จาก R โดยว�ว

ดงกล�าวประกอบัด�วย attributes ท�(ติ�องการให�เห6นเท�าน4น ท&าการ grant SELECT on V ให�กบผู้��ใช� B

Page 22: DBMS :  Database Security and Authorization

22

View

Create View View_name as select

as select tab1.col, tab2.col, …

from table1 tab1, table2 tab2

where condition

Syntax for create view by SQL (oracle)

Page 23: DBMS :  Database Security and Authorization

23

Grant privilege

Grant operation on Table/View to User with grant option

Example GRANT select ON emp to tori; GRANT select ON empcom to nok with grant

option; GRANT update on emp (salary) to tori; GRANT all on emp to nok with grant option;

Page 24: DBMS :  Database Security and Authorization

24

example

Tori : Grant select on student to Hana; Hana: Select * from Tori.student; Tori : Grant select, update on student to kawa

with grant option; Kawa: Grant select on student to Nara with grant

option;

Question: Can Nara grant her privilege to others? If No, why? If yes, what privilege nara can grant to other users?

Page 25: DBMS :  Database Security and Authorization

25

Syntax for create view by SQL (oracle)

CREATE VIEW View_name AS SELECT col1,col2,…,coln

FROM table1,…,tablen WHERE condition;

EXAMPLEDEPT (DEPTNO, DNAME, LOC) EMP (EMPNO, ENAME, JOB, MGR, SAL, COMM, DEPTNO)

CREATE VIEW EMPCOM AS Select Empno , Ename, Sal, Comm, E.DeptNo, DnameFROM EMP E, DEPT DWHERE E.DeptNo = D.DeptNo and Comm > 0;

EMPCOM

EMPCOM (Empno , Ename, Sal, Comm, DeptNo, Dname)View

Page 26: DBMS :  Database Security and Authorization

26

Revoking Privileges

จ2ดประสิงค0เพ!(อยกเล�กสิ�ทธิ�ในการใช้�งาน REVOKE operation on table/view/object from USER Example

REVOKE select on EMP from tori; REVOKE select on EMPCOM from tori;

Page 27: DBMS :  Database Security and Authorization

27

Propagation of Privileges using the Grant Option

User A create table R (A is owner of R) GRANT

User A grants Privilege on R to User B with grant option (หมายความว�า B สิามารถ grant สิ�ทธิ�ท�(สิามารถท&ากบั R ให�กบัผู้��ใช้�อ!(นได�).

User B ให�สิ�ทธิ� grant privilege กบั User C with grant option ความหมายค!อ privilege on R สิามารถสิ�งติ�อให�กบั accounts อ!(นโดยท�( owner

ของ R ไม�จ&าเป5นติ�องทราบั REVOKE

ถ�า A revoke privilege on R จาก B. ท2กๆ privilege ท�( B ให�กบัผู้��อ!(นควรติ�องถ�กเร�ยกกบัค!นอติโนมติ� โดย system.

User ได�รบั privilege จาก sources ติ�างๆ มากกว�า หน1(ง A2 และ A3 ให�สิ�ทธิ� UPDATE on R แก� A4 ถ�า A2 ขอสิ�ทธิ�ดงกล�าวค!นจาก A4 A4 ยงคงม�สิ�ทธิ�ในการใช้�งาน (grant จากA2) ถ�า A3 ขอสิ�ทธิ�ค!นจาก A4 น(นค!อ A4 สิ�ญเสิ�ยสิ�ทธิ�ท2กประการในการใช้�งาน R

Page 28: DBMS :  Database Security and Authorization

28

LOGO

F A Q