CHAP (Challenge-Handshake Authentication Protocol) คืออะไร?
CHAP เป็นโปรโตคอลยืนยันตัวตน (Authentication Protocol) ที่ใช้ร่วมกับ PPP (Point-to-Point Protocol) ใช้ในการเชื่อมต่อ Dial-up, VPN, DSL, และ Serial Links โดยมีกลไก Challenge-Response ที่ไม่ส่ง Password (Secret) ผ่านสายตรงๆ
CHAP ทำงานอย่างไร? (3-Way Handshake)
- Challenge: Authenticator (Server/NAS) ส่ง Random Challenge String ไปยัง Peer (Client)
- Response: Peer คำนวณ MD5(Challenge + Secret) ส่งผลลัพธ์ (Hash) กลับพร้อม Name/ID
- Verify: Authenticator คำนวณ MD5(Challenge + Secret) เอง เปรียบเทียบกับ Response → Match = Success
จุดสำคัญ: Secret (Password) ไม่เคยส่งผ่าน Network มีแต่ Hash เท่านั้น
CHAP vs PAP (Password Authentication Protocol)
| คุณสมบัติ | PAP | CHAP |
|---|---|---|
| กลไก | ส่ง Username/Password แบบ Plaintext (Base64 encoded) | Challenge-Response with MD5 Hash |
| ความปลอดภัย | ต่ำมาก (Sniffing ได้ง่าย) | สูงกว่า (Secret ไม่ส่งผ่านสาย) |
| Replay Attack | เปราะบาง | ป้องกันได้ (Challenge สุ่มทุกครั้ง) |
| การตรวจสอบซ้ำ | เฉพาะตอน Connect | Periodic Re-authentication (Re-challenge) |
| Mutual Auth | ไม่รองรับ | รองรับ (Two-way CHAP) |
MS-CHAP (Microsoft CHAP) v1 และ v2
| เวอร์ชัน | ลักษณะ | สถานะ |
|---|---|---|
| MS-CHAP v1 | ใช้ DES-based, 1-way authentication, Weak | ❌ Deprecated (RFC 4249, 2012) |
| MS-CHAP v2 | Mutual Auth, Stronger Hash (SHA-1 based), Peer Challenge | ⚠️ Vulnerable (Dictionary/Brute-force feasible) → ไม่แนะนำใช้ใหม่ |
หมายเหตุ: MS-CHAP v2 ใช้ใน PPTP VPN, WPA2-Enterprise (PEAP-MSCHAPv2) - ควรย้ายไป EAP-TLS, EAP-TEAP, หรือ Certificate-based Auth
ข้อดีและข้อจำกัดของ CHAP
| ข้อดี | ข้อจำกัด |
|---|---|
| Secret ไม่ส่งผ่าน Network (Plaintext) | ต้องเก็บ Secret แบบ Plaintext/Reversible Encryption บน Server (เพื่อคำนวณ Hash เปรียบเทียบ) |
| ป้องกัน Replay Attack (Challenge สุ่ม) | MD5 ถูก Broken (Collision) - ไม่ควรใช้ในระบบใหม่ |
| Periodic Re-authentication | ไม่มี Forward Secrecy |
| รองรับ Mutual Authentication | Susceptible to Dictionary Attack (หาก Secret อ่อน) |
| Simple, Lightweight, Widely Supported | ไม่ป้องกัน Man-in-the-Middle โดยตรง (ต้องผสมกับ TLS/VPN) |
CHAP ในบริบทสมัยใหม่ (Modern Context)
- PPP/Dial-up: ล้าสมัย (Legacy) - เหลือในบาง ISP/Enterprise Legacy
- PPTP VPN: ใช้ MS-CHAP v2 Deprecated/Insecure → ใช้ IPsec IKEv2, WireGuard, OpenVPN, SSTP แทน
- RADIUS/802.1X: ใช้ EAP-MSCHAPv2 (PEAP) ยังพบได้ แต่ แนะนำ EAP-TLS (Cert-based) หรือ EAP-TEAP
- iSCSI: ใช้ CHAP สำหรับ Authentication ระหว่าง Initiator และ Target (ยังใช้อยู่)
- PPP over Ethernet (PPPoE): ISP บางแห่งยังใช้ CHAP สำหรับ Broadband Authentication
ตัวเลือกที่ดีกว่า (Modern Alternatives)
| Protocol | Use Case | ข้อดี |
|---|---|---|
| EAP-TLS | 802.1X, VPN, RADIUS | Certificate-based, Mutual Auth, Forward Secrecy, Strongest |
| EAP-TEAP | 802.1X (Windows 10+, Cisco ISE) | TLS Tunnel + Inner EAP, Machine + User Auth, Posture Check |
| IKEv2 + Cert/EAP | IPsec VPN | Standard, Fast Reconnect, MOBIKE, Strong Crypto |
| WireGuard | Modern VPN | Simple, Fast, Noise Protocol, Formal Verification |
| OAuth 2.0 / OIDC | Application/API Auth | Token-based, Delegated Auth, Industry Standard |
สรุป
CHAP เป็นโปรโตคอล Authentication แบบ Challenge-Response ที่ ดีกว่า PAP มาก (Secret ไม่ส่ง Plaintext, ป้องกัน Replay) แต่ ล้าสมัยและมีข้อจำกัด (MD5 Broken, ต้องเก็บ Secret Plaintext, No Forward Secrecy) ในระบบใหม่ ควรใช้ EAP-TLS, IKEv2, WireGuard, หรือ Certificate-based Authentication แทน