Building Lanyard, part 5: security decisions you can enforce

"Nothing leaves your phone" is easy to say. These are the decisions behind it, the checks that make the build fail if we break it, and what each one cost.

Dan Fernández

· 5 min read

Part 5 of Building Lanyard.

An earlier post explained why Lanyard processes everything on the iPhone: conference notes are mostly about other people, and the safest data is data you never collect. This one is about how. A privacy promise is only as good as whatever stops you breaking it by accident, so each decision below has a test, a script or a build check behind it.

The network has one door

Every network request in the app goes through one gate, which keeps a short allowlist of hosts per purpose (“telemetry may reach this host, and only this one”). It allows only HTTPS on port 443, follows no redirects, keeps no cookies or cache, and caps how much each response can return.

What makes the gate worth having is the check around it. A build script fails if URLSession, the Network framework, sockets, web views or any other way to reach the network shows up anywhere but that one file, and the script has its own tests so it can’t quietly stop working. The public list of hosts the app talks to is checked against the code as well: if the published list and the real allowlist disagree, a test fails.

Models stay on the phone

Every AI step runs on the phone. Cloud APIs are off, and so is Apple’s Private Cloud Compute. Even an IT admin’s setting that would allow off-device models is read and ignored.

The model also has no tools, so it can’t send, delete or reach the network. If a slide or a badge contains text written to manipulate it, the worst that happens is a strange line in a report the user previews before sending, and sending only ever happens when someone taps Send.

Telemetry with no room for content

We wanted to know whether people finish onboarding and send reports, without being able to learn anything about what’s in them. Every telemetry event is a Swift enum whose values can only be other enums, booleans or ranges like “3–5”. There’s no String, no URL and no raw number, so a field that could carry a name doesn’t exist.

A test walks every event by reflection and fails on any free-text or numeric field. Another fails if an event isn’t listed in the public telemetry document. On the other end, the server refuses any field or value that isn’t in a schema generated from the app’s code.

Telemetry is opt-in, and when it’s off nothing is queued. The install ID changes every day, and Settings has a “See what we send” screen showing the actual bytes. Our one small server stores no IP addresses, user agents or request headers.

A key for every event

Each event gets its own random 256-bit key. That key is only ever stored wrapped (AES-GCM) by a master key that lives in the Keychain, with the event’s ID bound in so a wrapped key can’t be moved onto another event. The database and the files use separate keys derived from it.

Deleting an event deletes its wrapped key along with its files, and without the key any copy left behind is noise. That’s crypto-shredding, and it’s how “delete means gone” holds up.

Audio, photos and notes are sealed in chunks, and each chunk is bound to its file, its position and whether it’s the last one. Reorder a file, cut it short or extend it, and it won’t open.

Two dependencies

The whole iOS app has two third-party dependencies, GRDB and SQLCipher, for the encrypted database. GRDB’s normal package links the system SQLite, which has no encryption, so we vendor its source at a recorded hash and pin SQLCipher exactly.

There are no networking, analytics, crash-reporting or ads SDKs. Adding any package means a line in an allowlist file that only I can add. The test script also runs secret scanning, a vulnerability scanner over dependencies, and a checker for the CI workflows, which are pinned to exact commits.

Keys that never leave this phone

The master key can be read after the phone’s first unlock, so overnight processing works while it’s locked. It’s tied to this device and never synced.

We pay for that one. A new iPhone, or a restore from backup, can’t open old events, because Lanyard’s data is kept out of iCloud and device backups entirely. To keep an event you export a passphrase-protected backup of it. Those backups are built to handle hostile files, with strict version checks, every entry bound to its name and event, and a size limit checked before the passphrase is even tried.

Erasing a person without remembering them

Someone you met can ask you to remove them. Lanyard erases the name from transcripts, notes and records, and stores only an HMAC of what it erased, under a per-event key, so it can keep erasing new mentions without keeping the name.

It took a few rounds to get right. Names need normalizing (Unicode forms, curly quotes, whitespace). Our first version also rewrote matches inside IDs and encoded data, and a short name like “Cade” broke record IDs. Erasure now never touches UUIDs, dates or base64. Recordings aren’t rewritten, and the erase screen says so plainly.

Only what was previewed gets sent

Every send shows a preview first, and what goes out is exactly what was previewed. An internal audit found a branch where a report reworded for a different audience could include lines the user had removed. It never merged, and the reworded preview is now a required step.

Hostile input stays text. Reports are escaped for HTML, Markdown and Slack, so a badge that says <!channel> can’t ping a whole channel, and links only open http and https. A business card whose email field contained a comma used to add a second recipient; now the address is checked.

Admins can only restrict

Companies can manage Lanyard with MDM. They can turn off recording, exports, telemetry or the clipboard, shorten how long events are kept (with notice to the user) and require App Lock. They can’t add network hosts, turn telemetry on or read anything.

What it cost

At launch, Slack, Notion and Google Docs are “Coming soon”, because each needs its own review first, so you send by email, the share sheet, Files, Reminders or Copy. There’s no sync or migration, only per-event backups made by hand. There’s no crash reporter either: we get bucketed counts from the OS rather than stack traces, so some bugs take longer to find. I review every line of encryption, Keychain, networking and sending code, and that’s often the slowest step in a release. App Lock and the extra preview step add a few taps.

We also had outside eyes on it, with several internal audits and an independent security review before launch. Each finding gets fixed and gets a test, and every release has to pass those gates before it ships.

Next: things to watch out for, the bugs the Simulator never showed us.

Working on something similar?

If this is close to a problem your team has, tell us about it.