PSCG
Ron Munitz
Founder & CEO - The PSCG
ron@thepscg.com
CodeMotion
Tel-Aviv
17 December 2015
@ronubo
The slides are available online at:
thepscg.com/talks/
Burning
Marshmallows
This work is licensed under the Creative Commons
Attribution-ShareAlike 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-
sa/4.0/
© Copyright Ron Munitz 2015
PSCG
about://Ron Munitz
â—Ź Founder and CEO of the PSCG
â—‹ The Premium Embedded/Android consulting and Training firm
â—Ź Android*, Linux*, Security* Trainer and Instructor
â—‹ The PSCG, NewCircle and the Linux Foundation
â—‹ For Q1 2016 training, Contact training@thepscg.com
â—Ź NIche Conference Organizer
â—‹ MobSecCon, MobModCon, Voxxed Days Tel-Aviv
â—‹ CFP is open. Follow me on Twitter and Google+ for announcements
( @ronubo , +RonMunitz )
● Working hard on the next huge thing…
Looking for co-founders!!!
â—‹ Full Stack developer
○ Offensive Security experts (Mobile - huge advantage. Otherwise… Be
smart and serious and I’ll teach you what you need to know)
PSCG
Agenda
â—Ź Android Security features timeline
â—Ź PR stunts and Software Security faceoff
â—Ź Android Security Patching and Nexus Security Bulletin
â—Ź Introducing: Android 6.0 - Marshmallow
â—Ź Burning Marshmallows - Future PR stunts
Android Security Timeline
PSCG
Days of future past
Android Security Architecture
â—Ź Key Features
â—‹ Robust security at the OS level through the Linux
kernel
â—‹ Mandatory application sandbox for all applications
â—‹ Secure interprocess communication
â—‹ Application signing
â—‹ Application-defined and user-granted permissions
â—‹ SE Linux
○ Multi-User support, “work profiles”, “guest profiles”,...
â—‹ FUSE for sdcard (permissions, encryption)
â—‹ Trusted Execution Environment and HW support
PSCG
Android Security features timeline
â—Ź Permission System / Signature Systems
â—Ź JCE (BouncyCastle), OpenSSL
● Partial ASLR (“stagefright” → ICS!)
â—Ź Hardware Backed KeyStore
â—Ź Full ASLR (and later heap randomization and full PIE)
â—Ź SE Linux (first Permissive, then Enforcing)
â—Ź OTA Update System (e.g. Chromium)
â—Ź Full disk encryption, dm-crypt
â—Ź Trusted Boot support, dm-verity
â—Ź SE Linux - Full domain enforcement (important addition)
â—Ź Partial Permission Module (Burden on the developer...)
â—Ź Fingerprinting API,
â—Ź Keystore redesign
â—Ź ...
Popular “Victims”
PSCG
A pre Marshmallow candy barbeque
(or is it?)
Popular Attack Surfaces
â—Ź The AOSP builds on countless lines of code
â—‹ Developed by Google and Partners
■ AOSP → OEM → Carrier chain of (mis)trust
○ “Borrowed”/Ported
â—Ź init services
â—‹ If defined critical may lead to device reboot
â—‹ If restarts other services - may lead to DoS
â—Ź Android services
â—‹ Usually one service (server) serves multiple
components (clients) ⇒ DoS
â—Ź Separate code injection and privilege
escalation from DoS!
Don’t (blindly) believe the news
â—Ź StageFright sequences (by several vendors)
○ Fact: “Everyone” is fuzzing stagefright.
■ @see “Fuzzing the media framework in android”
by the Intel OTC, at ELC 2015
○ The mediaserver runs stagefright as the “media
backend”
○ If “everyone” fuzzes ⇒ at least someone succeeds
â—Ź Skia sequences
â—Ź gralloc sequences
â—Ź Kernel sequences...
Don’t (blindly) believe the news
â—Ź Fact: One of the Stagefright exploits was
severe because it could be triggered
remotely.
â—‹ This is a huge deal.
â—‹ If only...
â—Ź Fact: ASLR, PIE, DEP, SELinux,...
â—Ź Home exercise/Group bet:
â—‹ Assuming an MMS costs $0.01. How many USD
would you spend on arbitrary remote code
execution?
â—‹ Volunteers?
■ Regardless: Potential remote code execution ⇒ Critical severity
Don’t (blindly) believe the news
â—Ź Fact: One of the stagefright exploits resulted
in DoS attacks on the media server due to
heap overflow.
â—Ź This can lead to annoying behavior, and
more.
â—Ź Fact: mediaserver is not a privileged user.
Software components have bugs. It’s a part
of life.
â—Ź Opinion: If someone manages to exploit
those vulnerabilities, they probably deserve
a prize...
Yet, don’t avoid somewhat silent news
â—Ź A good attack is a low profile attack.
â—Ź An excellent attack is a zero-day attack
â—Ź Disclosure does not always help, and the
Android Ecosystem is not a great helper
○ AOSP → OEM → Carrier → (?) → User
â—Ź And when someone in the chain decides to
do something stupid within the chain -
someone else will take advantage
○ @see the “yearly” signature verification attacks
○ In fact, let’s have a quick look at a recent one
Silent but lethal news as per Sep 15
A great example which has not been published without
proportions and been recently patched at most, but not all
implementations is the Certifi-gate attack against RST
(Remote Support Tools):
Silent but lethal news as per Sep 15
â—Ź It turns out that RST such as TeamViewer, RSupport
and more, which were bundled in some popular device
ROMs from leading companies (LG, Samsung, Huawei
and more), had privileged access to elements such as
â—‹ Screen Recording (Surface Flinger/Framebuffer)
â—‹ Event Injection
â—‹ Package Installation
Silent but lethal news as per Sep 15
● It also turns out that these RST’s enabled “trusted”
applications to take advantage of these permissions, by
using them as a (confused?) deputy, while the
applications would be an “extension”.
â—Ź What is trust?
â—‹ Apparently, comparing an X509 certificate serial
number to a hard-coded value, comparing a
certificate “HashCode” to a hardcoded value etc…
● Given that, one could just build a “trusted” “extension” to
the RST, that would have full device control, without
ever asking for any permission.
â—Ź Great.
Getting the latest news
â—Ź In the last year, the Android team has started
a monthly security pathcing cycle
○ @see About→ Phone→ Security Patch Level
â—Ź Most insights/changelogs/CVE) can be seen
in https://source.android.com/security/bulletin/index.html
â—Ź The patch levels are (obviously) applied only
to the Nexus phones at the released dates.
○ The rest is up to the OEM’s good will
â—Ź Classified into 4 severity levels:
â—‹ Critical, High, Moderate, Low
Understanding Android Security Bulletin
ratings
The severity of a bug generally reflects the potential harm that could occur if a bug was
successfully exploited. Use the following criteria to determine the severity:
Critical
â—Ź Remote privileged code execution (execution at a privilege level that third-party apps cannot obtain)
â—Ź Local permanent device compromise (device cannot be repaired without re-flashing the entire operating
system, such as a verified boot or Trusted Execution Environment/TEE compromise)
â—Ź Remote permanent denial of service (inoperability, either completely permanent or requiring re-flashing the
device)
High
â—Ź Remote unprivileged code execution (execution at a privilege level that third-party apps can obtain through
installation)
â—Ź Local access to system/signature-level permission data or capabilities without permission
â—Ź Local permanent denial-of-service (inoperability, either completely permanent or requiring re-flashing the
device)
â—Ź Remote temporary denial-of-service (remote hang or reboot)
Moderate
â—Ź Access to "dangerous" level permission data or capabilities without permission with an app installed on the
device
â—Ź Local temporary denial-of-service (can be resolved only through a factory reset)
Low
â—Ź Access to "normal" level permission capabilities without permission with an app installed on the device
â—Ź Local temporary denial-of-service (can be resolved by booting the device into Safe Mode and removing the
problem application)
Marshmallow Additions
PSCG
Marshmallow Additions
â—Ź FingerPrinting API
○ Biometric ID’s anyone?
â—‹ Trusted Execution Environment implementation
â–  @see attacks on ARM TrustZone..
â—‹ What if the device has no TEE?
■ Prone to forensics…
â—Ź Dynamic Permission API
â—‹ Basically a good thing. Finally catches up with iOS
dynamic permission model
â—‹ Drawback: Will break applications. Not because it is
a bad things. But because of application developers
â—‹ Mitigation: SDL, Captain Hindsight
Marshmallow Additions
â—Ź Keystore API redesign
â—Ź Keystore HAL redesign/additions
â—‹ keymaster v. 1.0 - First signs of maturity?
â—Ź Symmetric key cryptography support at (HW
backed) keystores
â—‹ This has been out for a while.
â—‹ But on a platform hidden API (@hide)
â—‹ Now available for all!
â—Ź Enable timed authentication
â—‹ Introducing the gatekeeper HAL
Marshmallow Additions
â—Ź APK Validation changes
â—‹ Following various notorious APK signing bugs (Master
Key etc.).
â—‹ If a file is declared in the manifest but not present in
the APK itself ⇒ APK is considered corrupt
â—Ź Android for Work
â—‹ Behavior is still evolving (for better? worse?)
â—‹ Examples: Automatic System updates
â—‹ Runtime Permission policy for all applications
â—‹ Data usage tracking.
â—‹ Most changes are Android. Not Google Play services.
â—Ź External Storage Encryption, App Linking,
Dynamic Permission API
Target API < 23 Target API >= 23
Device API < 23 No change (shocking, isn’t it?) Use Build.VERSION.SDK_INT switch.
Device API >= 23 No change on installation (all
permissions granted)
Permission can be revoked -
may break apps. The device
will warn the user about it.
Full dynamic permission model.
Make sure you check for SDK_INT ,
and always checkSelfPermission() ,
[shouldShowPermissionRationale()],
and requestPermission() when
relevant.
Then, handle the user’s choice on
onRequestPermissionResults()
Dynamic Permission API
â—Ź Long story short:
Target API Level 23 ⇒ Application
developer needs to be aware of dynamic
permissions
● Device Level 23 ⇒ End User needs to be
aware of the consequences of disabling
permissions for older SDK level apps.
● It’s quite obvious researchers will
celebrate this significant behavior
change...
Ahead Of Time Compiling (ART)
â—Ź Marshmallow provides ART as the default
(and only unless specifically configured) run
time.
● It seems that the OAT files are still “Lollipop
compliant” ⇒ Trivially reversible due to:
â—Ź A full mapping from Native code to DEX bytecode
â—Ź A full mapping from both to Java functions.
â—Ź So you can apply the same techniques for .dex
file decompiling.
â—Ź @see my upcoming Android Reverse Engineering
Lab
Speculations
● The most dominant attacks we’ll hear of will
be in the categories of:
â—‹ Certificate validation, self Certificate Chain validation
â—‹ Everything under the AOSP /external/
â–  Home exercise: Can you play with toybox?
â—‹ Everything media, graphics, binder, native related
â—‹ Application breaking
â—‹ Fingerprint stealing (if and when)
○ Bad SE Linux policies (unlikely for the “serious”
vendors, but hey, Android fragmentation…)
○ Timing attacks against the new Keystore API’s
â—Ź Or maybe we will hear of nothing. But
attackers/researchers will definitely try.
Follow up:
â—Ź Android Security workshop
â—‹ Public class in Tel-Aviv - January 24-28, 2015.
â—‹ training@thepscg.com
â—‹ Discount Code: CodeMotionTLV1711
â—Ź On-Site/Public classes anywhere??
â—‹ Contact me - training@thepscg.com
â—Ź MobSecCon and MobModCon
â—‹ http://thepscg.com/events/mobmodcon
â—‹ http://thepscg.com/events/mobseccon
â—‹ CFP is now open!
Thank You
PSCG
Consulting/Training requests:
ron@thepscg.com

