skip to content

Client Security & Privacy

A mobile app runs on hardware an attacker may own, so secrets on disk, the network path and the binary itself each need a design. Interviewers probe what only the server can enforce.

on this pageshow

explore

questions

12

In a law firm's client-portal phone app, why can't the refresh token live in a plain preferences file, and what should the app never store?

level: juniorimportance: must knowfreq 58%

answer

  1. the sandbox is only one wall
  2. backups copy ordinary app files
  3. a bearer token works anywhere
  4. the OS-protected credential store
  5. the password is exchanged, never kept

basics

~20 s

A plain preferences file is cleartext that device backups, file copies and rooted or jailbroken phones expose. Keep the refresh token in the OS-protected credential store; never persist the password, and keep only what offline use needs.

solid answer

~50 s

The app sandbox stops other apps opening the preferences file, but the file is still ordinary cleartext app data: both platforms put ordinary app files into the device backup by default unless the app excludes them, and a rooted or jailbroken phone reads it directly. A refresh token is a bearer credential, so a copy usually works anywhere until it expires or is revoked. The OS-protected credential store (a system store on one platform, a secret encrypted under a key-store key on the other) keeps small secrets encrypted under keys the app cannot read, releases them only to that app, and lets it choose when each is readable. It protects the token at rest, not from code running inside the app. Never persist the password (it is exchanged once for tokens), no raw token sits outside the store, and the phone keeps only what offline use needs.

go deeper

for a junior

Recall the three ways a preferences file leaks: the device backup, a rooted or jailbroken phone, a copy of the app's folder. Then name the OS-protected credential store and say the password is never kept.

for a middle

Explain what the credential store adds, encryption under keys the app cannot read and read conditions chosen when the secret is stored, and what it does not: it still hands the token to code running as the app.

for a senior

Tie storage to the server: a bearer token copied off the phone works anywhere, so lifetime, revocation and how little the phone keeps for offline use matter as much as where it rests.

for a principal

Frame a client-wide rule: which secrets the phone may hold at all, in which store, for how long, and which offline promises the firm declines because of what a lost phone would carry.

## The question behind the question Every phone app that signs a user in ends up holding a **refresh token**: a long-lived credential the app presents to obtain fresh, short-lived access tokens without asking for the password again. In a law firm's client-portal app it opens a client's confidential case documents and their messages with their lawyer. Where the app writes that token down decides who else can pick it up, and what the app writes down besides it decides how much a lost phone gives away. ## Why a plain preferences file fails A **plain preferences file** is the app's ordinary key-value settings file: convenient, fast, and stored as cleartext inside the app's private folder. The app sandbox stops *other apps* from opening it, and many teams stop reasoning there. The sandbox is one wall among several: - **Device backups.** Both platforms back up an app's ordinary files by default, leaving out cache folders and whatever the app explicitly excludes; on one platform the preferences files are named in that default set. A token in preferences travels into every backup. - **A compromised device.** On a rooted or jailbroken phone the sandbox no longer holds, and a process with elevated rights reads the file like any other. - **Copies of the app's folder.** Debugging, backup and forensic tools that copy an app's files copy the token with them. - **It is a bearer credential.** Whoever holds a copy can usually use it from any machine until it expires or the server revokes it; nothing in the token ties it to this phone. Encoding the value in `Base64`, scrambling it reversibly or giving the preference a meaningless name changes how it looks, not who can read it. ## What the OS-protected credential store adds Each platform offers an OS-protected way to keep small secrets, called here the **OS-protected credential store**. On one platform it is a system store: the system encrypts each item under keys it manages, releases it only to the app that stored it, and lets the app choose, when the item is created, the conditions under which it can be read: only while the phone is unlocked, from the first unlock after a restart, only with the user present, only on this device. On the other, the same protection is built by encrypting the token under a key held in the hardware-backed key store and keeping only the ciphertext, with the conditions attached to that key; cross-platform secure-storage wrappers do this on the app's behalf. | Where the token rests | Copied files or a backup | Other apps | Code running as the app | Read conditions | |---|---|---|---|---| | Plain preferences file | Readable as cleartext | Blocked by the sandbox | Readable | None | | OS-protected credential store | Not readable as cleartext | Blocked | Readable: the store answers the app | Chosen when stored | The last two columns matter in an interview. The store protects the token **at rest**. It does not protect it from code running inside the app, such as a compromised third-party library, because to the store that code *is* the app. That is one reason tokens stay short-lived and revocable by the server whatever the phone does. ## What never to persist The second half of the question is the one candidates skip. Keep on the phone only what offline use needs: 1. **Never the password.** Exchange it once for tokens and drop it. A stored password, however it is encrypted, is often reused on other services, cannot be revoked the way a token can, and lets whoever extracts it sign in afresh from anywhere. 2. **No raw token outside the credential store**: not in preferences, not in a column of the local database, not in a file written "for the background job". 3. **No more content than the offline promise.** If the firm lets clients read documents they marked for offline use, keep those, encrypted on disk; not every document they ever previewed. ## A short design for the portal - At sign-in the app receives its tokens, keeps the access token in memory and writes the refresh token to the credential store. - The password field is cleared and never written anywhere. - Offline documents are encrypted on disk under a key that is never stored beside them; how that key is protected is a separate decision. - The preferences file holds only non-secret settings: theme, which matter was open last, and the client's email address if they asked to have it remembered. - At launch the app reads the refresh token from the store; if it is not there, the app shows sign-in rather than guessing. ## How interviewers mark it A passing answer names the credential store. A good one also says what the store does **not** do, which is protect the token from code running as the app, and offers the never-persist list unprompted, starting with the password. A weak one defends preferences because "the sandbox protects them", or reaches for an encoding as if it were encryption.

  • Does the credential store protect the token from malicious code running inside the app, such as a compromised third-party library?
    No. The store releases the secret to the app's identity, and anything executing in the app's process is the app as far as the store can tell. It defends the token at rest: against copied files, backups read elsewhere and other apps. Against code inside the app the defences are short token lifetimes, server-side revocation and keeping untrusted code out of the app.
  • The firm wants clients to read documents offline for a week; what should the phone store to make that work?
    The minimum: the refresh token in the credential store, only the documents the client marked for offline use, encrypted under a key that is not stored beside them, and the time the offline grant expires. Not the password, not every matter's file list, not documents merely previewed once. Each extra item enlarges what a lost phone gives away.

