0

I'm writing an iOS app that will store some information. Though not too confidential, I'd like to prevent other apps from reading the data, since a malicious app can then "phone home". If the user has jailbroken their phone, that would be their decision, so too if they will give someone else the device so the other person can use the app and see the data. My question is only about preventing a malicious app from reading the data and sending it to its creators.

I'm planning on saving the data in the cache folder. Does that make a difference?

2

No. All third-party iOS applications must have a sandbox, and the sandbox prevents direct access to any other app's data. Two apps from the same publisher can create a shared location that both can access, but even then, any data stored in an app's own directories is never exposed to other apps. Apps can also push data to one another, but there is no way for one app to force another to send it data unless the developer of the sending app explicitly creates one.

From Apple's File System Overview doc:

For security purposes, an iOS app’s interactions with the file system are limited to the directories inside the app’s sandbox directory. During installation of a new app, the installer creates a number of container directories for the app inside the sandbox directory. Each container directory has a specific role. The bundle container directory holds the app’s bundle, whereas the data container directory holds data for both the app and the user. The data container directory is further divided into a number of subdirectories that the app can use to sort and organize its data. The app may also request access to additional container directories—for example, the iCloud container—at runtime.

The Library/Caches directory for an app has the same privileges as any other app-specific folder. Its main distinction is that its contents are considered to not need backing up or to be disastrous if lost, though they are less ephemeral than temp data (which may be purged automatically while the app is not running). As such, files in the Caches directory are not synced to iCloud. You can also use the "do not back up" attribute for a file in any directory that should not be synced.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.