22
iOS App Security Cheatsheet
In a previous article we saw an example on how an attacker could analyse an app in the search of vulnerabilities, and perform an XSS attack through the misuse of a web view. Hopefully after reading that, if you weren’t aware of how easy it is to at least get into some source code of an app published on the AppStore, now you are and you might be wondering if there are other ways to hack an iOS application and how to prevent it.
In this article I will try to make a compilation of stuff to check if you want to ensure your app handles most common security flaws. We will cover the following topics: system API’s, Data Handling, Data transportation and App Hardening.
applicationDidEnterBackground.
UIPasteboardNameFind
and UIPasteboardNameGeneral
.userDidTakeScreenshotNotification
and use UIScreen.isCaptured()
in order to blur or hide the content.NSPredicate(format: “(email LIKE ‘\(user.email)’) AND (password LIKE ‘\(user.password)’)”, nil)
you should better use NSPredicate(format: “(email = @) AND (password = @)”, user.email, user.password)
. If necessary input text validation measures can be taken in place before saving to the database or interacting with the server.NSData.WritingOptions
and URLFileProtection
.UserDefaults
to store any sensitive data, such as Access Tokens, subscription flags, or relevant account information. It can be easily accessed from outside the app. Use KeychainService API instead.ephemeralSessionConfiguration
which does not store cookies nor caches. Global cache can also be disabled, check URLCache, you can assign 0 capacity to it and assign it to URLCache.shared
.As you can see, there are a considerable amount of things to keep in mind when addressing the security of your application. And of course these are not all of them, but at least with this list you have a point to start checking your application and think which items are relevant for your application security profile. I hope this short read was useful for you and that you keep it handy for the next time you have to audit an application’s security.
22