Leaving the refresh token in preferences is like leaving the office key under the doormat of a building with a locked lobby: other tenants cannot reach it, but the cleaner, the locksmith and anyone who copies the doormat can. The credential store is the building's key safe, opened only for the named tenant; it still opens for anyone who walks in as that tenant.

  • The app sandbox already protects preferences, so a token there is safe.
  • Base64-encoding the token makes it unreadable to an attacker.
  • Store the password encrypted so the app can sign the user back in silently.
  • A token in the credential store is safe from anything running inside the app.
  • Cache every document the client opened, in case they go offline later.
open as a page

In a law firm's client-portal app with offline case documents, how should they be encrypted at rest, and what does a hardware-backed key defend against?

level: middleimportance: must knowfreq 55%

basics

~20 s

Encrypt documents and the database under a data key that a non-exportable, hardware-backed key protects, never stored beside them. That defeats copied files and backups read elsewhere, not code running as the app on an unlocked or compromised phone.

open as a page

Should a banking app pin its server keys, and for which domains: its own API, an image CDN, an analytics host?

level: middleimportance: must knowfreq 48%

basics

~20 s

Pin the bank's own API, not hosts it does not control. Pinning defeats a mis-issued or device-added certificate authority, but it costs lockout risk when keys change, breaks inspecting proxies and complicates testing, so it comes with a rotation plan.

open as a page

A banking app pins its API keys and two-year-old builds are still installed; how do you rotate the server key without locking those builds out?

level: seniorimportance: must knowfreq 42%

basics

~20 s

Never deploy a key that installed builds do not pin. Each build ships the live key, an offline backup and an expiry on the pin set; a new key goes live only after shipping for one expiry window, so every build pins it or has expired.

open as a page

In a banking app, how should the cleartext policy handle a partner's plain-HTTP feed and a plain-HTTP test server?

level: juniorimportance: should knowfreq 44%

basics

~20 s

Keep the app TLS-only, as current platform defaults already are. Move the partner feed to HTTPS or relay it through the bank's own HTTPS API, and give the test server a debug-only exception that the release build never carries.

open as a page

In a law firm's client-portal app, why does a background token refresh fail on a locked phone, and which availability class suits each secret?

level: middleimportance: should knowfreq 45%

basics

~20 s

The token was stored readable only while the phone is unlocked, so a job on a locked phone cannot read it. Give the refresh token the after-first-unlock, device-only class; keep the document key unlocked-only, since documents open in the foreground.

open as a page

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%

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.

open as a page

How should a banking app's server check platform attestation before adding a new payee, and what does a pass not prove?

level: middleimportance: should knowfreq 45%

basics

~20 s

The server issues a one-time challenge; the platform signs a statement about app and device that embeds it; the server verifies it and decides. A pass shows a genuine app on a genuine device, not an honest human or their intent.

open as a page

In a law firm's client-portal app unlocked by fingerprint or face, why is a yes/no biometric check weak, and what must happen when a new fingerprint or face is enrolled?

level: seniorimportance: should knowfreq 51%

basics

~20 s

A yes/no result is a value in app code that hooking or patching flips. Bind unlocking to a key released only after biometric success; a new enrolment can invalidate it, so fall back to the password and re-protect.

open as a page

A law-firm portal client restores a backup onto a new phone, or reinstalls the app; what can the app find at first launch, and how must it treat it?

level: seniorimportance: should knowfreq 47%

basics

~20 s

Backed-up files can arrive without the device-bound key that opens them, and on one platform old credentials can outlive an uninstall. Clear what a fresh install finds, and on a missing key delete the ciphertext, sign in again and re-download.

open as a page

The fraud team wants a banking app to refuse rooted or jailbroken phones using on-device checks; why won't that hold, and what would you build instead?

level: seniorimportance: should knowfreq 40%

basics

~20 s

Whoever controls the phone controls the app's code, so hooking or patching makes any on-device check report clean. Keep checks as cost and telemetry; let the server decide per action, scoring device signals and stepping up risky payee additions.

open as a page

After a server certificate change, a banking app's pin-failure reports spike; how do you tell your own mistake from interception, and what should the app do?

level: seniorimportance: nice to knowfreq 30%

basics

~20 s

Slice reports by app version, network and presented key: failures everywhere, in exactly the builds lacking the new key, are your rollout; an unknown key clustered on some networks is interception. Either way the app refuses and explains.

open as a page