9.2.2 MFA (Multi-Factor Authentication)
Multi-Factor Authentication (MFA) adalah mekanisme keamanan yang membutuhkan dua atau lebih bukti identitas (faktor) sebelum mengizinkan akses ke akun atau resource cloud. Di lingkungan cloud - di mana satu set kredensial bisa memberikan akses ke seluruh infrastruktur - MFA bukan lagi opsional, melainkan keharusan.
Mengapa MFA Krusial di Cloud?
Cloud memiliki attack surface yang luas:
- Management console bisa diakses dari mana saja via internet
- API keys bisa bocor di code repository, CI/CD pipeline, atau log
- Root account memiliki akses tak terbatas - satu kredensial compromised bisa menghancurkan seluruh infrastruktur
- Brute-force dan credential stuffing menargetkan akun cloud karena reward-nya tinggi
Statistik: lebih dari 80% data breach melibatkan kredensial yang dicuri atau weak password. MFA bisa memblokir 99.9% serangan berbasis kredensial.
Kasus Nyata
Capital One Breach (2019): penyerang mengeksploitasi WSF (Web Application Firewall) yang miskonfigurasi + role IAM yang terlalu permisif. Meski tidak langsung melibatkan MFA, insiden ini menunjukkan bahwa akses ke metadata instance EC2 memberikan akses ke kredensial sementara - MFA pada role yang mengizinkan akses ke resource sensitif bisa memitigasi ini.
Codecov Breach (2021): attacker mendapatkan akses ke environment variable di CI/CD yang berisi credentials cloud - tanpa MFA, credentials bisa langsung digunakan untuk akses ke AWS.
Jenis MFA di Cloud
1. TOTP (Time-based One-Time Password)
Faktor kedua berupa kode 6 digit yang berubah setiap 30 detik.
- Cara kerja: seed key dibagikan saat setup, algoritma TOTP (RFC 6238) menghasilkan kode berdasarkan waktu + seed
- Aplikasi: Google Authenticator, Authy, Microsoft Authenticator, 1Password
- Keamanan: sedang - rentan terhadap phishing (attacker bisa membuat fake login page yang menampung kode TOTP)
Implementasi di AWS Console:
aws iam create-virtual-mfa-device \
--virtual-mfa-device-name "devops-phone" \
--outfile /tmp/qr-code.png \
--bootstrap-method QRCodePNG
Output:
{
"VirtualMFADevice": {
"SerialNumber": "arn:aws:iam::123456789012:mfa/devops-phone"
}
}
Kemudian enable untuk user:
aws iam enable-mfa-device \
--user-name devops-engineer \
--serial-number arn:aws:iam::123456789012:mfa/devops-phone \
--authentication-code-1 123456 \
--authentication-code-2 789012
2. SMS-based OTP
Kode dikirim via SMS ke nomor telepon terdaftar.
- Keamanan: rendah - rentan terhadap SIM swapping, intercept SMS, no signal
- Regulasi: beberapa standar (seperti PCI DSS) tidak lagi mengizinkan SMS sebagai faktor kedua
- Rekomendasi: hindari SMS MFA untuk akun critical. Gunakan hanya sebagai fallback atau untuk akun non-privileged
3. Hardware Security Key (FIDO2/U2F)
Perangkat fisik seperti YubiKey yang menggunakan kriptografi asimetris.
- Cara kerja: private key di perangkat, challenge-response dengan public key di server
- Keamanan: tinggi - phishing-resistant, tidak bisa di-intercept
- Contoh: YubiKey 5 Series, Google Titan Key
Implementasi di AWS: AWS mendukung FIDO2 security keys untuk IAM users.
aws iam create-security-key \
--user-name admin-user \
--credential-id "ABC123..." \
--public-key "MCowBQYDK2VwAyEA..."
4. Biometric Authentication
Menggunakan sidik jari, face recognition, atau iris scanner.
- SaaS apps: Microsoft Authenticator dengan Face ID, Windows Hello
- Keterbatasan: umumnya di level device, bukan sebagai faktor independen di cloud provider
- Kombinasi: sering digunakan bersama TOTP atau push notification sebagai faktor kedua
MFA untuk Root/Admin Accounts
Root account (AWS Account Root User, Azure Global Admin, GCP Super Admin) adalah akun paling kuat di cloud - tidak ada batasan akses. Oleh karena itu, MFA untuk root account adalah mandatory.
AWS Root Account MFA
# Root account MFA harus dilakukan via AWS Console (tidak bisa CLI)
# Langkah-langkah:
# 1. Login ke AWS Console sebagai root user
# 2. Buka IAM > Security credentials
# 3. Pilih "Assign MFA" di tab "Multi-factor authentication (MFA)"
# 4. Pilih jenis MFA (Virtual / Hardware / FIDO)
Best practice untuk root account:
- Enable MFA segera setelah membuat akun
- Jangan buat access key untuk root account
- Jangan gunakan root account untuk aktivitas sehari-hari
- Simpan root credentials di secure vault (contoh: AWS Secrets Manager, password manager terenkripsi)
- Monitor penggunaan root account via CloudTrail
Azure Global Admin MFA
# Enable MFA untuk Azure AD Global Administrator via CLI
az ad user update \
--force-change-password-next-sign-in true \
--password "TemporaryP@ss123"
Di Azure, MFA dikelola via Conditional Access Policy:
{
"displayName": "Require MFA for Admins",
"conditions": {
"users": {
"includeRoles": [
"62e90394-69f5-4237-9190-012177145e10" // Global Administrator role ID
]
},
"applications": {
"includeApplications": ["All"]
},
"clientAppTypes": ["all"]
},
"grantControls": {
"builtInControls": ["mfa"],
"operator": "OR"
},
"state": "enabled"
}
GCP Super Admin MFA
# GCP menggunakan Google Workspace Security settings
# Enable 2-Step Verification via Admin Console:
# Security > 2-Step Verification > Allow users to turn on 2-Step Verification
# Atau enforce via Organizational Policy
gcloud organizations add-iam-policy-binding ORG_ID \
--role="roles/resourcemanager.organizationAdmin"
MFA Enforcement Policies
MFA enforcement memastikan bahwa semua akses ke resource cloud harus melalui MFA - bahkan untuk API calls.
AWS: MFA Enforcement via IAM Policy
Gunakan Condition Key
aws:MultiFactorAuthPresent untuk mewajibkan MFA.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"BoolIfExists": {
"aws:MultiFactorAuthPresent": "false"
}
}
}
]
}
Penjelasan:
BoolIfExists: jika kondisi tidak ada (misal akses via CLI tanpa session token), dianggapfalseEffect: Deny: blokir akses jika MFA tidak hadir- Gunakan policy ini di AWS Organizations SCP untuk semua akun
AWS: MFA untuk API Calls via CLI
# Dapatkan temporary credentials dengan MFA
aws sts get-session-token \
--serial-number arn:aws:iam::123456789012:mfa/devops-phone \
--token-code 123456
# Output: temporary credentials (AccessKeyId, SecretAccessKey, SessionToken)
# Temporary credentials hanya valid 1 jam (default)
Konfigurasi MFA profile di ~/.aws/config:
[profile mfa]
region = ap-southeast-1
output = json
# Gunakan script untuk get-session-token otomatis
# Atau gunakan aws-vault untuk manajemen MFA session
Azure Conditional Access
Azure Conditional Access memberikan kontrol granular:
- Berdasarkan user/group - misal semua Global Admin wajib MFA
- Berdasarkan location - misal akses dari luar kantor wajib MFA
- Berdasarkan device - misal device non-compliant wajib MFA
- Berdasarkan application - misal Azure Portal wajib MFA, CLI tidak
# Azure CLI - login dengan MFA
az login --use-device-code
# Browser opens → masukkan kode → autentikasi dengan MFA
GCP MFA Enforcement
# Di GCP, MFA diatur via Google Workspace/Cloud Identity
# Enforce 2-Step Verification via Organization Policy
gcloud identity groups memberships add \
Conditional Access di Cloud
AWS
AWS Condition Keys untuk MFA:
| Condition Key | Deskripsi |
|---|---|
aws:MultiFactorAuthPresent |
Apakah MFA digunakan untuk sesi ini? (true/false) |
aws:MultiFactorAuthAge |
Berapa lama sejak MFA diautentikasi? (dalam detik) |
Contoh: MFA berlaku untuk akses ke production, tapi tidak untuk development:
{
"Effect": "Deny",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::prod-bucket/*",
"Condition": {
"BoolIfExists": {
"aws:MultiFactorAuthPresent": "false"
}
}
}
Azure
Azure Conditional Access Policies - contoh policy kompleks:
{
"displayName": "MFA + Compliant Device for Production",
"conditions": {
"users": { "includeGroups": ["sg-production-admins"] },
"applications": { "includeApplications": ["Azure Portal", "Microsoft Graph"] },
"locations": { "includeLocations": ["AllTrusted"] },
"clientAppTypes": ["browser", "mobileAppsAndDesktopClients"]
},
"grantControls": {
"builtInControls": ["mfa", "compliantDevice"],
"operator": "AND"
}
}
GCP
GCP menggunakan Access Context Manager untuk context-aware access:
gcloud access-context-manager levels create corp-access \
--title="Corporate Network" \
--basic-level-spec="conditions=ip_subnetworks:203.0.113.0/24"
Implementasi MFA di Tiap Provider
AWS
| Akun/User | MFA |
|---|---|
| Root Account | Wajib - via Console |
| IAM User | Virtual MFA, U2F, Hardware MFA |
| AWS SSO / IAM Identity Center | TOTP atau FIDO2 |
| Cross-account role | MFA via Session Token |
Azure
| Akun/User | MFA |
|---|---|
| Global Admin | Wajib - Security Defaults atau Conditional Access |
| Azure AD User | Per-user MFA, Conditional Access, Identity Protection |
| Service Principal | Certificate-based authentication (bukan MFA tradisional) |
| Azure CLI | Device code flow dengan MFA |
GCP
| Akun/User | MFA |
|---|---|
| Super Admin | Wajib - via Google Workspace 2-Step Verification |
| IAM Member | MFA via Google Account |
| Service Account | Key-based atau workload identity federation |
| gcloud CLI | Login flow dengan browser - mendukung MFA |
MFA Best Practices
- Enable MFA untuk semua user, bukan hanya admin - attacker sering target user non-privileged sebagai entry point
- Gunakan hardware security key untuk akun critical - root account, global admin
- Terapkan enforcement policy - jangan andalkan voluntary compliance
- Monitor dan alert MFA failures - CloudTrail + CloudWatch Alarm untuk AWS
- Buat backup MFA device - sediakan second device atau recovery codes
- Edukasi user - phishing awareness, jangan pernah memberikan kode MFA ke siapa pun
- Gunakan passwordless authentication - Windows Hello, FIDO2, biometric (lebih aman dari password + TOTP)
Kesimpulan
MFA adalah salah satu kontrol keamanan paling cost-effective di cloud. Dengan biaya hampir nol (untuk virtual MFA), Anda bisa memblokir sebagian besar serangan berbasis credential. Kombinasikan MFA dengan Conditional Access dan enforcement policy untuk lapisan pertahanan yang kuat. Ingat: password bisa dicuri, tetapi faktor kedua Anda harus tetap milik Anda.