CodeMotion tel aviv 2015 - burning marshmallows

  • 1.
    PSCG Ron Munitz Founder &CEO - The PSCG ron@thepscg.com CodeMotion Tel-Aviv 17 December 2015 @ronubo The slides are available online at: thepscg.com/talks/ Burning Marshmallows
  • 2.
    This work islicensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by- sa/4.0/ © Copyright Ron Munitz 2015 PSCG
  • 3.
    about://Ron Munitz ● Founderand CEO of the PSCG ○ The Premium Embedded/Android consulting and Training firm ● Android*, Linux*, Security* Trainer and Instructor ○ The PSCG, NewCircle and the Linux Foundation ○ For Q1 2016 training, Contact training@thepscg.com ● NIche Conference Organizer ○ MobSecCon, MobModCon, Voxxed Days Tel-Aviv ○ CFP is open. Follow me on Twitter and Google+ for announcements ( @ronubo , +RonMunitz ) ● Working hard on the next huge thing… Looking for co-founders!!! ○ Full Stack developer ○ Offensive Security experts (Mobile - huge advantage. Otherwise… Be smart and serious and I’ll teach you what you need to know) PSCG
  • 4.
    Agenda â—Ź Android Securityfeatures timeline â—Ź PR stunts and Software Security faceoff â—Ź Android Security Patching and Nexus Security Bulletin â—Ź Introducing: Android 6.0 - Marshmallow â—Ź Burning Marshmallows - Future PR stunts
  • 5.
  • 6.
    Android Security Architecture ●Key Features ○ Robust security at the OS level through the Linux kernel ○ Mandatory application sandbox for all applications ○ Secure interprocess communication ○ Application signing ○ Application-defined and user-granted permissions ○ SE Linux ○ Multi-User support, “work profiles”, “guest profiles”,... ○ FUSE for sdcard (permissions, encryption) ○ Trusted Execution Environment and HW support PSCG
  • 7.
    Android Security featurestimeline ● Permission System / Signature Systems ● JCE (BouncyCastle), OpenSSL ● Partial ASLR (“stagefright” → ICS!) ● Hardware Backed KeyStore ● Full ASLR (and later heap randomization and full PIE) ● SE Linux (first Permissive, then Enforcing) ● OTA Update System (e.g. Chromium) ● Full disk encryption, dm-crypt ● Trusted Boot support, dm-verity ● SE Linux - Full domain enforcement (important addition) ● Partial Permission Module (Burden on the developer...) ● Fingerprinting API, ● Keystore redesign ● ...
  • 8.
    Popular “Victims” PSCG A preMarshmallow candy barbeque (or is it?)
  • 9.
    Popular Attack Surfaces ●The AOSP builds on countless lines of code ○ Developed by Google and Partners ■ AOSP → OEM → Carrier chain of (mis)trust ○ “Borrowed”/Ported ● init services ○ If defined critical may lead to device reboot ○ If restarts other services - may lead to DoS ● Android services ○ Usually one service (server) serves multiple components (clients) ⇒ DoS ● Separate code injection and privilege escalation from DoS!
  • 10.
    Don’t (blindly) believethe news ● StageFright sequences (by several vendors) ○ Fact: “Everyone” is fuzzing stagefright. ■ @see “Fuzzing the media framework in android” by the Intel OTC, at ELC 2015 ○ The mediaserver runs stagefright as the “media backend” ○ If “everyone” fuzzes ⇒ at least someone succeeds ● Skia sequences ● gralloc sequences ● Kernel sequences...
  • 11.
    Don’t (blindly) believethe news ● Fact: One of the Stagefright exploits was severe because it could be triggered remotely. ○ This is a huge deal. ○ If only... ● Fact: ASLR, PIE, DEP, SELinux,... ● Home exercise/Group bet: ○ Assuming an MMS costs $0.01. How many USD would you spend on arbitrary remote code execution? ○ Volunteers? ■ Regardless: Potential remote code execution ⇒ Critical severity
  • 12.
    Don’t (blindly) believethe news ● Fact: One of the stagefright exploits resulted in DoS attacks on the media server due to heap overflow. ● This can lead to annoying behavior, and more. ● Fact: mediaserver is not a privileged user. Software components have bugs. It’s a part of life. ● Opinion: If someone manages to exploit those vulnerabilities, they probably deserve a prize...
  • 13.
    Yet, don’t avoidsomewhat silent news ● A good attack is a low profile attack. ● An excellent attack is a zero-day attack ● Disclosure does not always help, and the Android Ecosystem is not a great helper ○ AOSP → OEM → Carrier → (?) → User ● And when someone in the chain decides to do something stupid within the chain - someone else will take advantage ○ @see the “yearly” signature verification attacks ○ In fact, let’s have a quick look at a recent one
  • 14.
    Silent but lethalnews as per Sep 15 A great example which has not been published without proportions and been recently patched at most, but not all implementations is the Certifi-gate attack against RST (Remote Support Tools):
  • 15.
    Silent but lethalnews as per Sep 15 â—Ź It turns out that RST such as TeamViewer, RSupport and more, which were bundled in some popular device ROMs from leading companies (LG, Samsung, Huawei and more), had privileged access to elements such as â—‹ Screen Recording (Surface Flinger/Framebuffer) â—‹ Event Injection â—‹ Package Installation
  • 16.
    Silent but lethalnews as per Sep 15 ● It also turns out that these RST’s enabled “trusted” applications to take advantage of these permissions, by using them as a (confused?) deputy, while the applications would be an “extension”. ● What is trust? ○ Apparently, comparing an X509 certificate serial number to a hard-coded value, comparing a certificate “HashCode” to a hardcoded value etc… ● Given that, one could just build a “trusted” “extension” to the RST, that would have full device control, without ever asking for any permission. ● Great.
  • 17.
    Getting the latestnews ● In the last year, the Android team has started a monthly security pathcing cycle ○ @see About→ Phone→ Security Patch Level ● Most insights/changelogs/CVE) can be seen in https://source.android.com/security/bulletin/index.html ● The patch levels are (obviously) applied only to the Nexus phones at the released dates. ○ The rest is up to the OEM’s good will ● Classified into 4 severity levels: ○ Critical, High, Moderate, Low
  • 18.
    Understanding Android SecurityBulletin ratings The severity of a bug generally reflects the potential harm that could occur if a bug was successfully exploited. Use the following criteria to determine the severity: Critical â—Ź Remote privileged code execution (execution at a privilege level that third-party apps cannot obtain) â—Ź Local permanent device compromise (device cannot be repaired without re-flashing the entire operating system, such as a verified boot or Trusted Execution Environment/TEE compromise) â—Ź Remote permanent denial of service (inoperability, either completely permanent or requiring re-flashing the device) High â—Ź Remote unprivileged code execution (execution at a privilege level that third-party apps can obtain through installation) â—Ź Local access to system/signature-level permission data or capabilities without permission â—Ź Local permanent denial-of-service (inoperability, either completely permanent or requiring re-flashing the device) â—Ź Remote temporary denial-of-service (remote hang or reboot) Moderate â—Ź Access to "dangerous" level permission data or capabilities without permission with an app installed on the device â—Ź Local temporary denial-of-service (can be resolved only through a factory reset) Low â—Ź Access to "normal" level permission capabilities without permission with an app installed on the device â—Ź Local temporary denial-of-service (can be resolved by booting the device into Safe Mode and removing the problem application)
  • 19.
  • 20.
    Marshmallow Additions ● FingerPrintingAPI ○ Biometric ID’s anyone? ○ Trusted Execution Environment implementation ■ @see attacks on ARM TrustZone.. ○ What if the device has no TEE? ■ Prone to forensics… ● Dynamic Permission API ○ Basically a good thing. Finally catches up with iOS dynamic permission model ○ Drawback: Will break applications. Not because it is a bad things. But because of application developers ○ Mitigation: SDL, Captain Hindsight
  • 21.
    Marshmallow Additions â—Ź KeystoreAPI redesign â—Ź Keystore HAL redesign/additions â—‹ keymaster v. 1.0 - First signs of maturity? â—Ź Symmetric key cryptography support at (HW backed) keystores â—‹ This has been out for a while. â—‹ But on a platform hidden API (@hide) â—‹ Now available for all! â—Ź Enable timed authentication â—‹ Introducing the gatekeeper HAL
  • 22.
    Marshmallow Additions ● APKValidation changes ○ Following various notorious APK signing bugs (Master Key etc.). ○ If a file is declared in the manifest but not present in the APK itself ⇒ APK is considered corrupt ● Android for Work ○ Behavior is still evolving (for better? worse?) ○ Examples: Automatic System updates ○ Runtime Permission policy for all applications ○ Data usage tracking. ○ Most changes are Android. Not Google Play services. ● External Storage Encryption, App Linking,
  • 23.
    Dynamic Permission API TargetAPI < 23 Target API >= 23 Device API < 23 No change (shocking, isn’t it?) Use Build.VERSION.SDK_INT switch. Device API >= 23 No change on installation (all permissions granted) Permission can be revoked - may break apps. The device will warn the user about it. Full dynamic permission model. Make sure you check for SDK_INT , and always checkSelfPermission() , [shouldShowPermissionRationale()], and requestPermission() when relevant. Then, handle the user’s choice on onRequestPermissionResults()
  • 24.
    Dynamic Permission API ●Long story short: Target API Level 23 ⇒ Application developer needs to be aware of dynamic permissions ● Device Level 23 ⇒ End User needs to be aware of the consequences of disabling permissions for older SDK level apps. ● It’s quite obvious researchers will celebrate this significant behavior change...
  • 25.
    Ahead Of TimeCompiling (ART) ● Marshmallow provides ART as the default (and only unless specifically configured) run time. ● It seems that the OAT files are still “Lollipop compliant” ⇒ Trivially reversible due to: ● A full mapping from Native code to DEX bytecode ● A full mapping from both to Java functions. ● So you can apply the same techniques for .dex file decompiling. ● @see my upcoming Android Reverse Engineering Lab
  • 26.
    Speculations ● The mostdominant attacks we’ll hear of will be in the categories of: ○ Certificate validation, self Certificate Chain validation ○ Everything under the AOSP /external/ ■ Home exercise: Can you play with toybox? ○ Everything media, graphics, binder, native related ○ Application breaking ○ Fingerprint stealing (if and when) ○ Bad SE Linux policies (unlikely for the “serious” vendors, but hey, Android fragmentation…) ○ Timing attacks against the new Keystore API’s ● Or maybe we will hear of nothing. But attackers/researchers will definitely try.
  • 27.
    Follow up: â—Ź AndroidSecurity workshop â—‹ Public class in Tel-Aviv - January 24-28, 2015. â—‹ training@thepscg.com â—‹ Discount Code: CodeMotionTLV1711 â—Ź On-Site/Public classes anywhere?? â—‹ Contact me - training@thepscg.com â—Ź MobSecCon and MobModCon â—‹ http://thepscg.com/events/mobmodcon â—‹ http://thepscg.com/events/mobseccon â—‹ CFP is now open!
  • 28.