iCloud keychain

A
Alexey TroshichevFounder at Hackapp
iCloud Keychain 
and 
iOS 7 Data Protection 
Andrey Belenko 
Sr. Security Engineer @ viaForensics 
! 
Alexey Troshichev 
@hackappcom founder
What is iCloud?
What’s inside? 
• Documents 
• Photos 
• Backups (SMS, application data, etc) 
• Keychain
Hacker’s view
Bruteforce protection?
Bruteforce protection?
Bruteforce protection?
Find My iPhone
Brought to you by 
hackapp.com 
! 
github.com/hackappcom/ibrute 
@hackappcom
iCloud Keychain 
Image: Apple Inc.
Motivation 
http://support.apple.com/kb/HT4865
Intercepting SSL 
SSL Proxy 
(Burp, Charles, …) 
Root CA cert 
Proxy settings
Authentication 
GET /authenticate 
AppleID, Password 
DsID, mmeAuthToken, fmipAuthToken 
icloud.com
/getAccountSettings
/getAccountSettings
iCloud keychain
iCloud keychain
Setup Options
The Big Picture 
*.keyvalueservice.icloud.com 
*.escrowproxy.icloud.com 
Keychain items (encrypted) 
Keybag (encrypted) 
Some Secret
Key-Value Store 
• Not new 
• Used extensively by many apps e.g. to keep preferences 
in sync across devices 
• iCloud Keychain utilises two stores: 
• com.apple.security.cloudkeychainproxy3 
• Syncing between devices 
• com.apple.sbd3 (securebackupd3) 
• Copy to restore if no other devices
Escrow Proxy 
• New; Designed to store precious secrets 
• Need to know iCSC to recover escrowed data 
• Need to receive SMS challenge 
• Must successfully complete SRP auth 
• User-Agent: com.apple.lakitu (iOS/OS X) 
Image: mariowiki.com
Key-Value Store 
com.apple.security.cloudkeychainproxy3 
S(usrPwd, D2_pub) 
S(D2_priv, (D1_pub, D2_pub)) 
S(D1_priv, D1_pub) 
S(userPwd, D1_pub) 
S(D1_priv, (D1_pub, D2_pub)) 
S(userPwd, (D1_pub, D2_pub))
Key-Value Store 
com.apple.sbd3 
Key Description 
com.apple.securebackup.enabled Is Keychain data saved in KVS? 
com.apple.securebackup.record Keychain records, encrypted 
SecureBackupMetadata iCSC complexity, timestamp, country 
BackupKeybag Keybag protecting Keychain records 
BackupUsesEscrow Is keybag password escrowed? 
BackupVersion Version, currently @“1” 
BackupUUID UUID of the backup
4-digit iCSC [Default]
4-digit iCSC [Default] 
Random Password 
BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4
4-digit iCSC [Default] 
Random Password 
BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 
Keychain Passwords 
yMa9ohCJ 
tzzcVhE7 
sDVoCnb 
Backup Keybag 
Key 1 
Key 2 
Key 3 
AES-GCM 
256 bit
4-digit iCSC [Default] 
Random Password 
BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 
Keychain Passwords 
yMa9ohCJ 
tzzcVhE7 
sDVoCnb 
Backup Keybag 
Key 1 
Key 2 
Key 3 
AES-GCM 
256 bit 
AES-Wrap Keys 
RFC 3394
4-digit iCSC [Default] 
Random Password 
BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 
Keychain Passwords 
yMa9ohCJ 
tzzcVhE7 
sDVoCnb 
Backup Keybag 
Key 1 
Key 2 
Key 3 
AES-GCM 
256 bit 
AES-Wrap Keys 
RFC 3394 
*.keyvalueservice.icloud.com
4-digit iCSC [Default] 
iCloud Security Code 
1234 PBKDF2 
Random Password 
BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 
SHA-256 x 10’000 
Keychain Passwords 
yMa9ohCJ 
tzzcVhE7 
sDVoCnb 
Backup Keybag 
Key 1 
Key 2 
Key 3 
AES-GCM 
256 bit 
AES-Wrap Keys 
RFC 3394 
*.keyvalueservice.icloud.com
4-digit iCSC [Default] 
iCloud Security Code 
1234 PBKDF2 
Random Password 
BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 
SHA-256 x 10’000 
AES-CBC 
256 bit 
*.escrowproxy.icloud.com 
Keychain Passwords 
yMa9ohCJ 
tzzcVhE7 
sDVoCnb 
Backup Keybag 
Key 1 
Key 2 
Key 3 
AES-GCM 
256 bit 
AES-Wrap Keys 
RFC 3394 
*.keyvalueservice.icloud.com
Secure Remote Password 
• Zero-knowledge password proof scheme 
• Combats sniffing/MITM 
• One password guess per connection attempt 
• Password verifier is not sufficient for impersonation 
• Escrow Proxy uses SRP-6a
Key Negotiation 
a ← random, A ← g^a 
b ← random, B ← kv + g^b 
u ← H(A, B) u ← H(A, B) 
x ← H(SALT, Password) 
S ← (B - kg^x) ^ (a + ux) 
K ← H(S) 
S ← (Av^u) ^ b 
K ← H(S) 
Key Verification 
M ← H(H(N) ⊕ H(g), H(ID), SALT, A, B, K) 
(Aborts if M is invalid) 
ID, A 
SALT, B 
M 
H(A, M, K) 
Password verifier: 
! 
SALT ← random 
x ← H(SALT,Password) 
v ← g^x 
Agreed-upon parameters: 
! 
H – one-way hash function 
N, g – group parameters 
k ← H(N, g)
Key Negotiation 
a ← random, A ← g^a 
b ← random, B ← kv + g^b 
u ← H(A, B) u ← H(A, B) 
x ← H(SALT, Password) 
S ← (B - kg^x) ^ (a + ux) 
K ← H(S) 
S ← (Av^u) ^ b 
K ← H(S) 
Key Verification 
M ← H(H(N) ⊕ H(g), H(ID), SALT, A, B, K) 
(Aborts if M is invalid) 
ID, A, SMS CODE 
SALT, B 
M, SMS CODE 
H(A, M, K) 
Password verifier: 
! 
SALT ← random 
x ← H(SALT,Password) 
v ← g^x 
Agreed-upon parameters: 
! 
H – SHA-256 
N, g – RFC 5054 w. 2048-bit group 
k ← H(N, g)
Escrowed Data Recovery 
*Display purposes only
Escrowed Data Recovery 
/get_records 
List of escrowed records 
*Display purposes only
Escrowed Data Recovery 
/get_records 
List of escrowed records 
/get_sms_targets 
List of phone numbers* 
*Display purposes only
Escrowed Data Recovery 
/get_records 
List of escrowed records 
/get_sms_targets 
List of phone numbers* 
/generate_sms_challenge 
OK 
*Display purposes only
Escrowed Data Recovery 
/get_records 
List of escrowed records 
/get_sms_targets 
List of phone numbers* 
/generate_sms_challenge 
OK 
/srp_init [DsID, A, SMS CODE] 
[UUID, DsID, SALT, B] 
*Display purposes only
Escrowed Data Recovery 
/get_records 
List of escrowed records 
/get_sms_targets 
List of phone numbers* 
/generate_sms_challenge 
OK 
/srp_init [DsID, A, SMS CODE] 
[UUID, DsID, SALT, B] 
/recover [UUID, DsID, M, SMS CODE] 
[IV, AES-CBC(KSRP, Escrowed Record)] 
*Display purposes only
Escrow Proxy Endpoints 
Endpoint Description 
get_club_cert [?] Obtain certificate 
enroll Submit escrow record 
get_records List escrowed records 
get_sms_targets List SMS numbers for escrowed records 
generate_sms_challenge Generate and send challenge code 
srp_init First step of SRP protocol 
recover Second step of SRP protocol 
alter_sms_target Change SMS number
Escrow Record 
iCloud Security Code 
1234 PBKDF2 
Random Password 
BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 
SHA-256 x 10’000 
AES-CBC 
256 bit 
*.escrowproxy.icloud.com 
Keychain Passwords 
yMa9ohCJ 
tzzcVhE7 
sDVoCnb 
AES-Wrap Keys 
RFC 3394 
Backup Keybag 
Key 1 
Key 2 
Key 3 
AES-GCM 
256 bit 
*.keyvalueservice.icloud.com
Escrow Record 
iCloud Security Code 
1234 PBKDF2 
Random Password 
BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 
SHA-256 x 10’000 
AES-CBC 
256 bit 
*.escrowproxy.icloud.com 
Key ← PBKDF2-SHA256(iCSC, 10’000) 
EscrowRecord ← AES-CBC(Key, RandomPassword)
Escrow Record 
Key ← PBKDF2-SHA256(iCSC, 10’000) 
EscrowRecord ← AES-CBC(Key, RandomPassword)
Escrow Record 
Key ← PBKDF2-SHA256(iCSC, 10’000) 
EscrowRecord ← AES-CBC(Key, RandomPassword) 
• This is stored by Apple
Escrow Record 
Key ← PBKDF2-SHA256(iCSC, 10’000) 
EscrowRecord ← AES-CBC(Key, RandomPassword) 
• This is stored by Apple 
• iCSC is 4 digits by default
Escrow Record 
Key ← PBKDF2-SHA256(iCSC, 10’000) 
EscrowRecord ← AES-CBC(Key, RandomPassword) 
• This is stored by Apple 
• iCSC is 4 digits by default
Escrow Record 
Key ← PBKDF2-SHA256(iCSC, 10’000) 
EscrowRecord ← AES-CBC(Key, RandomPassword) 
• This is stored by Apple 
• iCSC is 4 digits by default 
Can you spot the problem yet?
Escrow Record 
Key ← PBKDF2-SHA256(iCSC, 10’000) 
• Offline iCSC guessing is possible 
• Almost instant recovery [for default settings] 
• iCSC decrypts keybag password 
• Keybag password unlocks keybag keys 
• Keybag keys decrypt Keychain items
Apple, or other adversary with 
access to stored data, can near-instantly 
decrypt “master” 
password and read synced iCloud 
Keychain records 
! 
(for default settings)
Setup Options
Complex iCSC 
correct horse battery staple PBKDF2 
Keychain Passwords 
yMa9ohCJ 
tzzcVhE7 
sDVoCnb 
iCloud Security Code 
Random Password 
BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 
SHA-256 x 10’000 
AES-CBC 
256 bit 
Backup Keybag 
Key 1 
Key 2 
Key 3 
*.escrowproxy.icloud.com 
AES-Wrap Keys 
RFC 3394 
AES-GCM 
256 bit 
*.keyvalueservice.icloud.com
Complex iCSC 
• Mechanics are the same as with simple iCSC 
• Offline password recovery attack is still possible, 
although pointless if password is complex enough
Setup Options
Random Password 
BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 
Keychain Passwords 
yMa9ohCJ 
tzzcVhE7 
sDVoCnb 
AES-Wrap Keys 
RFC 3394 
Backup Keybag 
Key 1 
Key 2 
Key 3 
AES-GCM 
256 bit 
*.keyvalueservice.icloud.com 
iCloud Security Code 
correct horse battery staple PBKDF2 
SHA-256 x 10’000 
AES-CBC 
256 bit 
*.escrowproxy.icloud.com 
Random iCSC
Random Password 
BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 
Keychain Passwords 
yMa9ohCJ 
tzzcVhE7 
sDVoCnb 
AES-Wrap Keys 
RFC 3394 
Backup Keybag 
Key 1 
Key 2 
Key 3 
AES-GCM 
256 bit 
*.keyvalueservice.icloud.com 
iCloud Security Code 
correct horse battery staple PBKDF2 
SHA-256 x 10’000 
AES-CBC 
256 bit 
*.escrowproxy.icloud.com 
Random iCSC
Random iCSC 
Random Password 
BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 
Keychain Passwords 
yMa9ohCJ 
tzzcVhE7 
sDVoCnb 
AES-Wrap Keys 
RFC 3394 
Backup Keybag 
Key 1 
Key 2 
Key 3 
AES-GCM 
256 bit 
*.keyvalueservice.icloud.com
Random iCSC 
• Escrow Proxy is not used 
• Random iCSC (or derived key) stored on the device 
[haven’t verified]
Setup Options 
iCloud 
Keychain 
Keychain 
Sync 
Keychain 
Backup 
Master 
Password 
Escrow 
No iCloud Security Code 
Random iCloud Security Code 
Complex iCloud Security Code 
Simple iCloud Security Code
Conclusions 
Image: Apple Inc.
Conclusions 
• Trust your vendor but verify his claims 
• Never ever use simple iCloud Security Code 
• Do not think that SMS Apple sends you is a 2FA 
• Yet, iCK is reasonably well engineered although not 
without shortcomings
Thank You! 
Questions are welcome :-) 
! 
! 
@abelenko @hackappcom
1 of 61

