skip to content

When a client signs out of a law firm's portal app, which credentials and keys must the phone destroy, and why destroy the key first?

level: middleimportance: should knowfreq 46%

answer

  1. the next holder may be hostile
  2. tokens, wrapping key, biometric key
  3. no key, no readable copy
  4. never wait for the network
  5. killed halfway: resume at launch

basics

~20 s

Destroy the refresh and access tokens, the key wrapping the document data key, and the biometric unlock key. Destroying the wrapping key makes every encrypted copy unreadable at once, even if deleting files is slow or interrupted.

solid answer

~50 s

Sign-out promises that nothing on the phone can open the client's account or documents, even if the next holder is hostile and the network is down. So the app destroys the refresh token in the credential store, the access token in memory, the wrapping key and the wrapped data key that protect the document cache, the biometric-bound unlock key, and any other device key it created for the account. The wrapping key goes first because that is **crypto-erase**: without it, every encrypted copy is unreadable at once, whereas deleting hundreds of megabytes takes time, can be cut short when the OS ends the app, and is not guaranteed to overwrite flash storage. None of this waits for the network; asking the server to revoke the session is best effort. Unsent writes, cached data and the push registration have their own clean-up alongside.

go deeper

for a junior

Recall the list: refresh token, access token, the key protecting the documents and the biometric key all go at sign-out, and the password was never stored.

for a middle

Explain crypto-erase: destroying the wrapping key makes every encrypted copy unreadable at once, so deleting files no longer has to finish for privacy to hold.

for a senior

Design for interruption and no network: an order where every crash leaves the safer state, resume at launch, best-effort revocation, and an offline grant for lost phones.

for a principal

Set the firm's rule: per-account keys so one client can be erased alone, how long an offline phone may keep documents, and what sign-out promises on a shared device.

## What sign-out must guarantee When a client signs out of a phone app that holds confidential case files, the promise is simple: **nothing left on this phone can open their account or their documents**, even if the next person to hold the phone is hostile and even if there is no network. That promise is about **credentials and keys**. Cached data, unsent messages and the push registration each have their own clean-up, run alongside; this part is what makes the rest unreadable. ## What to destroy - **The refresh token** in the OS-protected credential store, plus any copy, of which there should be none. - **The access token** held in memory. - **The wrapping key** in the hardware-backed store that protects the document data key, and the wrapped data key itself. - **The biometric-bound unlock key.** The next person must not inherit a fingerprint gate set up for the last. - **Any other device key** the app created for this account, such as one used to sign requests. What can stay: non-secret settings, and the client's email address if they asked for it to be remembered. ## Why the key goes first: crypto-erase Deleting hundreds of megabytes of documents takes time, can be cut short when the OS ends the app, and on flash storage the old blocks are not guaranteed to be overwritten straight away. Destroying the key that wraps the data key makes every encrypted copy unreadable at once: the files on disk, a forgotten temporary file, a copy restored onto this phone later. This is **crypto-erase**. File deletion still follows, to free the space, but the client's privacy no longer depends on it finishing. It only works if the design kept its keys separate: one data key per account, wrapped by a device key that exists for that account alone. ## The order of operations | Step | Needs the network | If the app is killed right after | |---|---|---| | 1. Record "signing out" in app storage and read the refresh token into memory | No | The next launch sees the record and finishes sign-out | | 2. Destroy the wrapping key and the wrapped data key | No | Documents are already unreadable | | 3. Delete the refresh token and the biometric key | No | The next launch finds the record and finishes clean-up | | 4. Ask the server to revoke the session, using the in-memory token | Yes | The phone holds nothing usable either way | | 5. Delete the ciphertext files, then clear the record | No | Unreadable leftovers, removed on the next launch | Every step before the network call is local, so a client who signs out on a plane is signed out on the phone the moment they tap. If the revocation request cannot be sent, the server-side session ends on its own schedule; ending sessions from the server side is a separate design. ## The phone that never comes back online A **lost** phone that stays offline never hears about a revocation at all. A local limit helps here: 1. When the app downloads documents for offline use, it records an **offline grant** with an expiry set by the server; the length, say fourteen days, is the firm's own assumption, not a platform figure. 2. At every launch, and before opening documents, the app compares the time with the grant. 3. When the grant has passed, the app runs the same crypto-erase as sign-out. The phone's clock can be set back, so this bounds an honest lost phone better than a determined attacker. It still turns "readable forever" into "readable until the grant ends". ## Mistakes that leave the door open - Deleting the files and keeping the keys "so the next sign-in is quick". - Waiting for the server to confirm revocation before wiping anything. - Clearing the in-memory session and calling that sign-out, while the refresh token stays in the store. - Leaving the biometric key, so the next person's face or fingerprint setup inherits access. - One data key for every account on a shared phone, which makes erasing one client's documents impossible without erasing everyone's. - Treating sign-out as a screen change: navigating to the sign-in page while every secret stays where it was.

  • What if the OS ends the app halfway through sign-out?
    Order the steps so every interruption leaves the safer state: first a signing-out record, then the keys, which makes the data unreadable at once, then the tokens, then file deletion. At launch, the record or a missing key triggers the rest of the clean-up. Each step must be safe to run twice.
  • How do you limit access on a lost phone that never comes online to hear about revocation?
    Give offline access an expiry the server sets when the documents are downloaded, and have the app destroy its own keys when it passes, the same crypto-erase as sign-out. The device clock can be wound back, so it bounds an honest lost phone more than a determined attacker, but it ends indefinite offline access.

  • Deleting the files is enough; the keys can stay for the next sign-in.
  • Sign-out has to wait until the server confirms the session is revoked.
  • Destroying the encryption key also revokes the session on the server.
  • Clearing the in-memory session is the whole of sign-out.
  • Keep the biometric key so the next person can unlock faster.