Over the past several days much ado has been made over a file located deep within iOS called consolidated.db. Judging from what I've heard and read in the news and on blogs it sounds like Apple is tracking iOS users like a dog and keeping a record of their every move.
I was skeptical about this conclusion from the first time I heard it. It seemed odd that people were using this to vilify Apple when they couldn't even demonstrate that Apple was collecting the information for their own commercial use. By admission of the security researchers who found this file the data was kept on the device and in backups but was never sent to 1 Infinite Loop. Some suggested that this was a 'programming mistake', but I couldn't believe that Apple would let this database needlessly take up space and cycles on their resource constrained mobile devices. There had to be a good reason for this database's existence.
I decided to download the application provided by the researchers and run it on my device. I had to decrypt my backup to get it to work but eventually I got the maps with dots showing where I had been recently. I was surprised at how unspecific the data was. In fact, the dots formed a near perfect grid completely covering the town in which I live. It was immediately clear to me that this database was not logging my location but the location of the cell tower to which my device was connecting.
At this point I was annoyed that the media had made such a big deal about this. This data did not reveal anything more than what towns I had spent time in. I can't think what sort of damning conclusions this data could help anyone come to about my travels or anyone else's. Yet the question still remained, what is the purpose of this database?
I decided that I needed to inspect this file for myself to see if I could derive any sort of reasoning of why Apple would have iOS keep this database. I downloaded the nifty iPhone Backup Extractor from supercrazyawesome.com so that I could get to the consolidated.db file. I then opened the database in Base which is a SQLite database client available on the Mac App Store.
After inspecting the database for a few minutes it was clear what was really going on here. The consolidated.db file is located at this path: "/Library/Caches/locationd". This part of the iOS filesystem is well out of reach of the normal iOS user so the naming of the directories in this path are meant to hint developers within Apple as to what is in the directories. It is inside Caches so this is obviously some sort of cache. To any developer who has spent time with UNIX "locationd" would hint to them that the files within are used by a system daemon that has something to do with location. A system daemon is a long-running background process that acts upon certain events as they occur.
So clearly the data about cellphone towers is related to the devices location not anything to do with quality of cell service. What we know so far is that this is a cache of location data based upon the location of towers this device has connected to.
Now lets look at the tables within the SQLite database. There are 3 significant groups of tables within the databases:
- GSM Cell Tower Data
- CDMA Cell Tower Data
- Wi-Fi Network Data
On my GSM iPhone the CDMA related tables were all empty. The GSM related table contained numbers that I suspect identify the tower, a timestamp, GPS coordinates, and a confidence field. The Wi-Fi related tables were very similar. I think the confidence field is very telltale of the purpose of this database. It seems to be a number between 0 and 100 that could possibly represent how confident iOS is of the accuracy of the measurement of that location.
So What Does This All Mean?
Anyone who watched the iOS 4.0 keynote saw Apple explain how location tracking works in iOS and any developer who have used the location APIs are very familiar as well. iOS uses three methods to locate the device it is running on. These are via nearby Wi-Fi networks, nearby cell towers, and traditional GPS. Each of these methods provide a trade-off between battery power and accuracy. The more accurate the location data the more power is used to determine it.
I think this tradeoff is where consolidated.db comes into play. What if when your phone used the power-hogging GPS chip to get a super accurate location on you it also logged the specifics of the current network conditions to later use as a fingerprint for that location. That way in the future the device could compare the fingerprint of the current network conditions against its database and could then derive a fairly accurate location of the device. This would help bridge the gap of the accuracy/power tradeoff especially in places you have spent time before.
So I would say that this consolidated.db file makes your iOS device better over time. The longer this file has been in existence on your device the more accurate your locations will be and the longer your battery will go. Should Apple be encrypting this data? Perhaps, but the information isn't nearly specific enough to be incriminating and any law enforcement officer could get much better data than this in minutes from your wireless carrier. I do not see how a burglar could determine the location of your home or place of work from this data especially due to the hoops they would need to jump through to access it. I would recommend you encrypt your backup, but I don't think you should worry about this data harming your privacy. Oh, and don't jailbreak your device dummy.