Recommended

2014.11 asfws by
2014.11 asfws2014.11 asfws
2014.11 asfwsCyber Security Alliance
1.6K views77 slides
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜 by
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜Retrieva inc.
13.4K views41 slides
NGINX Back to Basics Part 3: Security (Japanese Version) by
NGINX Back to Basics Part 3: Security (Japanese Version)NGINX Back to Basics Part 3: Security (Japanese Version)
NGINX Back to Basics Part 3: Security (Japanese Version)NGINX, Inc.
500 views65 slides
Abusing Microsoft Kerberos - Sorry you guys don't get it by
Abusing Microsoft Kerberos - Sorry you guys don't get itAbusing Microsoft Kerberos - Sorry you guys don't get it
Abusing Microsoft Kerberos - Sorry you guys don't get itBenjamin Delpy
43.1K views53 slides
M08_あなたの知らない Azure インフラの世界 [Microsoft Japan Digital Days] by
M08_あなたの知らない Azure インフラの世界 [Microsoft Japan Digital Days]M08_あなたの知らない Azure インフラの世界 [Microsoft Japan Digital Days]
M08_あなたの知らない Azure インフラの世界 [Microsoft Japan Digital Days]日本マイクロソフト株式会社
1.5K views49 slides
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It by
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does ItAMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does ItNikhil Mittal
45K views26 slides

