Design a PCI tokenisation vault
Design the vault that turns card numbers into tokens for a merchant storing 50 million cards: random format-preserving tokens, a cardholder data environment shrunk to a few services, HSM-backed keys, detokenisation only for callers with a purpose, active-active regions with no lost mappings, and an audit trail a QSA will sign off.
01Understand the problem
- Explain tokenisation versus encryption and why random tokens shrink PCI DSS scope
- Design format-preserving tokens and deterministic lookups with a keyed index
- Use an HSM and envelope encryption for PANs and lock down detokenisation
- Run the vault active-active across regions with no lost mappings and a complete audit trail
What they probe: what is in the cardholder data environment and what is not, why a token is not just an encrypted PAN, how the same card gets the same token, who can turn a token back into a PAN and how you stop bulk extraction, and what happens if a region goes away. Where candidates slip: hashing PANs without a key, letting every service detokenise, card numbers flowing through app servers so the whole app is in scope, async replication that loses cards.
PCI DSS (Payment Card Industry Data Security Standard) applies to every system that stores, processes or transmits the PAN (primary account number) and everything connected to them: the cardholder data environment (CDE). A token is a surrogate that stands in for the PAN. If it is random, with no mathematical relationship to the PAN, a system holding only tokens with no way to detokenise can be taken out of scope. Shrinking scope from 400 services to five is the business case for the vault.
Functional requirements
- Tokenise a PAN and return a token that looks like a card number: same length, last four preserved.
- The same PAN gets the same token (card on file, dedupe, fraud joins).
- Detokenise only for authorised callers and purposes, ideally by forwarding the PAN to the processor so the caller never sees it.
- Delete a card when the customer removes it, and audit every operation.
Non-functional requirements
- 50 million stored cards; tokenise 3,000/s at peak checkout, detokenise 1,000/s (authorisations, recurring billing).
- p99 tokenise < 150 ms (cross-region write), detokenise < 20 ms in-region.
- 99.99 % and RPO 0: a lost mapping is a lost card and a failed recurring payment.
- PCI DSS v4.0: PANs unreadable wherever stored, keys protected in an HSM, every access logged, logs kept 12 months with 3 months immediately available.
This is an advanced module
Design problems: data security is part of the Pro pass. 4 more sections — the deep dives, the final design, follow-ups and the test — unlock with it.
Already a cyart.io or studio.cyart.io member? Your pass code is in your Studio account.
Related lessons
- Design a secrets managerHLD · Design problems: Infrastructure & dataPro
- Design PKI and certificate automationHLD · Design problems: Infrastructure & dataPro
- Data protection: KMS, envelope encryption, tokenisationSecEng · Cloud & Platform SecurityPro
- Design a key management serviceHLD · Design problems: Infrastructure & dataPro