How to make iOS App Secure from Jailbroken Device?
Thanks to the mobile era we have mobile apps for everything these days. Every business from a barbers shop to huge retailers has apps so that they can be closer to their customers. On one hand, we really leverage this convenience but on the other hand, there are risks of exposing a lot of confidential information while using these apps. And it becomes very vital when dealing with payments and other sensitive information. As a developer of these apps, it is our responsibility to put checks to make sure privacy and security are not compromised. Here is a comprehensive list of security best practices. But this article focuses on detecting if an iOS device is jailbroken.
JailBroken detections techniques basically fall under these categories
1. File Extension Checks
If a device is jailbroken, there are some files that exist in the system. One common file is Cydia. Let take a look at the code below how we would check for the existence of these files
2. URI Schemes
iOS App allows registering for different schemes that allow opening our app directly from a weblink. If a device is jailbroken we can check for the existence of cydia:// scheme. Below is code that checks for the existence for the URI scheme
3. Sandbox Check
JailBroken device alters the sandbox behavior of the app. Basically, the app can access or affect things outside of its sandbox. So we check by writing a file outside our sandbox and if we succeed then the device is jailbroken. This is how it will look in code.
4. Dynamic Linker Check
Dynamic Linking provides a way for executables to take advantage of code provided by other libraries without compiling and be able to ship that code in the executable file. This greatly helps executables to reuse code without including a copy of these different libraries. On the other hand, static linking will include all code the executable needs are shipped with it.
usually Anti jailbroken detection tools are loaded as dynamic libraries. iOS dynamic linker dyld loads all the dynamic libraries. So we can check the presence of anti-jailbreak-detection tools by looking at the names and numbers of libraries loaded into the current process. If an anti-jailbreak-detection tool is running, we know the device is jailbroken.
Conclusion
JailBroke device detection definitely adds a layer of security to your app. But by no way or means, the list above is enough to do that. End of the day, as a good developer we need to practice all the good security practices to secure our iOS app.