More Related Content

What's hot

Burp番外編~バープ、チョトニホンゴデキル~ by
Burp番外編~バープ、チョトニホンゴデキル~Burp番外編~バープ、チョトニホンゴデキル~
Burp番外編~バープ、チョトニホンゴデキル~abend_cve_9999_0001
3.5K views27 slides
IIJにおけるGlusterFS利用事例 GlusterFSの詳解と2年間の運用ノウハウ by
IIJにおけるGlusterFS利用事例 GlusterFSの詳解と2年間の運用ノウハウIIJにおけるGlusterFS利用事例 GlusterFSの詳解と2年間の運用ノウハウ
IIJにおけるGlusterFS利用事例 GlusterFSの詳解と2年間の運用ノウハウIIJ
4.3K views32 slides
15分でお届けする Elastic Stack on Azure 設計・構築ノウハウ by
15分でお届けする Elastic Stack on Azure 設計・構築ノウハウ15分でお届けする Elastic Stack on Azure 設計・構築ノウハウ
15分でお届けする Elastic Stack on Azure 設計・構築ノウハウYoichi Kawasaki
3.6K views16 slides
Rules to Hack By - Offensivecon 2022 keynote by
Rules to Hack By - Offensivecon 2022 keynoteRules to Hack By - Offensivecon 2022 keynote
Rules to Hack By - Offensivecon 2022 keynoteMarkDowd13
2.8K views39 slides
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx by
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, XilinxXPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, XilinxThe Linux Foundation
5.7K views23 slides
Hands-on ethernet driver by
Hands-on ethernet driverHands-on ethernet driver
Hands-on ethernet driverSUSE Labs Taipei
2.2K views22 slides

What's hot(20)

