Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSURLCache and Data Protection

I am trying to protect sensitive data stored in NSURLCache. My app's files and Core Data sqlite files are set to NSFileProtectionComplete. However, I am unable to change the NSURLCache files data protection level to anything other than NSFileProtectionCompleteUntilFirstUserAuthentication. This leaves any sensitive data in the cache exposed when the device is locked.

I need to have the responses cached so repeated requests return 304 responses to prevent data from being re-processed multiple times when not necessary to do so. Also, I need the cache to be protected at rest when the device is locked.

Does anyone have any suggestions for protecting NSURLCache data?

like image 506
PPierson Avatar asked Jan 13 '15 23:01

PPierson


People also ask

What is NSURLCache?

The NSURLCache class implements the caching of responses to URL load requests, by mapping NSURLRequest objects to NSCachedURLResponse objects. It provides a composite in-memory and on-disk cache, and lets you manipulate the sizes of both the in-memory and on-disk portions.

What is Nscache?

A mutable collection you use to temporarily store transient key-value pairs that are subject to eviction when resources are low.


1 Answers

The default NSURLCache does not support changing the protection level of its store. I've solved my issue by creating a custom NSURLCache subclass that stores URL responses in a custom SQLite database with file protection set to NSFileProtectionComplete. This seems to be the only solution next to disabling URL caching.

like image 177
PPierson Avatar answered Oct 01 '22 10:10

PPierson