OWASP Lithuania - Luca Bongiorni – 05/03/2015
 Introduction to Pinning
 Why is good to have it...
 State of Art – Android / iOS / Win
 Conclusion – Pros & Cons
2
3
 Mobile applications frequently do not protect network traffic.
 They may use SSL/TLS during authentication but not elsewhere.
This inconsistency leads to the risk of exposing data and session IDs to
interception.
Business Impact
 Loss of Confidentiality and Integrity
 Company’s reputation at risk
 Incident response costs $$$
 Possible legal issues (e.g. violation of ISO/PCI requirements)
Mitigation
 Use End-to-End encryption between browser and web server (HTTPS)
► SSL/TLS ► Certificate Pinning !
4
Pinning is the process of associating a host with their expected
*{X509 certificate || public key}. Once a certificate or public key is
known or seen for a host, the certificate or public key is associated or
'pinned' to the host. <…>
• The pre-existing relationship between the user and an
organization helps make better security related decisions.
• No longer needs to depend on others (e.g. CAs) when making
security decisions relating to a peer's identity!
5
 The certificate is easiest to pin.
When the certificate expires, you would update your
application.
 Public key pinning is more flexible but a little trickier due to the extra
steps necessary to extract the public key from a certificate.
o As with a certificate, the program checks the extracted public key with its
embedded copy of the public key.
o It is harder to work with keys (Vs. certificates) since you usually must
extract the key from the certificate. Extraction is a minor inconvenience in
Java, buts its uncomfortable in Cocoa and OpenSSL.
o The key is static and may violate key rotation policies.
 Introduction to Pinning
 Why is good to have it...
 State of Art – Android / iOS / Win
 Conclusion – Pros & Cons
6
7
“An IMSI-Catcher (International Mobile Subscriber Identity) is
a telephony eavesdropping device used for intercepting
mobile phone traffic and tracking movement of subscribers.
Essentially a "fake" mobile tower acting between the target
mobile phone and the MNO's real BTSes, it is considered a
Man-In-The-Middle (MITM) attack.”
Fake WiFi AP + jam real AP? ARP Poisoning?… Old known
boring threats.
8
9
 Introduction to Pinning
 Why is good to have it...
 State of Art – Android / iOS / Win
 Conclusion – Pros & Cons