Burp番外編~バープ、チョトニホンゴデキル~ by abend_cve_9999_0001
Burp番外編~バープ、チョトニホンゴデキル~Burp番外編~バープ、チョトニホンゴデキル~
Burp番外編~バープ、チョトニホンゴデキル~
abend_cve_9999_00013.5K views
IIJにおけるGlusterFS利用事例 GlusterFSの詳解と2年間の運用ノウハウ by IIJ
IIJにおけるGlusterFS利用事例 GlusterFSの詳解と2年間の運用ノウハウIIJにおけるGlusterFS利用事例 GlusterFSの詳解と2年間の運用ノウハウ
IIJにおけるGlusterFS利用事例 GlusterFSの詳解と2年間の運用ノウハウ
IIJ4.3K views
15分でお届けする Elastic Stack on Azure 設計・構築ノウハウ by Yoichi Kawasaki
15分でお届けする Elastic Stack on Azure 設計・構築ノウハウ15分でお届けする Elastic Stack on Azure 設計・構築ノウハウ
15分でお届けする Elastic Stack on Azure 設計・構築ノウハウ
Yoichi Kawasaki3.6K views
Rules to Hack By - Offensivecon 2022 keynote by MarkDowd13
Rules to Hack By - Offensivecon 2022 keynoteRules to Hack By - Offensivecon 2022 keynote
Rules to Hack By - Offensivecon 2022 keynote
MarkDowd132.8K views
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx by The Linux Foundation
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, XilinxXPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
Hybrid Public Key Encryption (HPKE) by Jun Kurihara
Hybrid Public Key Encryption (HPKE)Hybrid Public Key Encryption (HPKE)
Hybrid Public Key Encryption (HPKE)
Jun Kurihara1K views
高速にコンテナを起動できるイメージフォーマット by Akihiro Suda
高速にコンテナを起動できるイメージフォーマット高速にコンテナを起動できるイメージフォーマット
高速にコンテナを起動できるイメージフォーマット
Akihiro Suda3.7K views
エンジニアのための Windows Virtual Desktop 設計術 by Takashi Ushigami
エンジニアのための Windows Virtual Desktop 設計術エンジニアのための Windows Virtual Desktop 設計術
エンジニアのための Windows Virtual Desktop 設計術
Takashi Ushigami2.9K views
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A... by Christian Schneider
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...
Christian Schneider1.5K views
Making a Headless Android Device by Patricia Aas
Making a Headless Android DeviceMaking a Headless Android Device
Making a Headless Android Device
Patricia Aas5.7K views
Securing your Pulsar Cluster with Vault_Chris Kellogg by StreamNative
Securing your Pulsar Cluster with Vault_Chris KelloggSecuring your Pulsar Cluster with Vault_Chris Kellogg
Securing your Pulsar Cluster with Vault_Chris Kellogg
StreamNative1K views
【18-E-3】クラウド・ネイティブ時代の2016年だから始める Docker 基礎講座 by Masahito Zembutsu
【18-E-3】クラウド・ネイティブ時代の2016年だから始める Docker 基礎講座【18-E-3】クラウド・ネイティブ時代の2016年だから始める Docker 基礎講座
【18-E-3】クラウド・ネイティブ時代の2016年だから始める Docker 基礎講座
Masahito Zembutsu20.3K views
DPDK IPSec Security Gateway Application by Michelle Holley
DPDK IPSec Security Gateway ApplicationDPDK IPSec Security Gateway Application
DPDK IPSec Security Gateway Application
Michelle Holley2.3K views
Splunk 7.0の概要及び新機能 by Kunihiko Ikeyama
Splunk 7.0の概要及び新機能Splunk 7.0の概要及び新機能
Splunk 7.0の概要及び新機能
Kunihiko Ikeyama3.1K views
Managing secrets at scale by Alex Schoof
Managing secrets at scaleManaging secrets at scale
Managing secrets at scale
Alex Schoof6.1K views
品質と開発スピードの両立と、OSSのリスク低減策のご紹介 / GTMF2019 by Game Tools & Middleware Forum
品質と開発スピードの両立と、OSSのリスク低減策のご紹介 / GTMF2019品質と開発スピードの両立と、OSSのリスク低減策のご紹介 / GTMF2019
品質と開発スピードの両立と、OSSのリスク低減策のご紹介 / GTMF2019

Viewers also liked

Icloud seminar report by
Icloud seminar reportIcloud seminar report
Icloud seminar reportRicha Dewani
19.2K views33 slides
iCloud - Apple Technology by
iCloud - Apple TechnologyiCloud - Apple Technology
iCloud - Apple TechnologyAsmita Kalena
7K views39 slides
iCloud by Apple by
iCloud by AppleiCloud by Apple
iCloud by AppleRicha Dewani
31.8K views22 slides
Applied cryptanalysis - everything else by
Applied cryptanalysis - everything elseApplied cryptanalysis - everything else
Applied cryptanalysis - everything elseVlad Garbuz
697 views40 slides
How apple can read your i messages by
How apple can read your i messagesHow apple can read your i messages
How apple can read your i messagesArtem I. Baranov
11.1K views88 slides
SkyDrive vs. SkyDrive Pro - Hans Brender by
SkyDrive vs. SkyDrive Pro - Hans Brender SkyDrive vs. SkyDrive Pro - Hans Brender
SkyDrive vs. SkyDrive Pro - Hans Brender Michael Greth
1.5K views73 slides

Viewers also liked(17)

