I looked a little deeper into this topic. Yes, the files are by default encrypted. The problem is that they are only encrypted with the device key which can be retrieved from the device even when the device is locked. If you apply the settingNSFileProtectionComplete the files are encrypted with the device key and the unlock passphrase. This way if the device is lost and locked an attacker cannot encrypt the files unless he has the unlock passphrase. There is a similar setting for the kaychain.
Interesting! Thanks for the links to the Fraunhofer papers — I hadn't seen those before, and they look very authoritative, especially since the first author's name is Jens. That's a name I can trust. The papers only describe the security of secrets stored in keychains, though, not of application files, although of course they're related since the file decryption keys are stored in the keychain.
It sounds as though:
• All files/keys are secure against remote attacks (malware) that don't compromise the OS kernel itself.
• The attacks Fraunhofer performed required physical access to the device, in order to jailbreak it and run their forensic app on it. In this case keys protected only by the device key can be retrieved. It looks like these tend to be system keys that need to be available even when the device is locked.
• Keys and passwords in application keychains are safe, because the default settings prevent access to them without having the user's passcode.
• Application files are by default not safe against a jailbreaking attack because their encryption is based only on the device key.
• Setting any of the non-default NSFileProtection attributes makes files safe — I don't see a great deal of difference between the levels, because they all protect files until the device is first unlocked with the user passcode, and jailbreaking requires rebooting the device.
The resolution seems to be that we should apply a file protection attribute to TouchDB database and attachment files. The best attribute seems to be (deep breath) NSDataWritingFileProtectionCompleteUntilFirstUserAuthentication, because it allows access to the file after the device is locked. That way if a push replication is active when the device locks, it can keep working without running into file access problems.
—Jens