Kerberos คืออะไร?
Kerberos เป็นโปรโตคอลการยืนยันตัวตน (Authentication Protocol) แบบ Ticket-based ที่พัฒนาโดย MIT ใช้ในระบบกระจาย (Distributed Systems) เพื่อให้ Client และ Server ยืนยันตัวตนกันได้อย่างปลอดภัยผ่านเครือข่ายที่ไม่ปลอดภัย (เช่น อินเทอร์เน็ต) โดย ไม่ส่งรหัสผ่านผ่านเครือข่าย
🏛️ สถาปัตยกรรมหลัก 3 ส่วน (3 Heads of Kerberos)
- Client (Principal): ผู้ใช้หรือบริการที่ขอยืนยันตัวตน
- Server (Application Server): ทรัพยากร/บริการที่ Client ต้องการเข้าถึง
- Key Distribution Center (KDC) - Trusted Third Party: ศูนย์กลางที่เชื่อถือได้ ประกอบด้วย 2 บริการ:
- Authentication Server (AS): ออก Ticket Granting Ticket (TGT)
- Ticket Granting Server (TGS): ออก Service Ticket สำหรับ Server เป้าหมาย
🔄 ขั้นตอนการทำงาน (Kerberos Flow)
- AS Request: Client ส่ง User ID ไป AS (ไม่ส่ง Password)
- AS Reply: AS ส่งกลับ TGT (เข้ารหัสด้วย Key ของ Client ที่derive จาก Password) + Session Key (Client-TGS)
- TGS Request: Client ส่ง TGT + Server Name (SPN) ไป TGS พร้อม Authenticator (Timestamp เข้ารหัสด้วย Session Key)
- TGS Reply: TGS ส่งกลับ Service Ticket (เข้ารหัสด้วย Key ของ Server) + Session Key (Client-Server)
- AP Request: Client ส่ง Service Ticket + Authenticator (Timestamp เข้ารหัสด้วย Client-Server Session Key) ไป Server
- AP Reply (Optional): Server ตอบกลับยืนยันตัวตน Server (Mutual Authentication) ด้วย Timestamp+1
🔐 ความปลอดภัยของ Kerberos
- ไม่ส่ง Password ผ่านเครือข่าย: ใช้ Key ที่ derive จาก Password เข้ารหัส TGT
- Mutual Authentication: Client และ Server ยืนยันตัวตนกัน
- Replay Protection: Timestamp + Window (ปกติ 5 นาที) ป้องกันการ Replay Attack
- Single Sign-On (SSO): TGT ใช้ได้หลายครั้ง (ค่าเริ่มต้น 10 ชม.) ไม่ต้องพิมพ์รหัสผ่านซ้ำ
- Encryption Types: AES256-CTS-HMAC-SHA1-96, AES128-CTS-HMAC-SHA1-96, RC4-HMAC (Deprecated), DES (Deprecated)
🔗 Kerberos ใน Active Directory (AD)
- AD ใช้ Kerberos v5 เป็นโปรโตคอลยืนยันตัวตนหลัก (ตั้งแต่ Windows 2000)
- Domain Controller (DC) ทำหน้าที่ KDC (AS + TGS)
- Service Principal Names (SPNs) ใช้ระบุบริการ (HTTP/webserver, MSSQL/sqlserver)
- Delegation: อนุญาตให้บริการหนึ่งทำงานแทน User (Constrained Delegation, Resource-based Constrained Delegation)
⚠️ โจมตีที่พบบ่อยและการป้องกัน
| โจมตี | คำอธิบาย | การป้องกัน |
|---|---|---|
| Kerberoasting | ขอ Service Ticket สำหรับ SPN ที่มี Password อ่อน แล้ว Crack Offline | ใช้ Service Account Password ยาวซับซ้อน (>25 chars), Group Managed Service Accounts (gMSA) |
| AS-REP Roasting | ขอ TGT สำหรับ User ที่ไม่ตั้งค่า Pre-authentication แล้ว Crack | บังคับ Pre-authentication สำหรับทุก User |
| Pass-the-Ticket (PtT) | ขโมย TGT/Service Ticket จากหน่วยความจำ (LSASS) ใช้เข้าถึงทรัพยากร | Protected Users Group, Credential Guard, LSASS Protection, Monitoring Event ID 4769 |
| Golden/Silver Ticket | ปลอม Ticket ด้วย KRBTGT Hash (Golden) หรือ Service Hash (Silver) | เปลี่ยน KRBTGT Password เป็นระยะ (2 ครั้ง), Monitoring, Tiered Administration |
| ข้อดี | ข้อจำกัด |
|---|---|
| SSO แท้จริง, Mutual Auth, ไม่ส่ง Password, Cross-platform (Unix/Windows), มาตรฐานเปิด (RFC 4120) | Time Sync จำเป็น (NTP), Single Point of Failure (KDC), ไม่รองรับ MFA โดยตรง (ต้องใช้ PKINIT/FAST), Complex Setup |