Icloud seminar report by Richa Dewani
Icloud seminar reportIcloud seminar report
Icloud seminar report
Richa Dewani19.2K views
iCloud by Apple by Richa Dewani
iCloud by AppleiCloud by Apple
iCloud by Apple
Richa Dewani31.8K views
Applied cryptanalysis - everything else by Vlad Garbuz
Applied cryptanalysis - everything elseApplied cryptanalysis - everything else
Applied cryptanalysis - everything else
Vlad Garbuz697 views
How apple can read your i messages by Artem I. Baranov
How apple can read your i messagesHow apple can read your i messages
How apple can read your i messages
Artem I. Baranov11.1K views
SkyDrive vs. SkyDrive Pro - Hans Brender by Michael Greth
SkyDrive vs. SkyDrive Pro - Hans Brender SkyDrive vs. SkyDrive Pro - Hans Brender
SkyDrive vs. SkyDrive Pro - Hans Brender
Michael Greth1.5K views
iPhone forensics on iOS5 by Satish b
iPhone forensics on iOS5iPhone forensics on iOS5
iPhone forensics on iOS5
Satish b14.8K views
How Android and iOS Security Enhancements Complicate Threat Detection by NowSecure
How Android and iOS Security Enhancements Complicate Threat DetectionHow Android and iOS Security Enhancements Complicate Threat Detection
How Android and iOS Security Enhancements Complicate Threat Detection
NowSecure619 views
Icloud keynote2 by avsorrent
Icloud keynote2Icloud keynote2
Icloud keynote2
avsorrent2.8K views
Bio-Molecular Engineering is the Future of Molecular Biology by Bob Eisenberg
Bio-Molecular Engineering is the Future of Molecular BiologyBio-Molecular Engineering is the Future of Molecular Biology
Bio-Molecular Engineering is the Future of Molecular Biology
Bob Eisenberg1.3K views
Apple iCloud by 우일 권
Apple iCloudApple iCloud
Apple iCloud
우일 권5.2K views
soft-computing by student
 soft-computing soft-computing
soft-computing
student11.5K views

Similar to iCloud keychain

Via forensics icloud-keychain_passwords_13 by
Via forensics icloud-keychain_passwords_13Via forensics icloud-keychain_passwords_13
Via forensics icloud-keychain_passwords_13viaForensics
924 views38 slides
7.3. iCloud keychain-2 by
7.3. iCloud keychain-27.3. iCloud keychain-2
7.3. iCloud keychain-2defconmoscow
722 views61 slides
6.1. iCloud keychain and iOS 7 data protection by
6.1. iCloud keychain and iOS 7 data protection6.1. iCloud keychain and iOS 7 data protection
6.1. iCloud keychain and iOS 7 data protectiondefconmoscow
784 views35 slides
Django cryptography by
Django cryptographyDjango cryptography
Django cryptographyErik LaBianca
9.5K views29 slides
Protect Sensitive Data with Ada Keystore by
Protect Sensitive Data with Ada KeystoreProtect Sensitive Data with Ada Keystore
Protect Sensitive Data with Ada KeystoreStephane Carrez
191 views24 slides
Dodging WebCrypto API Landmines by
Dodging WebCrypto API LandminesDodging WebCrypto API Landmines
Dodging WebCrypto API LandminesErnie Turner
1.2K views84 slides

Similar to iCloud keychain(20)

Via forensics icloud-keychain_passwords_13 by viaForensics
Via forensics icloud-keychain_passwords_13Via forensics icloud-keychain_passwords_13
Via forensics icloud-keychain_passwords_13
viaForensics 924 views
7.3. iCloud keychain-2 by defconmoscow
7.3. iCloud keychain-27.3. iCloud keychain-2
7.3. iCloud keychain-2
defconmoscow722 views
6.1. iCloud keychain and iOS 7 data protection by defconmoscow
6.1. iCloud keychain and iOS 7 data protection6.1. iCloud keychain and iOS 7 data protection
6.1. iCloud keychain and iOS 7 data protection
defconmoscow784 views
Protect Sensitive Data with Ada Keystore by Stephane Carrez
Protect Sensitive Data with Ada KeystoreProtect Sensitive Data with Ada Keystore
Protect Sensitive Data with Ada Keystore
Stephane Carrez191 views
Dodging WebCrypto API Landmines by Ernie Turner
Dodging WebCrypto API LandminesDodging WebCrypto API Landmines
Dodging WebCrypto API Landmines
Ernie Turner1.2K views
Adventures in Underland: Is encryption solid as a rock or a handful of dust? by Paula Januszkiewicz
Adventures in Underland: Is encryption solid as a rock or a handful of dust?Adventures in Underland: Is encryption solid as a rock or a handful of dust?
Adventures in Underland: Is encryption solid as a rock or a handful of dust?
Paula Januszkiewicz5.8K views
Cryptography for Smalltalkers 2 by ESUG
Cryptography for Smalltalkers 2Cryptography for Smalltalkers 2
Cryptography for Smalltalkers 2
ESUG783 views
Cryptography and SSL in Smalltalk - StS 2003 by Martin Kobetic
Cryptography and SSL in Smalltalk - StS 2003Cryptography and SSL in Smalltalk - StS 2003
Cryptography and SSL in Smalltalk - StS 2003
Martin Kobetic428 views
Cryptography for Absolute Beginners (May 2019) by Svetlin Nakov
Cryptography for Absolute Beginners (May 2019)Cryptography for Absolute Beginners (May 2019)
Cryptography for Absolute Beginners (May 2019)
Svetlin Nakov1.9K views
Securing the Web without site-specific passwords by Francois Marier
Securing the Web without site-specific passwordsSecuring the Web without site-specific passwords
Securing the Web without site-specific passwords
Francois Marier835 views
Security and Encryption on iOS by Graham Lee
Security and Encryption on iOSSecurity and Encryption on iOS
Security and Encryption on iOS
Graham Lee4.2K views
12 symmetric key cryptography by drewz lin
12   symmetric key cryptography12   symmetric key cryptography
12 symmetric key cryptography
drewz lin9.9K views
Cryptography 101 for Java developers by Michel Schudel
Cryptography 101 for Java developersCryptography 101 for Java developers
Cryptography 101 for Java developers
Michel Schudel233 views
PEW PEW PEW: Designing Secure Boot Securely by Riscure
PEW PEW PEW: Designing Secure Boot SecurelyPEW PEW PEW: Designing Secure Boot Securely
PEW PEW PEW: Designing Secure Boot Securely
Riscure991 views
PEW PEW PEW: Designing Secure Boot Securely by Niek Timmers
PEW PEW PEW: Designing Secure Boot SecurelyPEW PEW PEW: Designing Secure Boot Securely
PEW PEW PEW: Designing Secure Boot Securely
Niek Timmers1.4K views
Overview and evolution of password-based authentication schemes by Ignat Korchagin
Overview and evolution of password-based authentication schemesOverview and evolution of password-based authentication schemes
Overview and evolution of password-based authentication schemes
Ignat Korchagin1.5K views
Cryptography for Smalltalkers by ESUG
Cryptography for SmalltalkersCryptography for Smalltalkers
Cryptography for Smalltalkers
ESUG455 views

