inspection of windows phone applications...- proximity communication using nfc app-to-app, wp8 13 ....

48
Inspection of Windows Phone applications Dmitriy Evdokimov Andrey Chasovskikh

Upload: others

Post on 28-May-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

Inspection of Windows Phone applications

Dmitriy Evdokimov Andrey Chasovskikh

Page 2: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

About us

Dmitriy ‘D1g1’ Evdokimov

- Security researcher at ERPScan

- Editor of Russian hacking magazine

- DEFCON Russia (DCG #7812) organizer

Andrey Chasovskikh

- Software developer

- Windows Phone addict

2

Page 3: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

Agenda

- Windows Phone intro

- Security model

- All about applications

- Not all applications are secure

- Tools overview

- Deep dive: finding vulnerabilities

- Conclusion

3

Page 4: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

WINDOWS PHONE INTRO

Page 5: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- The successor to the Windows Mobile OS

- 15 Mar 2010 – Windows Phone 7 series announced

- 21 Oct 2010 – Windows Phone 7 released

- 29 Oct 2012 – Windows Phone 8 released

History of Windows Phone

time

version

WP7 WP7 NoDo

WP7.5 Mango WP7.5 Tango

WP8

27 Sep 2011 29 Oct 2012 21 Oct 2011

5

Page 6: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

Market share

Source: Gartner, November 2012

6

Page 7: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- 125 000+ applications

- Casual apps, social networks, mobile banking, enterprise applications etc.

Windows Phone Store

7

Page 8: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

SECURITY MODEL

Page 9: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- Trusted Computing Base (TCB) Kernel, kernel-mode drivers

- Elevated Rights Chamber (ERC) Services, user-mode drivers

- Standard Rights Chamber (SRC) Pre-installed applications

- Least Privileged Chamber (LPC) Applications from WP store

Chamber concept, WP7

9

Page 10: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- Trusted Computing Base (TCB) Kernel, kernel-mode drivers

- Least Privileged Chamber (LPC) All other software: services, pre-installed apps,

application from WP store

Chamber concept, WP8

10

Page 11: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

Capabilities

Windows Phone 7

- Camera

- Contacts

- Location services

- Owner/phone identity

- Network services

Etc.

Undocumented

- Native code

- SMS API

- Access to user properties

- SIM API

Etc.

WMAppManifest.xml

Windows Phone 8

- All WP7 capabilities

- NFC

- SD card access

- Wallet

- Speech recognition

- Front camera

Etc.

11

Page 12: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

Sandboxing concept

App1

Isolated chamber

App2

Isolated chamber

Isolated storage for App1

Isolated storage for App2

- No app communication in WP7 - Limited app-to-app in WP8 - File system structure is hidden - Isolated storages

12

Page 13: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- File associations - LaunchFileAsync()

- Reserved: xap, msi, bat, cmd, py, jar etc

- URI associations - LaunchUriAsync()

- Reserved: http, tel, wallet, LDAP, rlogin, telnet etc

- Proximity communication using NFC

App-to-App, WP8

13

Page 14: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

Isolated Storage

Isolated Storage

Isolated Settings Storage

Files

Database

Isolated File Storage

Directory

Physical File Storage

14

Page 15: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- Store applications are signed in WP7

- All binaries get signed since WP8

- Application file get signed - Kind of checksum file is put into applications

- Applications XAP files have undocumented format (since Aug 2012)

Signing

15

Page 16: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

ALL ABOUT APPLICATIONS

Page 17: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

.NET and CLR, WP7

Applications

Developer Platform (XAML, XNA, Device services)

.NET Compact Framework (BCL + Silverlight flavor)

WP7 OS, WinCE based

17

Page 18: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

???

Framework

18

Page 19: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

.NET and CLR, WP8

Applications

Developer Platform (XAML, XNA, Device services)

.NET Framework (CoreCLR)

WP8 OS, Win8 based

19

Page 20: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

Framework

20

Page 21: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- Application assemblies

- Resources

- AppManifest.xaml

- WMAppManifest.xml

- WMInteropManifest.xml*

Application file structure

* — optional for WP7, absent in WP8

21

Page 22: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

Submission and certification

App Creation App Submission XAP File

Validation

Adding Metadata

Certification Testing

Signing Publication in Marketplace

Source code

.xap

22

Page 23: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

WP7:

\Applications

\Install\<ProductID>\Install\ - Content from XAP

- WMAppPRHeader.xml (package signature)

\Data\<ProductID>\Data\IsolatedStorage

Same idea in WP8, i.e. install path:

C:\Data\Programs\<ProductID>\Install\

Applications on a device

23

Page 24: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

NOT ALL APPLICATIONS ARE SECURE

Page 25: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

Security assessment

Server

Device/Emulator

Data channel

App

25

App

Page 26: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

Prepare environment - Get app (unpack/decrypt) - Configuration device/emulator

Static analysis - Properties of program compilation - Metadata analysis - Code analysis

Dynamic analysis - How application works with file system/network - Runtime code analysis

Mobile applications security assessment

26

Page 27: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

1. Insecure Data Storage 2. Weak Server Side Controls 3. Insufficient Transport Layer Protection 4. Client Side Injection 5. Poor Authorization and Authentication 6. Improper Session Handling 7. Security Decisions Via Untrusted Inputs 8. Side Channel Data Leakage 9. Broken Cryptography 10. Sensitive Information Disclosure

OWASP Top 10 Mobile Risks

27

Page 28: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

WP vs. Android vs. iOS vulnerabilities

WP7 (C#/VB) WP8 (C#/VB/C/C++)

iOS (Objective-C)

Android (Java)

Note: Main programming languages in brackets

Platform independent vulnerabilities

Platform specific vulnerabilities

28

Page 29: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

TOOLS OVERVIEW

Page 30: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- Device

- Full unlock

- Emulator

- Windows Phone Device Manager

- Network proxy: Burp Suite, Charles etc.

- .NET tools: .Net Reflector, ILSpy etc.

- IDA Pro

- RAIN, Boyan Balkanski

- Windows Phone App Analyzer, David Rook

- XAPSpy, Behrang Fouladi

- XapSpyAnalysis, David Rook

Arsenal

30

Page 31: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

Static analysis is insufficient.

Lack of dynamic analysis tools:

• IDE allows debugging with source code only

• No programmable debugging interface

• Managed code

Main issue

31

Solution: static byte code instrumentation.

Page 32: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

Tangerine

32

Page 33: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- Unpacking

- Removing application signature

- Resigning assemblies

- Packing

- Deploying

Automates routine with XAP files

33

Page 34: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- Application info

- Application capabilities

- Code analysis

- Code structure analysis

- API usage analysis

- View IL code

Static analysis

34

Page 35: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- Log application stack trace

- Method names

- Method parameters

- Return values

- Run custom code

- On method enter

- Replace method

- On method exit

- Change parameters values

Dynamic analysis

35

Page 36: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

DEEP DIVE: FINDING VULNERABILITIES

Page 37: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

DEMO

Page 38: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

How it works

Target application

Instrumented application

Emulator

Emulator console Tangerine log

Instrumented application

Add hooks (1)

Resign and deploy

Hooked output (2)

Log data (2)

Repeat

(1) Changing CIL code

(2) Emulator console (writing/reading)

38

Page 39: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

CIL Instrumentation

39

Page 40: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- Emulator only - Does not help to overcome obfuscated code - Does not work with system assemblies - Applications from store need to be decrypted - Windows Phone 7 only

Limitations

40

Page 41: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

Cloud Compilation, WP8

CIL Assembly

C# Source Code

MDIL Assembly C# Compiler

MDIL Compiler

Cloud

MDIL Assembly

Native Image Generator

Native DLL

Device

Download

Run

41

Page 42: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

MDIL in work

42

R0 = this R1 = a R0 + 0x10 = j, where j is a field from base class

Page 43: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

MDILDump

43

http://github.com/WalkingCat/mdildump/

Page 44: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- Support Windows Phone 8 applications

- MDIL instrumentation

- Windows Phone RT

- Add new features

- Code graphical representation

- Data flow analysis

- Fix bugs ;)

Future work

44

Page 45: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

CONCLUSION

Page 46: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- Greater attack surface in WP8

- App-to-App

- Applications that use native code

- New technologies

- Logical bugs never die

Conclusion

46

Page 47: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

- Evgeny Bechkalo

- DSecRG team

Thanks

47

Page 48: Inspection of Windows Phone applications...- Proximity communication using NFC App-to-App, WP8 13 . Isolated Storage Isolated Storage Isolated Settings Storage Files Database Isolated

Q&A

Dmitry Evdokimov [email protected] @evdokimovds Andrey Chasovskikh http://andreycha.info @andreycha Tangerine: http://github.com/andreycha/tangerine