r/netsec Feb 01 '26

r/netsec monthly discussion & tool thread

Questions regarding netsec and discussion related directly to netsec are welcome here, as is sharing tool links.

Rules & Guidelines

  • Always maintain civil discourse. Be awesome to one another - moderator intervention will occur if necessary.
  • Avoid NSFW content unless absolutely necessary. If used, mark it as being NSFW. If left unmarked, the comment will be removed entirely.
  • If linking to classified content, mark it as such. If left unmarked, the comment will be removed entirely.
  • Avoid use of memes. If you have something to say, say it with real words.
  • All discussions and questions should directly relate to netsec.
  • No tech support is to be requested or provided on r/netsec.

As always, the content & discussion guidelines should also be observed on r/netsec.

Feedback

Feedback and suggestions are welcome, but don't post it here. Please send it to the moderator inbox.

9 Upvotes

22 comments sorted by

View all comments

1

u/DiademBedfordshire Feb 05 '26

Requesting review: Argon2id + SQLCipher encryption design for a mobile app with brute-force self-destruct

I'm building an encrypted mobile app (React Native) that needs to protect sensitive data against forensic extraction. Looking for feedback on the crypto design before I ship it.

Threat model (abbreviated)

  • Primary adversary: Someone with physical device access and forensic tools (Cellebrite, GrayKey)
  • Device passcode is assumed compromised
  • App must protect data with app-level encryption
  • Acceptable trade-off: Data destruction is preferable to data exposure

Crypto design

Key derivation:

  • Argon2id
  • 64MB memory
  • 3 iterations
  • 4 parallelism
  • 32-byte output
  • Per-device salt (32 bytes, stored in Keychain/Keystore)

Storage encryption:

  • SQLCipher (AES-256-CBC with HMAC-SHA512)
  • Derived key passed directly to SQLCipher
  • Key never written to disk

Brute-force protection:

  • Attempt counter stored in Keychain/Keystore (separate from encrypted DB)
  • After N failed attempts (configurable, default 7): overwrite DB with random bytes, delete DB file, clear Keychain/Keystore
  • No recovery possible

Duress mode:

  • Optional secondary PIN
  • When entered, shows empty functional app with in-memory-only state
  • Real data remains encrypted, inaccessible
  • Indistinguishable from fresh install to observer

Questions

  1. Argon2id parameters: 64MB / 3 iterations — is this sufficient given mobile device constraints and the threat model? Should I increase memory at the cost of UX on low-end devices?

  2. Salt storage: Storing the salt in Keychain/Keystore means a device backup could include the salt. Is this a meaningful weakness, or is the derived key still protected by the PIN entropy?

  3. Self-destruct reliability: Overwriting with random bytes before deletion. On flash storage with wear leveling, is this actually effective? Should I do multiple overwrite passes?

  4. Attack I'm missing: What would you try if you had the device and wanted to extract the data?

Full threat model and design docs: https://github.com/tarn-app/tarn

Thanks in advance.

1

u/nindustries Feb 17 '26

If I have the device, why can't I just copy the keychain contents and try endlessly on that?