Recently uploaded

Is Entireweb better than Google by
Is Entireweb better than GoogleIs Entireweb better than Google
Is Entireweb better than Googlesebastianthomasbejan
12 views1 slide
UiPath Document Understanding_Day 3.pptx by
UiPath Document Understanding_Day 3.pptxUiPath Document Understanding_Day 3.pptx
UiPath Document Understanding_Day 3.pptxUiPathCommunity
103 views25 slides
How to think like a threat actor for Kubernetes.pptx by
How to think like a threat actor for Kubernetes.pptxHow to think like a threat actor for Kubernetes.pptx
How to think like a threat actor for Kubernetes.pptxLibbySchulze1
5 views33 slides
PORTFOLIO 1 (Bret Michael Pepito).pdf by
PORTFOLIO 1 (Bret Michael Pepito).pdfPORTFOLIO 1 (Bret Michael Pepito).pdf
PORTFOLIO 1 (Bret Michael Pepito).pdfbrejess0410
8 views6 slides
𝐒𝐨𝐥𝐚𝐫𝐖𝐢𝐧𝐝𝐬 𝐂𝐚𝐬𝐞 𝐒𝐭𝐮𝐝𝐲 by
𝐒𝐨𝐥𝐚𝐫𝐖𝐢𝐧𝐝𝐬 𝐂𝐚𝐬𝐞 𝐒𝐭𝐮𝐝𝐲𝐒𝐨𝐥𝐚𝐫𝐖𝐢𝐧𝐝𝐬 𝐂𝐚𝐬𝐞 𝐒𝐭𝐮𝐝𝐲
𝐒𝐨𝐥𝐚𝐫𝐖𝐢𝐧𝐝𝐬 𝐂𝐚𝐬𝐞 𝐒𝐭𝐮𝐝𝐲Infosec train
9 views6 slides
Building trust in our information ecosystem: who do we trust in an emergency by
Building trust in our information ecosystem: who do we trust in an emergencyBuilding trust in our information ecosystem: who do we trust in an emergency
Building trust in our information ecosystem: who do we trust in an emergencyTina Purnat
98 views18 slides

Recently uploaded(12)

UiPath Document Understanding_Day 3.pptx by UiPathCommunity
UiPath Document Understanding_Day 3.pptxUiPath Document Understanding_Day 3.pptx
UiPath Document Understanding_Day 3.pptx
UiPathCommunity103 views
How to think like a threat actor for Kubernetes.pptx by LibbySchulze1
How to think like a threat actor for Kubernetes.pptxHow to think like a threat actor for Kubernetes.pptx
How to think like a threat actor for Kubernetes.pptx
LibbySchulze15 views
PORTFOLIO 1 (Bret Michael Pepito).pdf by brejess0410
PORTFOLIO 1 (Bret Michael Pepito).pdfPORTFOLIO 1 (Bret Michael Pepito).pdf
PORTFOLIO 1 (Bret Michael Pepito).pdf
brejess04108 views
𝐒𝐨𝐥𝐚𝐫𝐖𝐢𝐧𝐝𝐬 𝐂𝐚𝐬𝐞 𝐒𝐭𝐮𝐝𝐲 by Infosec train
𝐒𝐨𝐥𝐚𝐫𝐖𝐢𝐧𝐝𝐬 𝐂𝐚𝐬𝐞 𝐒𝐭𝐮𝐝𝐲𝐒𝐨𝐥𝐚𝐫𝐖𝐢𝐧𝐝𝐬 𝐂𝐚𝐬𝐞 𝐒𝐭𝐮𝐝𝐲
𝐒𝐨𝐥𝐚𝐫𝐖𝐢𝐧𝐝𝐬 𝐂𝐚𝐬𝐞 𝐒𝐭𝐮𝐝𝐲
Infosec train9 views
Building trust in our information ecosystem: who do we trust in an emergency by Tina Purnat
Building trust in our information ecosystem: who do we trust in an emergencyBuilding trust in our information ecosystem: who do we trust in an emergency
Building trust in our information ecosystem: who do we trust in an emergency
Tina Purnat98 views
IETF 118: Starlink Protocol Performance by APNIC
IETF 118: Starlink Protocol PerformanceIETF 118: Starlink Protocol Performance
IETF 118: Starlink Protocol Performance
APNIC244 views
We see everywhere that many people are talking about technology.docx by ssuserc5935b
We see everywhere that many people are talking about technology.docxWe see everywhere that many people are talking about technology.docx
We see everywhere that many people are talking about technology.docx
ssuserc5935b6 views
Marketing and Community Building in Web3 by Federico Ast
Marketing and Community Building in Web3Marketing and Community Building in Web3
Marketing and Community Building in Web3
Federico Ast12 views

