Building a no-photo-upload camera app in Flutter: sandbox storage, binary metadata stripping, and the encryption we removed
Most "private photo vault" apps work the same way: the photo lands in the camera roll first, then gets copied into a vault. That first landing is the problem — the original sits in the library, syncs to iCloud, and shows
Most "private photo vault" apps work the same way: the photo lands in the camera roll first, then gets copied into a vault. That first landing is the problem — the original sits in the library, syncs to iCloud, and shows up in Recently Deleted for thirty days. Copying it somewhere else doesn't undo any of that.
This post is about the other architecture, and the technical decisions behind it.
1. Capture straight into the sandbox
The app never calls a "save to camera roll" API. Photos taken in-app are written to the application's private container:
Application Container/
Library/Application Support/vault/photos/<fileId>.jpg
Library/Application Support/vault/videos/<fileId>.mp4
Library/Application Support/vault/thumbs/...
Three consequences that matter more than they sound:
No photo-library permission needed for capture. The camera writes to our own directory, so the app never asks for "All Photos" access. Import from the library is a separate, explicit flow.
Excluded from iCloud backup. On iOS, the storage directory is marked with URLResourceValues.isExcludedFromBackup = true. Without that flag, the app container is included in the device's iCloud backup by default — and your "never uploaded" claim would be false, because iCloud backup is an upload.
No system index. Files in the app container aren't indexed by the Photos framework; other apps with photo-library access can't enumerate them.
2. Metadata stripping at the byte level, not the re-encode level
The naive way to strip EXIF is to decode and re-encode the image. That works, but it costs quality and CPU, and it's a silent second generation of lossy compression on every capture.
Instead, the stripper operates on the JPEG byte stream directly: walk the marker segments, drop APP1 (EXIF), APP13 (Photoshop IRB / IPTC authorship and captions) and COM (comment) blocks, keep everything else — including the compressed scan data — untouched. Zero re-encoding, zero quality loss.
Two details that are easy to get wrong:
- Keep orientation. EXIF orientation tells viewers how to rotate the image. Strip it blindly and portrait photos render sideways. We keep orientation (and capture time) by rewriting a minimal APP1 instead of dropping the block wholesale.
- Not everything is a JPEG. PNG goes through a chunk filter; HEIC/HEIF is decoded and re-encoded as JPEG first (a real re-encode — there's no cheap byte-level path), and formats that can't be processed safely fail closed rather than shipping metadata through.
Stripping runs on capture, on import, and again on export — because the same file can leave through three different doors (camera roll, ZIP, LAN transfer) and only one of them being clean isn't a guarantee.
3. The passcode layer: PBKDF2, constant-time compare, and the Secure Enclave
Passwords are hashed with PBKDF2 (per-install random salt, high iteration count) and verified with a constant-time comparison so timing can't leak prefix information. Biometric unlock delegates entirely to LocalAuthentication — the app receives a boolean from the Secure Enclave and never touches biometric data.
A second passcode opens a second album: two passcodes, two independent spaces, and the real vault is simply absent from the second view rather than locked behind it. The design goal is separation of spaces — not a lock with a sign on it.
4. The encryption we removed
Early versions of the app had an AES-256-CBC pipeline with a device-held master key. It was removed, and I think the reasoning is worth more than the code was.
The turning point was a pre-launch audit, which found the storage layer writing plain files to the sandbox — and pointed out the real problem: the product's own framing implied more protection than the storage actually carried. So we had two options: build the encryption properly, or change the words. We changed the words, because the honest threat model pointed the same way:
- The main threat for this product is the person holding your unlocked phone — someone you just handed it to, or anyone who knows the passcode. File-level encryption with a key stored on the same device does nothing against that person: they open the app, they pass the lock screen, they see plaintext.
- The other threat — physical extraction of the device storage by an attacker with tools — is real, but iOS data protection (the device passcode deriving the file-system key) already covers most of it, and building our own crypto layer on top invites key-management bugs that are worse than the threat.
So the shipped claim is: sandbox isolation plus the device passcode; no file-level encryption; explicit about what it does not stop. It's a less impressive sentence and a more accurate one.
What I'd do differently
- Write the security claims after the security code ships, not before. Our audit was the right move; doing it pre-launch rather than post-launch was the only reason it was a documentation problem instead of a trust incident.
- Test the "what leaves this app" paths as a matrix. Capture / import / export-to-roll / export-ZIP / LAN transfer — each path is independently capable of leaking metadata. We ended up with a fail-closed default plus a per-path test list; it should have been the design from day one.
If you're building anything that stores user media locally, the checklist is short: is the storage directory excluded from backup? Does every exit path strip metadata? Can the app enumerate its own files after a restore? Get those three right before optimizing anything else.
SheMi: Private Photo Vault — https://www.ruisstech.com/en/ (iOS, no account, no photo uploads)
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.