10
11
Pinning is accomplished through a custom X509TrustManager API. Google
Chrome PubKey pinning style.
Customized version of TrustManager from Moxie Marlinspike available at:
https://github.com/moxie0/AndroidPinning
public PinningTrustManager(SystemKeyStore keyStore, String[] pins, long
enforceUntilTimestampMillis) {
this.systemTrustManagers = initializeSystemTrustManagers(keyStore);
this.systemKeyStore = keyStore;
this.enforceUntilTimestampMillis = enforceUntilTimestampMillis;
for (String pin : pins) {
this.pins.add(hexStringToByteArray(pin));
}
}
Constructs a PinningTrustManager with a set of valid pins.
@param keyStore A SystemKeyStore that validation will be based on.
@param pins An array of encoded pins to match a seen certificate chain against. A pin is a hex-
encoded hash of a X.509 certificate's SubjectPublicKeyInfo. A pin can be generated using the
provided ./tools/pin.py certificate_file.pem
@param enforceUntilTimestampMillis A timestamp (in milliseconds) when pins will stop being
enforced. Normal non-pinned certificate validation will continue. Set this to some period after your
build date, or to 0 to enforce pins forever.
12
The method used to Ping Certificates is
:connection:willSendRequestForAuthenticationChallenge:
inside the NSURLConnectionDelegate protocol.
This method gets called when an SSL connection is made, giving the developer, a
chance to inspect the authentication challenge and either proceed or fail.
The code below shows how you can check the certificate sent by the server, with
a known certificate embedded in your applications.
After doing await and socket.UpgradeToSslAsync(), check
socket.Information.ServerCertificate for the cert that was provided by the server.
You can verify that it's the cert you were expecting before you send any data. 13
The majority of Windows Phone 8 applications on the Marketplace lack certificate
pinning due to the difficulty of implementing this security measure on the
platform.
Possible solutions:
• For Win 8.0: Use an open source third party library for SSL such as OpenSSL
or Bouncy Castle crypto Libs and attempt to build for Windows Phone. Cons: It
may require significant effort to implement correctly.
• For Win 8.0: Use a commercial library supporting SSL pinning:
SecureBlackBox (https://www.eldos.com/sbb/). Cons: $$$
• >= Win 8.1: Thanks to the use of StreamSocket we can read the contents of the
certificate via StreamSocket.Information.ServerCertificate property.
StreamSocket s = new StreamSocket();
await s.ConnectAsync(new HostName(SrvURL), "443");
s.UpgradeToSslAsync(SocketProtectionLevel.Ssl, new HostName(SrvURL));
var certificate = s.Information.ServerCertificate;
 Introduction to Pinning
 Why is good to have it...
 State of Art – Android / iOS / Win
 Conclusion – Pros & Cons
14
PROS
15
 Better Security: Drastically reduce the ability to conduct successful MITM
attacks.
 Not Hard to Implement: Not as difficult as it seems to implement a basic
certificate pinning.
 Cost Saving: By using a self-signed certificate is possible reduce the costs,
instead of paying for a certificate.
• Possible problems in case of Certificate or PubKey revocation.
• Egress filtering in a corporate environment (i.e. Interception Proxy)
• The certificate embedded in your app will eventually expire.
Your have to either plan for an app update that contains an updated
certificate, or code a way for the application to download the new
certificate, which is hardly achievable in practice.
CONS
16
• https://www.owasp.org/index.php/Mobile_Top_10_2014-M3
• https://www.owasp.org/index.php/Certificate_and_Public_Key_Pinning
• https://tools.ietf.org/html/draft-ietf-websec-key-pinning-21
• https://www.owasp.org/index.php/Pinning_Cheat_Sheet
• http://www.thoughtcrime.org/blog/authenticity-is-broken-in-ssl-but-your-app-ha/
• http://developer.android.com/reference/android/net/http/X509TrustManagerExte
nsions.html
• https://www.isecpartners.com/blog/2013/february/ssl-pinning-on-ios.aspx
• www.doubleencore.com/2013/03/ssl-pinning-for-increased-app-security/
• http://blog.soat.fr/2014/11/wp8-problematique-du-certificate-pinning/
• http://www.slideshare.net/iazza/dcm-final-23052013fullycensored
• http://chargen.matasano.com/chargen/2015/1/6/bypassing-openssl-certificate-
pinning-in-ios-apps.html
17

More Related Content

PPTX
REST API
PPTX
Certificate pinning v certificate transparency
PDF
Spring Security
PDF
Terraform을 이용한 Infrastructure as Code 실전 구성하기 :: 변정훈::AWS Summit Seoul 2018
PDF
Websocket + Redis pubsub
PDF
Api security-testing
PPTX
Golang - Overview of Go (golang) Language
PPTX
Best Practices for running the Oracle Database on EC2 webinar
REST API
Certificate pinning v certificate transparency
Spring Security
Terraform을 이용한 Infrastructure as Code 실전 구성하기 :: 변정훈::AWS Summit Seoul 2018
Websocket + Redis pubsub
Api security-testing
Golang - Overview of Go (golang) Language
Best Practices for running the Oracle Database on EC2 webinar

What's hot (20)

PPTX
REST & RESTful Web Services
PDF
Web Application Security
PPTX
Waf bypassing Techniques
PPTX
Kotlin presentation
PDF
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
PPT
Http VS. Https
PDF
SAML Protocol Overview
PDF
CSS Selectors
PDF
REST APIs with Spring
PPT
Top 10 Web Security Vulnerabilities (OWASP Top 10)
PPTX
Thick client pentesting_the-hackers_meetup_version1.0pptx
PPTX
Os Command Injection Attack
PPT
PDF
A story of the passive aggressive sysadmin of AEM
PDF
What is API - Understanding API Simplified
PPTX
ECS+Locust로 부하 테스트 진행하기
PPTX
XXE: How to become a Jedi
PPTX
Where and when to use the Oracle Service Bus (OSB)
PPTX
Dom based xss
REST & RESTful Web Services
Web Application Security
Waf bypassing Techniques
Kotlin presentation
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
Http VS. Https
SAML Protocol Overview
CSS Selectors
REST APIs with Spring
Top 10 Web Security Vulnerabilities (OWASP Top 10)
Thick client pentesting_the-hackers_meetup_version1.0pptx
Os Command Injection Attack
A story of the passive aggressive sysadmin of AEM
What is API - Understanding API Simplified
ECS+Locust로 부하 테스트 진행하기
XXE: How to become a Jedi
Where and when to use the Oracle Service Bus (OSB)
Dom based xss
Ad

Viewers also liked (20)

PDF
SSL Pinning and Bypasses: Android and iOS
PPTX
Pentesting Android Applications
PPTX
Mobile App Security: Enterprise Checklist
PPTX
Pentesting Android with BackBox 4
PDF
Lockpicking Baltic Cyber Security Forum 2013
PPTX
Forms4all
PDF
Introduction to Mobile Application Security - Techcity 2015 (Vilnius)
PPTX
Penetrating Android Aapplications
PDF
PDF
Mobile Network Security: a tale of tracking, spoofing and owning mobile phone...
PDF
NCC Group 44Con Workshop: How to assess and secure ios apps
PDF
Toward Better Password Requirements
PDF
iParanoid: an IMSI Catcher - Stingray Intrusion Detection System
PDF
«Автотесты» Вадим Пуштаев, программист отдела внутренней разработки Поиска Ma...
PDF
Java Tools and Technologies Landscape for 2014 (image gallery)
PDF
Real Life Clean Architecture
PPTX
JavaStart - kurs Java Podstawy
PPTX
«Coro. Intro» Евгений Вансевич, программист Почты Mail.Ru
PDF
My Null Android Penetration Session
PDF
Android Security & Penetration Testing
SSL Pinning and Bypasses: Android and iOS
Pentesting Android Applications
Mobile App Security: Enterprise Checklist
Pentesting Android with BackBox 4
Lockpicking Baltic Cyber Security Forum 2013
Forms4all
Introduction to Mobile Application Security - Techcity 2015 (Vilnius)
Penetrating Android Aapplications
Mobile Network Security: a tale of tracking, spoofing and owning mobile phone...
NCC Group 44Con Workshop: How to assess and secure ios apps
Toward Better Password Requirements
iParanoid: an IMSI Catcher - Stingray Intrusion Detection System
«Автотесты» Вадим Пуштаев, программист отдела внутренней разработки Поиска Ma...
Java Tools and Technologies Landscape for 2014 (image gallery)
Real Life Clean Architecture
JavaStart - kurs Java Podstawy
«Coro. Intro» Евгений Вансевич, программист Почты Mail.Ru
My Null Android Penetration Session
Android Security & Penetration Testing
Ad

Similar to Certificate Pinning in Mobile Applications (20)

PDF
Cutting out the middleman: Man-in-the-middle attacks and prevention for mobil...
PPTX
SSL Pinning
PDF
Certificate Pinning: Not as Simple as It Sounds
PPTX
Certificate pinning in android applications
PPTX
iOS Security - Secure-iOS-Guidelines - Apple | iOS | Swift
PPTX
Hacking Mobile Apps
PDF
APIsecure 2023 - Enhancing API Security with Runtime Secrets & Attestation, T...
PDF
Denis Zhuchinski Ways of enhancing application security
PDF
SE2016 Android Denis Zhuchinski "Ways of enhancing application security"
PDF
Security Checklist: how iOS can help protecting your data.
PDF
Mfp80 certificate pinning
PPTX
Web application security part 02
PDF
LF_APIStrat17_OWASP’s Latest Category: API Underprotection
PDF
App Security and Securing App
PPTX
"Mobile security: iOS", Yaroslav Vorontsov, DataArt
PPTX
ncsmodule module department of electronics
PPTX
Hacking mobile apps
PDF
Avoiding damage, shame and regrets data protection for mobile client-server a...
PDF
Microsoft Bluehat 2017: Mobile SSL Interception
PPTX
New FIDO Specifications Overview -FIDO Alliance -Tokyo Seminar -Nadalin
Cutting out the middleman: Man-in-the-middle attacks and prevention for mobil...
SSL Pinning
Certificate Pinning: Not as Simple as It Sounds
Certificate pinning in android applications
iOS Security - Secure-iOS-Guidelines - Apple | iOS | Swift
Hacking Mobile Apps
APIsecure 2023 - Enhancing API Security with Runtime Secrets & Attestation, T...
Denis Zhuchinski Ways of enhancing application security
SE2016 Android Denis Zhuchinski "Ways of enhancing application security"
Security Checklist: how iOS can help protecting your data.
Mfp80 certificate pinning
Web application security part 02
LF_APIStrat17_OWASP’s Latest Category: API Underprotection
App Security and Securing App
"Mobile security: iOS", Yaroslav Vorontsov, DataArt
ncsmodule module department of electronics
Hacking mobile apps
Avoiding damage, shame and regrets data protection for mobile client-server a...
Microsoft Bluehat 2017: Mobile SSL Interception
New FIDO Specifications Overview -FIDO Alliance -Tokyo Seminar -Nadalin

More from Luca Bongiorni (6)

PDF
HandPwning Security pitfalls of biometric hand-geometry recognition access co...
PDF
ANP catalog: the adversarial ninja playset
PDF
Manufacturing Hardware Implants from Idea to Mass Production: A Hacker's Journey
PDF
How to bring HID attacks to next level with WHID Injector & P4wnP1
PDF
Mobile Network Security: Quanto sono sicure le reti cellulari? - Smau Milano ...
PPT
OpenBTS: Emergency GSM Messaging & Monitoring System for Civil Protection
HandPwning Security pitfalls of biometric hand-geometry recognition access co...
ANP catalog: the adversarial ninja playset
Manufacturing Hardware Implants from Idea to Mass Production: A Hacker's Journey
How to bring HID attacks to next level with WHID Injector & P4wnP1
Mobile Network Security: Quanto sono sicure le reti cellulari? - Smau Milano ...
OpenBTS: Emergency GSM Messaging & Monitoring System for Civil Protection

Recently uploaded (20)

PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PPTX
The various Industrial Revolutions .pptx
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PPTX
Tartificialntelligence_presentation.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
Hybrid model detection and classification of lung cancer
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PPT
What is a Computer? Input Devices /output devices
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
Chapter 5: Probability Theory and Statistics
PDF
Unlock new opportunities with location data.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Hindi spoken digit analysis for native and non-native speakers
Taming the Chaos: How to Turn Unstructured Data into Decisions
The various Industrial Revolutions .pptx
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Tartificialntelligence_presentation.pptx
Assigned Numbers - 2025 - Bluetooth® Document
WOOl fibre morphology and structure.pdf for textiles
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Hybrid model detection and classification of lung cancer
sustainability-14-14877-v2.pddhzftheheeeee
A contest of sentiment analysis: k-nearest neighbor versus neural network
What is a Computer? Input Devices /output devices
Developing a website for English-speaking practice to English as a foreign la...
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Chapter 5: Probability Theory and Statistics
Unlock new opportunities with location data.pdf
DP Operators-handbook-extract for the Mautical Institute

Certificate Pinning in Mobile Applications

  • 1. OWASP Lithuania - Luca Bongiorni – 05/03/2015
  • 2.  Introduction to Pinning  Why is good to have it...  State of Art – Android / iOS / Win  Conclusion – Pros & Cons 2
  • 3. 3  Mobile applications frequently do not protect network traffic.  They may use SSL/TLS during authentication but not elsewhere. This inconsistency leads to the risk of exposing data and session IDs to interception. Business Impact  Loss of Confidentiality and Integrity  Company’s reputation at risk  Incident response costs $$$  Possible legal issues (e.g. violation of ISO/PCI requirements) Mitigation  Use End-to-End encryption between browser and web server (HTTPS) ► SSL/TLS ► Certificate Pinning !
  • 4. 4 Pinning is the process of associating a host with their expected *{X509 certificate || public key}. Once a certificate or public key is known or seen for a host, the certificate or public key is associated or 'pinned' to the host. <…> • The pre-existing relationship between the user and an organization helps make better security related decisions. • No longer needs to depend on others (e.g. CAs) when making security decisions relating to a peer's identity!
  • 5. 5  The certificate is easiest to pin. When the certificate expires, you would update your application.  Public key pinning is more flexible but a little trickier due to the extra steps necessary to extract the public key from a certificate. o As with a certificate, the program checks the extracted public key with its embedded copy of the public key. o It is harder to work with keys (Vs. certificates) since you usually must extract the key from the certificate. Extraction is a minor inconvenience in Java, buts its uncomfortable in Cocoa and OpenSSL. o The key is static and may violate key rotation policies.
  • 6.  Introduction to Pinning  Why is good to have it...  State of Art – Android / iOS / Win  Conclusion – Pros & Cons 6
  • 7. 7 “An IMSI-Catcher (International Mobile Subscriber Identity) is a telephony eavesdropping device used for intercepting mobile phone traffic and tracking movement of subscribers. Essentially a "fake" mobile tower acting between the target mobile phone and the MNO's real BTSes, it is considered a Man-In-The-Middle (MITM) attack.” Fake WiFi AP + jam real AP? ARP Poisoning?… Old known boring threats.
  • 8. 8
  • 9. 9
  • 10.  Introduction to Pinning  Why is good to have it...  State of Art – Android / iOS / Win  Conclusion – Pros & Cons 10
  • 11. 11 Pinning is accomplished through a custom X509TrustManager API. Google Chrome PubKey pinning style. Customized version of TrustManager from Moxie Marlinspike available at: https://github.com/moxie0/AndroidPinning public PinningTrustManager(SystemKeyStore keyStore, String[] pins, long enforceUntilTimestampMillis) { this.systemTrustManagers = initializeSystemTrustManagers(keyStore); this.systemKeyStore = keyStore; this.enforceUntilTimestampMillis = enforceUntilTimestampMillis; for (String pin : pins) { this.pins.add(hexStringToByteArray(pin)); } } Constructs a PinningTrustManager with a set of valid pins. @param keyStore A SystemKeyStore that validation will be based on. @param pins An array of encoded pins to match a seen certificate chain against. A pin is a hex- encoded hash of a X.509 certificate's SubjectPublicKeyInfo. A pin can be generated using the provided ./tools/pin.py certificate_file.pem @param enforceUntilTimestampMillis A timestamp (in milliseconds) when pins will stop being enforced. Normal non-pinned certificate validation will continue. Set this to some period after your build date, or to 0 to enforce pins forever.
  • 12. 12 The method used to Ping Certificates is :connection:willSendRequestForAuthenticationChallenge: inside the NSURLConnectionDelegate protocol. This method gets called when an SSL connection is made, giving the developer, a chance to inspect the authentication challenge and either proceed or fail. The code below shows how you can check the certificate sent by the server, with a known certificate embedded in your applications.
  • 13. After doing await and socket.UpgradeToSslAsync(), check socket.Information.ServerCertificate for the cert that was provided by the server. You can verify that it's the cert you were expecting before you send any data. 13 The majority of Windows Phone 8 applications on the Marketplace lack certificate pinning due to the difficulty of implementing this security measure on the platform. Possible solutions: • For Win 8.0: Use an open source third party library for SSL such as OpenSSL or Bouncy Castle crypto Libs and attempt to build for Windows Phone. Cons: It may require significant effort to implement correctly. • For Win 8.0: Use a commercial library supporting SSL pinning: SecureBlackBox (https://www.eldos.com/sbb/). Cons: $$$ • >= Win 8.1: Thanks to the use of StreamSocket we can read the contents of the certificate via StreamSocket.Information.ServerCertificate property. StreamSocket s = new StreamSocket(); await s.ConnectAsync(new HostName(SrvURL), "443"); s.UpgradeToSslAsync(SocketProtectionLevel.Ssl, new HostName(SrvURL)); var certificate = s.Information.ServerCertificate;
  • 14.  Introduction to Pinning  Why is good to have it...  State of Art – Android / iOS / Win  Conclusion – Pros & Cons 14
  • 15. PROS 15  Better Security: Drastically reduce the ability to conduct successful MITM attacks.  Not Hard to Implement: Not as difficult as it seems to implement a basic certificate pinning.  Cost Saving: By using a self-signed certificate is possible reduce the costs, instead of paying for a certificate. • Possible problems in case of Certificate or PubKey revocation. • Egress filtering in a corporate environment (i.e. Interception Proxy) • The certificate embedded in your app will eventually expire. Your have to either plan for an app update that contains an updated certificate, or code a way for the application to download the new certificate, which is hardly achievable in practice. CONS
  • 16. 16 • https://www.owasp.org/index.php/Mobile_Top_10_2014-M3 • https://www.owasp.org/index.php/Certificate_and_Public_Key_Pinning • https://tools.ietf.org/html/draft-ietf-websec-key-pinning-21 • https://www.owasp.org/index.php/Pinning_Cheat_Sheet • http://www.thoughtcrime.org/blog/authenticity-is-broken-in-ssl-but-your-app-ha/ • http://developer.android.com/reference/android/net/http/X509TrustManagerExte nsions.html • https://www.isecpartners.com/blog/2013/february/ssl-pinning-on-ios.aspx • www.doubleencore.com/2013/03/ssl-pinning-for-increased-app-security/ • http://blog.soat.fr/2014/11/wp8-problematique-du-certificate-pinning/ • http://www.slideshare.net/iazza/dcm-final-23052013fullycensored • http://chargen.matasano.com/chargen/2015/1/6/bypassing-openssl-certificate- pinning-in-ios-apps.html
  • 17. 17