iCloud keychain

  • 1. iCloud Keychain and iOS 7 Data Protection Andrey Belenko Sr. Security Engineer @ viaForensics ! Alexey Troshichev @hackappcom founder
  • 3. What’s inside? • Documents • Photos • Backups (SMS, application data, etc) • Keychain
  • 9. Brought to you by hackapp.com ! github.com/hackappcom/ibrute @hackappcom
  • 12. Intercepting SSL SSL Proxy (Burp, Charles, …) Root CA cert Proxy settings
  • 13. Authentication GET /authenticate AppleID, Password DsID, mmeAuthToken, fmipAuthToken icloud.com
  • 19. The Big Picture *.keyvalueservice.icloud.com *.escrowproxy.icloud.com Keychain items (encrypted) Keybag (encrypted) Some Secret
  • 20. Key-Value Store • Not new • Used extensively by many apps e.g. to keep preferences in sync across devices • iCloud Keychain utilises two stores: • com.apple.security.cloudkeychainproxy3 • Syncing between devices • com.apple.sbd3 (securebackupd3) • Copy to restore if no other devices
  • 21. Escrow Proxy • New; Designed to store precious secrets • Need to know iCSC to recover escrowed data • Need to receive SMS challenge • Must successfully complete SRP auth • User-Agent: com.apple.lakitu (iOS/OS X) Image: mariowiki.com
  • 22. Key-Value Store com.apple.security.cloudkeychainproxy3 S(usrPwd, D2_pub) S(D2_priv, (D1_pub, D2_pub)) S(D1_priv, D1_pub) S(userPwd, D1_pub) S(D1_priv, (D1_pub, D2_pub)) S(userPwd, (D1_pub, D2_pub))
  • 23. Key-Value Store com.apple.sbd3 Key Description com.apple.securebackup.enabled Is Keychain data saved in KVS? com.apple.securebackup.record Keychain records, encrypted SecureBackupMetadata iCSC complexity, timestamp, country BackupKeybag Keybag protecting Keychain records BackupUsesEscrow Is keybag password escrowed? BackupVersion Version, currently @“1” BackupUUID UUID of the backup
  • 25. 4-digit iCSC [Default] Random Password BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4
  • 26. 4-digit iCSC [Default] Random Password BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 Keychain Passwords yMa9ohCJ tzzcVhE7 sDVoCnb Backup Keybag Key 1 Key 2 Key 3 AES-GCM 256 bit
  • 27. 4-digit iCSC [Default] Random Password BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 Keychain Passwords yMa9ohCJ tzzcVhE7 sDVoCnb Backup Keybag Key 1 Key 2 Key 3 AES-GCM 256 bit AES-Wrap Keys RFC 3394
  • 28. 4-digit iCSC [Default] Random Password BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 Keychain Passwords yMa9ohCJ tzzcVhE7 sDVoCnb Backup Keybag Key 1 Key 2 Key 3 AES-GCM 256 bit AES-Wrap Keys RFC 3394 *.keyvalueservice.icloud.com
  • 29. 4-digit iCSC [Default] iCloud Security Code 1234 PBKDF2 Random Password BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 SHA-256 x 10’000 Keychain Passwords yMa9ohCJ tzzcVhE7 sDVoCnb Backup Keybag Key 1 Key 2 Key 3 AES-GCM 256 bit AES-Wrap Keys RFC 3394 *.keyvalueservice.icloud.com
  • 30. 4-digit iCSC [Default] iCloud Security Code 1234 PBKDF2 Random Password BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 SHA-256 x 10’000 AES-CBC 256 bit *.escrowproxy.icloud.com Keychain Passwords yMa9ohCJ tzzcVhE7 sDVoCnb Backup Keybag Key 1 Key 2 Key 3 AES-GCM 256 bit AES-Wrap Keys RFC 3394 *.keyvalueservice.icloud.com
  • 31. Secure Remote Password • Zero-knowledge password proof scheme • Combats sniffing/MITM • One password guess per connection attempt • Password verifier is not sufficient for impersonation • Escrow Proxy uses SRP-6a
  • 32. Key Negotiation a ← random, A ← g^a b ← random, B ← kv + g^b u ← H(A, B) u ← H(A, B) x ← H(SALT, Password) S ← (B - kg^x) ^ (a + ux) K ← H(S) S ← (Av^u) ^ b K ← H(S) Key Verification M ← H(H(N) ⊕ H(g), H(ID), SALT, A, B, K) (Aborts if M is invalid) ID, A SALT, B M H(A, M, K) Password verifier: ! SALT ← random x ← H(SALT,Password) v ← g^x Agreed-upon parameters: ! H – one-way hash function N, g – group parameters k ← H(N, g)
  • 33. Key Negotiation a ← random, A ← g^a b ← random, B ← kv + g^b u ← H(A, B) u ← H(A, B) x ← H(SALT, Password) S ← (B - kg^x) ^ (a + ux) K ← H(S) S ← (Av^u) ^ b K ← H(S) Key Verification M ← H(H(N) ⊕ H(g), H(ID), SALT, A, B, K) (Aborts if M is invalid) ID, A, SMS CODE SALT, B M, SMS CODE H(A, M, K) Password verifier: ! SALT ← random x ← H(SALT,Password) v ← g^x Agreed-upon parameters: ! H – SHA-256 N, g – RFC 5054 w. 2048-bit group k ← H(N, g)
  • 34. Escrowed Data Recovery *Display purposes only
  • 35. Escrowed Data Recovery /get_records List of escrowed records *Display purposes only
  • 36. Escrowed Data Recovery /get_records List of escrowed records /get_sms_targets List of phone numbers* *Display purposes only
  • 37. Escrowed Data Recovery /get_records List of escrowed records /get_sms_targets List of phone numbers* /generate_sms_challenge OK *Display purposes only
  • 38. Escrowed Data Recovery /get_records List of escrowed records /get_sms_targets List of phone numbers* /generate_sms_challenge OK /srp_init [DsID, A, SMS CODE] [UUID, DsID, SALT, B] *Display purposes only
  • 39. Escrowed Data Recovery /get_records List of escrowed records /get_sms_targets List of phone numbers* /generate_sms_challenge OK /srp_init [DsID, A, SMS CODE] [UUID, DsID, SALT, B] /recover [UUID, DsID, M, SMS CODE] [IV, AES-CBC(KSRP, Escrowed Record)] *Display purposes only
  • 40. Escrow Proxy Endpoints Endpoint Description get_club_cert [?] Obtain certificate enroll Submit escrow record get_records List escrowed records get_sms_targets List SMS numbers for escrowed records generate_sms_challenge Generate and send challenge code srp_init First step of SRP protocol recover Second step of SRP protocol alter_sms_target Change SMS number
  • 41. Escrow Record iCloud Security Code 1234 PBKDF2 Random Password BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 SHA-256 x 10’000 AES-CBC 256 bit *.escrowproxy.icloud.com Keychain Passwords yMa9ohCJ tzzcVhE7 sDVoCnb AES-Wrap Keys RFC 3394 Backup Keybag Key 1 Key 2 Key 3 AES-GCM 256 bit *.keyvalueservice.icloud.com
  • 42. Escrow Record iCloud Security Code 1234 PBKDF2 Random Password BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 SHA-256 x 10’000 AES-CBC 256 bit *.escrowproxy.icloud.com Key ← PBKDF2-SHA256(iCSC, 10’000) EscrowRecord ← AES-CBC(Key, RandomPassword)
  • 43. Escrow Record Key ← PBKDF2-SHA256(iCSC, 10’000) EscrowRecord ← AES-CBC(Key, RandomPassword)
  • 44. Escrow Record Key ← PBKDF2-SHA256(iCSC, 10’000) EscrowRecord ← AES-CBC(Key, RandomPassword) • This is stored by Apple
  • 45. Escrow Record Key ← PBKDF2-SHA256(iCSC, 10’000) EscrowRecord ← AES-CBC(Key, RandomPassword) • This is stored by Apple • iCSC is 4 digits by default
  • 46. Escrow Record Key ← PBKDF2-SHA256(iCSC, 10’000) EscrowRecord ← AES-CBC(Key, RandomPassword) • This is stored by Apple • iCSC is 4 digits by default
  • 47. Escrow Record Key ← PBKDF2-SHA256(iCSC, 10’000) EscrowRecord ← AES-CBC(Key, RandomPassword) • This is stored by Apple • iCSC is 4 digits by default Can you spot the problem yet?
  • 48. Escrow Record Key ← PBKDF2-SHA256(iCSC, 10’000) • Offline iCSC guessing is possible • Almost instant recovery [for default settings] • iCSC decrypts keybag password • Keybag password unlocks keybag keys • Keybag keys decrypt Keychain items
  • 49. Apple, or other adversary with access to stored data, can near-instantly decrypt “master” password and read synced iCloud Keychain records ! (for default settings)
  • 51. Complex iCSC correct horse battery staple PBKDF2 Keychain Passwords yMa9ohCJ tzzcVhE7 sDVoCnb iCloud Security Code Random Password BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 SHA-256 x 10’000 AES-CBC 256 bit Backup Keybag Key 1 Key 2 Key 3 *.escrowproxy.icloud.com AES-Wrap Keys RFC 3394 AES-GCM 256 bit *.keyvalueservice.icloud.com
  • 52. Complex iCSC • Mechanics are the same as with simple iCSC • Offline password recovery attack is still possible, although pointless if password is complex enough
  • 54. Random Password BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 Keychain Passwords yMa9ohCJ tzzcVhE7 sDVoCnb AES-Wrap Keys RFC 3394 Backup Keybag Key 1 Key 2 Key 3 AES-GCM 256 bit *.keyvalueservice.icloud.com iCloud Security Code correct horse battery staple PBKDF2 SHA-256 x 10’000 AES-CBC 256 bit *.escrowproxy.icloud.com Random iCSC
  • 55. Random Password BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 Keychain Passwords yMa9ohCJ tzzcVhE7 sDVoCnb AES-Wrap Keys RFC 3394 Backup Keybag Key 1 Key 2 Key 3 AES-GCM 256 bit *.keyvalueservice.icloud.com iCloud Security Code correct horse battery staple PBKDF2 SHA-256 x 10’000 AES-CBC 256 bit *.escrowproxy.icloud.com Random iCSC
  • 56. Random iCSC Random Password BL7Z-EBTJ-UBKD-X7NM-4W6D-J2N4 Keychain Passwords yMa9ohCJ tzzcVhE7 sDVoCnb AES-Wrap Keys RFC 3394 Backup Keybag Key 1 Key 2 Key 3 AES-GCM 256 bit *.keyvalueservice.icloud.com
  • 57. Random iCSC • Escrow Proxy is not used • Random iCSC (or derived key) stored on the device [haven’t verified]
  • 58. Setup Options iCloud Keychain Keychain Sync Keychain Backup Master Password Escrow No iCloud Security Code Random iCloud Security Code Complex iCloud Security Code Simple iCloud Security Code
  • 60. Conclusions • Trust your vendor but verify his claims • Never ever use simple iCloud Security Code • Do not think that SMS Apple sends you is a 2FA • Yet, iCK is reasonably well engineered although not without shortcomings
  • 61. Thank You! Questions are welcome :-) ! ! @abelenko @hackappcom