Blog · Security
Checking the rules a bot must never get around
IRL Formal: we wrote down the few rules that keep bots from thriving on IRL as exact properties, and checked them three ways. A model checker found a real hole in the order of two steps, and two more ways the rules were too weak or too harsh. All three are fixed. Here is what was checked, what it found, and what it doesn’t prove.
The question
When a trap catches a bot on IRL, the account is quarantined. It keeps its own view of the app, so it can’t tell, and nothing it does reaches anyone else. The question we set: once an account is quarantined, can any order of ordinary steps give it influence back without a person on our side releasing it? Signing up, inviting, making friends, posting, getting caught and getting released, in any order and at the same time as each other.
Tests answer for the orders someone thought of. Bots don’t keep to those.
Three ways of checking
- A model, checked in every state. We wrote the logic of quarantine, invites and vouching in TLA+ and ran TLC, a model checker, over it. It tries every order of every step, within a fixed size: 619,149 distinct states for the quiet room with every fix in, 945,702 for vouching.
- Property tests. 10 rules, each run against the real code with 3,000 generated inputs, shrunk to the smallest failing input when one breaks. They cover the quiet room’s check, the bot reports we may sell (only caught bots, every count 0 or at least 5, no @name and no words), tracking tags taken off links, and message sealing.
- Proven code. Message text is now sealed with ChaCha20-Poly1305 from HACL*, code that is mathematically proven to compute the standard’s algorithm, to be memory safe, and to take the same time whatever the key.
A check that can’t fail proves nothing, so each was first shown to catch a bug we planted on purpose. Two of our first property tests missed theirs. We fixed the tests before trusting them.
What it found
A caught account’s invite could still let someone in. When someone signs up through an invite, the @name is held for up to 15 minutes before the account is made. The checker found this order, 3 steps: someone claims an @name through a person’s invite link, a trap catches that person while the claim is held, and then the account is made. The new account was trusted from the start, on a caught account’s link, without the bot check. Each step was right on its own; only the order was wrong. It’s fixed: such an account starts on probation, and a real friend lifts it. We replayed the same steps against our database: the test fails without the fix and passes with it.
A release didn’t give back the power to vouch. If three people you invited are caught, you lose the power to vouch for anyone. If a reviewer then finds one of them was a person after all, you should get it back, and you didn’t. Now you do, as soon as fewer than three are left. Only a reviewer can release anyone, so a bot can’t use this. The model caught a trap in the obvious fix: counting only the bots caught before you lost it would give it back while three still stand, if one was caught after. The fix counts them all.
People a bot vouched for kept that vouch. If a bot made friends with you before it was caught, its vouch for you stayed, so a cluster built around a bot kept its standing for up to a day. Now, the moment a bot is caught, each person it vouched for is either backed by another friend who can vouch, and nothing changes for them, or held: they use IRL exactly as before, but can’t vouch for anyone until the hold lifts. It lifts if the bot turns out to be a person, if a real friend adds them, or when the daily trust count finds enough trust from people reaching them. Nobody a bot befriended is sent back to the start: a bot’s friends are often people.
What holds now
With all three fixes in one model, in every state: nothing a quarantined account does reaches anyone else; no trust is ever given on the strength of an account that is quarantined at that moment; only a reviewer’s release gives a caught account its standing back; nobody passes trust on while their own vouch rests on a caught account; and a hold or a lost power to vouch never outlasts its cause.
Those rules say nothing bad happens, and a system that never gave anyone their standing back would pass them. So we also checked the other side: a person who is cleared, with nothing else against them, gets their standing back in the end. That one depends on the daily trust count actually running. The checker confirms it under that assumption, and finds a way it fails without it.
The vouching rules hold too: you lose the power to vouch only on three different sources of bots, one leaked link is one source however many bots use it, and two catches at the same moment take it once.
The mathematics, kernel-checked
Tetelestai’s one-time MAC and recovery shares rest on a few lines of algebra: how many keys a forged tag can fit, how many values of x a tampered share can pass. Those lines are now theorems in Lean, accepted by its kernel and replayed through six external checker runs, four of them checkers that are not Lean’s kernel, with no library beyond Lean’s own: the root bound; the forgery bound, max(L, L′) keys of 2^128, and the tamper bound, d + 1 values of x, each also as a probability over the key space, the forgery bound also end to end as mac.js computes it, pad and block splitting included; the field’s own existence (GCM’s polynomial is irreducible, proved from Fermat’s little theorem with 64 gcds the kernel computes); and, from a research result sheet we were sent, a curvature conservation theorem that gives our bot red team a signal. Two textbook results the key book rests on are in the same record: the one-time pad’s perfect secrecy (exactly one pad takes any word to any word), and that fewer than k Shamir shares fit every secret by exactly one polynomial each. GF(2^128) itself is a field in Lean, with nothing assumed, and with it the forgery bound is a statement about mac.js’s own loop on byte messages. Real test vectors from the code are recomputed by the kernel, so the Lean loops are the code’s. The record of the last run is lean.json, anchored in Bitcoin with OpenTimestamps (the proof), and irl-formal, the proofs published on their own, replays it by hand with nothing of ours (lean/README.md). Every theorem’s statement is read against the claim it carries in formal/lean/AUDIT.md, because a kernel checks what was written, not what was meant.
What this doesn’t prove
- The Lean theorems are about the constructions’ mathematics. That the JavaScript is that mathematics is SPARK’s proof and the test vectors, not a theorem; that the keys are random and used once is the key book’s job, not Lean’s.
- The model is checked, not the code. The code is tested against the same rules, and every finding was run against our real database, but tests sample; they don’t prove.
- The checks run at a fixed size: a few accounts, not millions.
- The quiet room is enforced by one check every list and alert must ask. Each one is tested; a new screen that forgot it would be a gap these checks wouldn’t see.
- Only the cipher is proven, not the code around it, the key, or the server. Messages aren’t end to end: our server opens them to review them.
- None of this says every bot gets caught. It says what a caught one can’t do.
IRL isn’t “formally verified”, and we won’t say it is. These are the few rules the commitments rest on, written down exactly and checked as hard as we can check them today.
Read the paper
The paper has the properties, the method, every number above and the references: IRL Formal (PDF). On our side, one command, npm run formal, reruns the models and the tests and writes the numbers this post quotes. The rules themselves are in plain words in the rules.
Credits
The mathematics is older than IRL: C. E. Shannon on the one-time pad (1949), Adi Shamir on secret sharing (1979), Michael O. Rabin (1980) and Michael Ben-Or (1981) on testing a polynomial for irreducibility, Mark N. Wegman and J. Lawrence Carter on one-time authentication (1981), Ronald Cramer, Yevgeniy Dodis, Serge Fehr, Carles Padró and Daniel Wichs on detecting tampering (2008), and Yann Ollivier, Yong Lin, Linyuan Lu, Shing-Tung Yau, Jürgen Jost, Shiping Liu and others on curvature in graphs.
The method borrows from three projects. Alexander S. Donahue’s secmesh-pqsi gave our Lean its field axioms and its root-count proof (Apache-2.0), and his archive the habits of formalizing known results to the same standard as new ones, auditing each statement against what it claims, and replaying proofs with outside checkers. Alex Townsend’s OpenProblemsInNLA gave the shape of our list of open problems. Terence Tao’s Lean companion to Analysis I gave the shape of our “as the code computes it” theorems.
The tools: Lean and the checkers released with it, SPARK and GNATprove with the Why3, Alt-Ergo, cvc5 and Z3 provers, TLA+ and its model checker TLC, fast-check, HACL*, OpenTimestamps, and the shamir-secret-sharing library, audited by Cure53 and Zellic.
IRL’s founder set the questions and the rules. The models, proofs and research were written with AI coding assistance, and the checks don’t rest on trusting that: kernels, provers and a model checker check them, and the Lean proofs are replayed on GitHub’s machines at every change. What they assume, such as good randomness and the code matching the models, still needs its own evidence. None of the people or projects named here has reviewed or endorsed this work.
New to IRL? Make your @name.