Multi-Factor Authentication (MFA) หรือการยืนยันตัวตนแบบหลายชั้นตอน เป็นหนึ่งในวิธีที่มีประสิทธิภาพมากที่สุดในการป้องกันการเข้าถึง Account โดยไม่ได้รับอนุญาต สถิติจาก Microsoft ระบุว่า MFA สามารถป้องกันการโจมตี Account ได้ถึง 99.9% ของกรณีทั้งหมด
MFA คืออะไร?
MFA คือการยืนยันตัวตนโดยใช้หลักฐาน ตั้งแต่ 2 อย่างขึ้นไป จาก 3 หมวดหมู่:
| หมวดหมู่ | คำอธิบาย | ตัวอย่าง |
|---|---|---|
| Something You Know | สิ่งที่คุณรู้ | Password, PIN, Security Question |
| Something You Have | สิ่งที่คุณมี | Smartphone, Hardware Token, Smart Card |
| Something You Are | สิ่งที่เป็นตัวคุณ | Fingerprint, Face ID, Retina Scan |
ประเภทของ MFA
1. TOTP (Time-based One-Time Password)
TOTP เป็นรหัส 6 หลักที่เปลี่ยนทุก 30 วินาที ใช้แอปเช่น Google Authenticator, Authy, Microsoft Authenticator เป็น MFA ที่นิยมใช้มากที่สุด
2. SMS / Email OTP
ส่ง OTP ผ่าน SMS หรือ Email ง่ายใช้งาน แต่มีความเสี่ยงจาก SIM Swapping และ Email Compromise ควรใช้เป็นตัวเลือกสุดท้ายถ้าไม่มีทางเลือกอื่น
3. Hardware Security Key (FIDO2/WebAuthn)
Hardware Key เช่น YubiKey เป็นวิธีที่ปลอดภัยที่สุด ไม่สามารถฟิชชิ่งหรือ Phishing ได้ เหมาะสำหรับบัญชี Privileged Account
4. Push Notification
แอปส่ง Push Notification มายังมือถือให้กด Approve/Deny เช่น Duo Security, Okta Verify ใช้งานง่ายและ User-friendly
การติดตั้ง MFA บนระบบ
ติดตั้ง TOTP ด้วย Python
pip install pyotp qrcode
import pyotp
import qrcode
# สร้าง Secret Key
secret = pyotp.random_base32()
print(f'Secret: {secret}')
# สร้าง TOTP Object
totp = pyotp.TOTP(secret)
# ดูรหัสปัจจุบัน
print(f'Current OTP: {totp.now()}')
# ตรวจสอบ OTP
def verify_otp(secret, token):
totp = pyotp.TOTP(secret)
return totp.verify(token)
# สร้าง QR Code สำหรับสแกนด้วย Authenticator App
uri = totp.provisioning_uri(name='[email protected]', issuer_name='MyApp')
img = qrcode.make(uri)
img.save('totp_qr.png')
เปิดใช้งาน MFA บน WordPress
ปล๊อกอินที่แนะนำ: WP 2FA, Google Authenticator, หรือ Wordfence Security ล้วนติดตั้ง Plugin และแนะนำให้ Admin เปิดใช้งาน MFA
เปรียบเทียบ MFA แต่ละประเภท
| ประเภท MFA | ความปลอดภัย | ความสะดวก | การป้องกัน Phishing |
|---|---|---|---|
| SMS OTP | ต่ำ | สูง | ไม่ป้องกัน |
| Email OTP | ปานกลาง | สูง | ไม่ป้อนกัน |
| TOTP App | สูง | สูง | ไม่ป้อนกัน |
| Push Notification | สูง | สูงมาก | ไม่ป้อนกัน |
| Hardware Key | สูงมาก | ปานกลาง | ป้อนกัน 100% |
การใช้ MFA ในองค์กร
- บังคับใช้ MFA สำหรับ Privileged Accounts: Admin, DevOps, Finance ต้องใช้ MFA ทุกคน
- ใช้ SSO + MFA: Single Sign-On ร่วมกับ MFA ช่วยลดความชักช้าในการเข้าสู่ Application หลายตัว
- MFA บน VPN: เพิ่มความปลอดภัยให้ Remote Access
- Backup Codes: มีรหัสสำรองในกรณีสูญเฮียเครื่องหรือ Device
สรุป
MFA เป็นการลงทุนด้านความปลอดภัยที่คุ้มค่าที่สุด การเปิดใช้งานมีค่าใช้จ่ายน้อยหรือฟรี แต่สามารถป้องกัน Data Breach ที่อาจสร้างความเสียหายโดยเฉลี่ย สำหรับผู้ใช้ Cloud VPS หรือผู้ดูแลระบบ Server ควรเปิดใช้งาน MFA สำหรับทุก Account ที่มีสิทธิ์เข้าถึงทันที

