Access Control (Authorization)
CSS454 — Access Control (Authorization)
เป้าหมาย: เข้าใจว่าใครเข้าถึงอะไรได้บ้าง, ผ่าน Policy แบบไหน, และจัดการ Identity ยังไง
1. พื้นฐาน Access Control
1.1 Flow ของ Access Control
User ──► Authentication ──► Access Control Function ──► System Resources
▲
Security Admin ◄──► Authorization Database
▼
Auditing (บันทึกทุก interaction)
1.2 สี่ Policy หลัก
| Policy | ตัดสินจาก | ตัวอย่าง |
|---|---|---|
| DAC | Identity ของ Requestor + Access rules | Google Drive owner กำหนด permission |
| MAC | Security labels vs Security clearances | Military classification |
| RBAC | Role ของ User ในระบบ | Nurse, Doctor, Admin มี permission ต่างกัน |
| ABAC | Attributes ของ User + Resource + Environment | เข้าได้แค่จาก US location |
2. Subjects, Objects, และ Access Rights
| Entity | คืออะไร | Classes / Examples |
|---|---|---|
| Subject | ผู้เข้าถึง Object | Owner, Group, World |
| Object | Resource ที่ถูก Access | File, Database, Process |
| Access Right | วิธีที่ Subject เข้าถึง Object | Read, Write, Execute, Delete, Create, Search |
3. Discretionary Access Control (DAC)
- Owner ของ Resource กำหนดเองว่าใครเข้าถึงได้
- Owner มักเป็น Creator ของ Resource นั้น
- ใช้ Access Matrix เป็นโครงสร้างหลัก
อุปมา: Google Drive — คนสร้าง File เป็นคนกำหนดว่าใคร View หรือ Edit ได้
3.1 Access Matrix
| SUBJECTS | File 1 | File 2 | File 3 | File 4 |
|---|---|---|---|---|
| User A | Own, R, W | — | Own, R, W | — |
| User B | R | Own, R, W | W | R |
| User C | R, W | R | — | Own, R, W |
3.2 สามรูปแบบของ Access Matrix
(a) Access Control List (ACL) — มองจาก Object ว่าใครเข้าได้บ้าง
File 1 → A: Own/R/W, B: R, C: R/W
File 2 → B: Own/R/W, C: R
File 3 → A: Own/R/W, B: W
File 4 → B: R, C: Own/R/W
(b) Capability List — มองจาก User ว่าเข้าถึง File ไหนได้บ้าง
User A → File 1: Own/R/W, File 3: Own/R/W
User B → File 1: R, File 2: Own/R/W, File 3: W, File 4: R
User C → File 1: R/W, File 2: R, File 4: Own/R/W
⚠️ Final Exam: อาจารย์ให้ Access Matrix มา แล้วให้วาด ACL หรือ Capability List ออกมาได้เลย
(c) Authorization Table — แสดงแบบ Row-by-row (Subject, Mode, Object)
| Subject | Access Mode | Object |
|---|---|---|
| A | Own/Read/Write | File 1 |
| A | Own/Read/Write | File 3 |
| B | Read | File 1 |
| B | Own/Read/Write | File 2 |
| ... | ... | ... |
3.3 Extended Access Matrix
- Subjects สามารถเป็น Object ได้ด้วย (e.g., มี Control เหนือ )
- รองรับ Process operations: wakeup, stop, execute
- รองรับ Disk operations: seek
- Copy flag (
*) — Permission ที่มี*สามารถโอนให้คนอื่นได้
3.4 Protection Domains
- Set of objects + access rights ที่จัดกลุ่มเข้าด้วยกัน
- แต่ละ Row ใน Access Matrix = Protection Domain หนึ่ง
- User spawn Process ได้ด้วย Access rights subset ของตัวเอง
- User mode — Memory บางส่วน Protected, บาง Instruction ทำไม่ได้
- Kernel mode — ทำ Privileged instructions ได้, เข้า Protected memory ได้
อุปมา: เหมือน Security clearance ในตึก — พนักงานทั่วไปเข้าล็อบบี้ได้ แต่ Server room ต้องได้รับอนุญาตพิเศษ
4. UNIX File Access Control
4.1 Inodes (Index Nodes)
- UNIX บริหาร File ผ่าน inode — Control structure เก็บ Key information ของ File
- หลาย File names → inode เดียวได้
- inode ที่ Active → ผูกกับ หนึ่ง File เท่านั้น
- เก็บ: File attributes, permissions, control info
- ตอน File ถูก Open → inode ถูก Load ขึ้น Main memory
4.2 UNIX File Permissions
- User มี User ID และ Group ID
- 12 Protection bits:
rw- r-- ---
[Owner] [Group] [Other]
| Class | ความหมาย |
|---|---|
| Owner | คนสร้าง File |
| Group | กลุ่มที่ Owner อยู่ด้วย |
| Other | ทุกคนที่เหลือ |
อุปมา: เหมือนบัตรห้องสมุด — Owner ยืม/คืนได้, Group อ่านในห้องได้, Others ไม่มีสิทธิ์
5. Mandatory Access Control (MAC)
- ระบบ กำหนด Security level ให้ทุก Information
- User แต่ละคนมี Security clearance
- User เข้าถึงได้เฉพาะ Data ที่มี Clearance ถึง
| Rule | ความหมาย | ทำไม? |
|---|---|---|
| Read Down | อ่านได้เฉพาะ Object ที่ Classification ≤ Clearance ตัวเอง | ป้องกันการรั่วไหลข้อมูลชั้นสูง |
| Write Up | เขียนได้เฉพาะ Object ที่ Classification ≥ Clearance ตัวเอง | ป้องกัน Data leakage ลงชั้นล่าง |
อุปมา: Military clearance — "Top Secret" คนอ่าน "Secret" ได้ แต่เขียนไปยัง "Classified" ไม่ได้ (ป้องกันข้อมูลรั่วลงระดับล่าง)
6. Role-Based Access Control (RBAC)
- User เข้าถึง Object ตาม Role ที่ได้รับ
- Role ถูกออกแบบตาม Job functions (Accountant, IT Support, CFO...)
- ระบบสนใจ Role ของ User ไม่ใช่ตัว User โดยตรง
อุปมา: โรงพยาบาล — Nurse ฉีดยาได้, Doctor สั่งยาได้, แต่ Janitor เข้าถึงบันทึกผู้ป่วยไม่ได้ ถ้าคนออก Role → Permission หายทันที
Key Advantage: Users เปลี่ยนบ่อย แต่ Roles ไม่เปลี่ยน → ลด Admin overhead
6.1 RBAC Framework
— Core RBAC (พื้นฐานที่ทุกระบบต้องมี)
| Component | ความหมาย |
|---|---|
| USERS | ผู้ใช้งานทั้งหมด |
| ROLES | บทบาทที่กำหนด |
| SESSIONS | Session ที่ User ใช้งาน (1 User → หลาย Sessions) |
| PRMS | Permissions (OPS × OBS) |
| UA | User Assignment — Many-to-many ระหว่าง User และ Role |
| PA | Permission Assignment — Many-to-many ระหว่าง Role และ Permission |
— Hierarchical RBAC
- เพิ่ม Role Hierarchy (RH) — Role สูงกว่า Inherit Permission ของ Role ต่ำกว่า
- General hierarchy — Multiple inheritance ได้
- Limited hierarchy — มี Ascendant หลายอันได้ แต่ Descendant ทันทีได้แค่อันเดียว
Cardiologist
↑
Specialist ← (inherits Doctor + Intern)
↑ ↑
Doctor Intern
— Constraints (SSD + DSD)
Static Separation of Duty (SSD)
- ป้องกัน Conflict of interest ระดับ Authorization (ถาวร)
- User ไม่สามารถมีทั้งสอง Role ที่ Conflict กันได้
- ตัวอย่าง: พนักงานธนาคาร ไม่สามารถเป็นทั้ง Teller และ Auditor ได้
Dynamic Separation of Duty (DSD)
- ป้องกัน Conflict ระดับ Session (Runtime)
- User มีทั้งสอง Role ได้ แต่ Activate พร้อมกันไม่ได้
- ตัวอย่าง: มีทั้ง Teller และ Account Holder แต่ใช้พร้อมกันไม่ได้
| Aspect | SSD | DSD |
|---|---|---|
| Scope | Authorization (ถาวร) | Session (Runtime) |
| ตัวอย่าง | Teller ≠ Auditor (ห้ามมีทั้งคู่) | Teller ≠ Account Holder (มีได้แต่ใช้พร้อมกันไม่ได้) |
| Flexibility | น้อย | มาก |
อุปมา: SSD = ห้ามมีทั้ง License ขับรถและ Taxi permit พร้อมกัน. DSD = มีได้ทั้งคู่ แต่ใช้พร้อมกันไม่ได้
— Consolidated Model
- รวมทุกอย่าง: Core + Hierarchy + Constraints
RBAC₀ — Core
RBAC₁ — Core + Hierarchy
RBAC₂ — Core + SSD/DSD
RBAC₃ — Core + Hierarchy + SSD/DSD (ครบ)
6.2 Constraints ใน RBAC
| ประเภท | ความหมาย | ตัวอย่าง |
|---|---|---|
| Mutually Exclusive Roles | User มีได้แค่ Role เดียวใน Set | ไม่สามารถเป็นทั้ง Maker และ Approver |
| Cardinality | จำกัดจำนวน User สูงสุดต่อ Role | Role Approver max 3 คน |
| Prerequisite Roles | ต้องมี Role A ก่อนถึงจะได้ Role B | ต้องเป็น Grad Student ก่อนถึงจะเป็น TA ได้ |
7. Least Privilege & Zero-Standing Privilege
7.1 Principle of Least Privilege (PoLP)
- User ได้รับ Permission น้อยที่สุดเท่าที่จำเป็น สำหรับงานของตัวเอง
- ตัวอย่าง: DB Retrieval account ไม่ควรมี Admin rights
- ตัวอย่าง: Code Developer ไม่ควรเข้าถึง Financial data
7.2 Zero-Standing Privilege (ZSP)
⚠️ Final Exam แน่นอน!
- Core Goal: ลบ Persistent privileged access ทั้งหมดออก → ลด Attack surface
- วิธีทำงาน: แทนที่จะมี Admin rights ตลอดเวลา → Request access สำหรับงานนั้นๆ แล้ว Revoke อัตโนมัติ หลังหมดเวลา
- ต้องใช้: Privileged Access Management (PAM) solution
| ด้าน | รายละเอียด |
|---|---|
| ประโยชน์ | ลด Cyber risk, รองรับ GDPR/HIPAA, ลด Insider threats |
| ความท้าทาย | User productivity ลด, Implementation ซับซ้อน, ต้องมี Automated workflows |
8. Attribute-Based Access Control (ABAC)
- ตัดสินจาก Attributes ของ Subject + Object + Environment
- Fine-grained AC (ละเอียดระดับบุคคล) ≠ RBAC ที่เป็น Coarse-grained (ระดับ Role)
- Standard: XACML (eXtensible Access Control Markup Language)
8.1 สี่ประเภทของ Attributes
| Attribute | คืออะไร | ตัวอย่าง |
|---|---|---|
| Subject | ตัวตนและลักษณะของ User | Username, Department, Clearance |
| Object | ลักษณะของ Resource | Type, Owner, Classification, Date Created |
| Environment | Context สิ่งแวดล้อม | Location, Time, Device |
| Action | การกระทำที่ขอ | Read, Write, View, Transfer, Delete |
8.2 Flow ของ ABAC
Subject Request ──► Access Control Mechanism
├── Access Control Policy
├── Subject Attributes
├── Object Attributes
└── Environment Conditions
↓
Decision → Enforce on Object
8.3 ABAC Policy Examples
ตัวอย่าง Policy: "US Sales data สามารถเข้าถึงได้โดย US Marketing department จาก US location"
| Example 1 ✅ | Example 2 ❌ | |
|---|---|---|
| Object | US Sales data | US Sales data |
| Subject | US Marketing dept | US Marketing dept |
| Environment | Location: New York, US | Location: London, UK |
| Decision | Access Granted | Access Denied |
8.4 RBAC vs ABAC
| Aspect | RBAC | ABAC |
|---|---|---|
| Granularity | Coarse-grained (Role level) | Fine-grained (Individual level) |
| Implementation | ง่าย (Assign role ทีเดียว) | ยากกว่า (ต้องกำหนด Attribute rules) |
| Policy format | Rule-based, DB | Rule-based, XACML |
| Expressiveness | ต่ำกว่า | สูงกว่า |
9. ICAM — Identity, Credential, and Access Management
พัฒนาโดย U.S. Government เพื่อจัดการ Digital identities, Credentials, และ Access แบบครบวงจร
9.1 สามส่วนหลัก
1. Identity Management
- จุดประสงค์: สร้าง Trustworthy digital identity ที่ Independent จาก Application ใดๆ
- Lifecycle includes:
- ปกป้อง Personal identity information
- Control access to identity data
- แชร์ Identity data กับ Application ที่ต้องการ
- Revocation ของ Enterprise identity
2. Credential Management
Credential = Object ที่ Bind identity กับ Token อย่างน่าเชื่อถือ ตัวอย่าง Credential: Smart card, Cryptographic key, Digital certificate
5 Logical Components:
- Authorize/specify the need for a credential
- Credential Enrollment
- Generation of Credential
- Credential Issuance
- Maintenance
3. Access Management
- จัดการว่า Entity ได้รับ Access to resources ยังไง (ทั้ง Physical และ Logical)
- 3 Support elements:
| Element | ความหมาย |
|---|---|
| Resource management | กำหนด Rules สำหรับ Resource (credential requirements, conditions) |
| Privilege management | สร้างและดูแล Entitlement/privilege attributes ของ User |
| Policy management | กำหนดว่า Access transaction ไหน Allow/Deny |
9.2 Identity Federation
"Trust digital identities ที่สร้างโดย Organization อื่น"
แก้ปัญหาสองข้อ:
- เชื่อ Identity ของคนจาก Org อื่นได้ยังไง?
- รับรอง Identity ของคนในองค์กรเราเมื่อไปทำงานกับ Org อื่น?
อุปมา: บัตรนักศึกษาที่ใช้ยืมหนังสือที่มหาวิทยาลัย Partner ได้ — เชื่อกระบวนการ Verify ของอีก Org
Flow:
User → Service Provider (SP) → Redirect Authentication → Identity Provider (IdP)
↓
ID Token ← ─────────────
↓
Access Multiple Services
Real-world examples: AWS IAM Federation, Azure AD Federation, Google Cloud Identity
9.3 Zero Trust Identity
"Never trust, always verify!"
Access decisions ขึ้นกับ:
- Identity — เป็นใคร?
- Device — ใช้อุปกรณ์อะไร?
- Location — อยู่ที่ไหน?
- Behavior — พฤติกรรมผิดปกติไหม?
9.4 Federation Attacks & Prevention
| Attack | Prevention |
|---|---|
| Token replay attacks | Short lifetime + Nonce |
| Man-in-the-middle | TLS everywhere + Strict Certificate Validation |
| Token forgery | Sign token + Encrypted payload |
| Session hijack | Token binding (to device/certificate/TLS session) |
9.5 Future Directions
- Decentralized Identity (DID)
- Self-Sovereign Identity (SSI)
- Blockchain-based identity systems
10. สรุปภาพรวม
| Topic | Key Concepts |
|---|---|
| DAC | Access Matrix → ACL (มองจาก File), Capability List (มองจาก User) |
| MAC | Read Down / Write Up — ป้องกัน Data leakage |
| RBAC | RBAC₀ Core → RBAC₁ Hierarchy → RBAC₂ SSD/DSD → RBAC₃ ครบ |
| ABAC | Subject + Object + Environment + Action attributes, XACML, Fine-grained |
| Least Privilege | ให้ Permission น้อยที่สุดเท่าที่จำเป็น |
| ZSP | ไม่มี Persistent access — Request เมื่อต้องการ, Auto-revoke |
| ICAM | Identity + Credential + Access management |
| Federation | Trust identity จาก Org อื่น, Zero Trust: Never trust always verify |
DAC → Owner กำหนดเอง → ยืดหยุ่น แต่เสี่ยง
MAC → ระบบกำหนด Level → Secure แต่ Rigid
RBAC → Role-based → Balance ระหว่าง Security และ Usability
ABAC → Attribute-based → Fine-grained สุด แต่ Complex สุด
CSS454 Computer Security — Access Control (Authorization) Cheat Sheet