A spaced-repetition or flashcard app still ships its scheduling algorithm
Spaced-repetition apps sell a promise: review this card tomorrow, not tonight, and you will remember it longer. That promise is an algorithm — intervals, ease factors, fuzz, leech thresholds, and the load-balancing that
Spaced-repetition apps sell a promise: review this card tomorrow, not tonight, and you will remember it longer. That promise is an algorithm — intervals, ease factors, fuzz, leech thresholds, and the load-balancing that keeps a daily queue sane.
Many "privacy-first" and offline-first flashcard tools run that algorithm entirely in the browser or the Electron shell. Every paying customer, and every competitor, can read it.
What ships in a client-side SRS
A typical in-browser or offline spaced-repetition client includes:
- The scheduler — how a grade (again / hard / good / easy) updates ease and the next interval, including first-learning steps.
- Fuzz and load limits — randomization so cards do not clump, and caps so a user is not hit with 400 reviews on Monday.
- Leech and new-card policy — when a card is buried, suspended, or replaced, and how many new cards are injected per day.
- Retention targets — desired recall probability, and the parameters that were fit on your own data or a published method (SM-2, FSRS, or a house blend).
- Streak and mastery badges — product logic that looks cosmetic until it is part of a paid "pro study plan".
If you tuned those numbers for months, they are the product. The card UI is not.
How it gets copied
Schedulers are small, pure functions. Attackers search for constants like 1.3, 86400000, or strings such as "ease" and "lapses".
export function nextInterval(card, grade, now = Date.now()) {
// grade: 0 again, 1 hard, 2 good, 3 easy
let { ease, intervalDays, reps, lapses } = card;
if (grade === 0) {
lapses += 1;
reps = 0;
ease = Math.max(1.3, ease - 0.2);
return { ease, intervalDays: 0, reps, lapses, due: now + 10 * 60 * 1000 };
}
ease = Math.max(1.3, ease + (0.1 - (3 - grade) * (0.08 + (3 - grade) * 0.02)));
if (reps === 0) intervalDays = grade === 3 ? 4 : 1;
else if (reps === 1) intervalDays = 6;
else intervalDays = Math.round(intervalDays * ease * (grade === 1 ? 0.85 : grade === 3 ? 1.3 : 1));
return { ease, intervalDays, reps: reps + 1, lapses, due: now + intervalDays * 86400000 };
}
A competing app can paste that function, rename two fields, and advertise "the same proven spacing, with a nicer theme". If you claimed a proprietary retention model, the parameters are sitting in the same file.
What actually protects you
Decide what must be authoritative
- Classrooms, corporate training, and certification should record reviews on the server and let the server pick the next due date. The client can cache a queue for offline use and reconcile later, but the official schedule cannot be a function anyone can patch to "mark all mastered".
- Shared decks you sell can still sync content without shipping a one-of-a-kind scheduler in clear text.
- A/B tests of new spacing parameters should be assigned and measured server-side, or your experiment is public.
If offline review is a real requirement
People study on the subway. You may have to ship a scheduler:
- Bundle it separately from the UI and deck content.
- Protect the scheduler and any fitted parameters with control-flow or VM-based obfuscation, not only minification.
- Do not leave the parameter table as readable JSON beside a "decryption" key in the same bundle.
- Re-validate review history when the client syncs; reject impossible streaks and bulk "easy" grades that bypass the algorithm.
- Keep source maps off the public CDN.
- Add a harmless distinctive quirk in fuzz or ease flooring so a cloned scheduler is recognizable.
Be careful with research claims
If you cite a public algorithm (SM-2, FSRS), say so. Obfuscation does not turn a public method into a trade secret. Protection is for your fitted parameters and house policy, not for hiding a well-known formula you should have attributed anyway.
Practical checklist
- [ ] Official classroom or certification progress is computed or re-checked on the server.
- [ ] Offline queues reconcile with the server; patched "all cards mastered" states do not survive sync.
- [ ] The scheduler and fitted parameters are split from the UI bundle.
- [ ] That chunk is protected with stronger-than-mangling obfuscation (control-flow or VM).
- [ ] Parameter tables are not shipped as clear JSON with a key in the same file.
- [ ] Source maps for the scheduler are not on the public CDN.
- [ ] Public algorithms are attributed; only house parameters are treated as sensitive.
- [ ] Streaks and paid study plans cannot be unlocked by flipping a flag in DevTools.
Honest limits
A motivated developer can still approximate your interval curve by recording what the app does. Obfuscation raises the cost of a clean copy-paste. It does not prevent someone from black-box fitting a similar scheduler. Put authority on the server when the result matters.
Summary
A flashcard app that schedules reviews in the browser ships its spacing algorithm and parameters to every learner. Re-check official progress on the server, protect the offline scheduler you have to ship, and stop treating minified nextInterval as a trade secret.
Disclosure: I work on VEILVM, a JavaScript VM-protection service. Free browser tier (3 runs/day, up to 5 KB) and a Pro plan at $9/month or $79/year with API access. Try the playground at vm.ldvmp.com.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.