CYART // SCHEMA · SECRETS-MANAGER8 NODES · 7 LINKSIDENTITY1TOKEN2ALLOWED?3READ4UNWRAP DEKMINT SHORT-LIVEDACTOR · Workload — pod / lambda / VMACTOR01Workloadpod / lambda / VMEDGE · Auth methods — OIDC, IAM, k8s SAEDGE02Auth methodsOIDC, IAM, k8s SASERVICE · Secrets API — lease, TTL, auditSERVICE03Secrets APIlease, TTL, auditSERVICE · Policy engine — path ACL, deny by defaultSERVICE04Policy enginepath ACL, deny by defaultDATA · Encrypted store — Raft, envelope encryptionDATA05Encrypted storeRaft, envelope encryptionDATA · KMS / HSM — root key never exportedDATA06KMS / HSMroot key never exportedSTREAM · Dynamic backends — DB users, cloud credsSTREAM07Dynamic backendsDB users, cloud credsDATA · Audit log — append onlyDATA08Audit logappend only

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.

● Hard🔒 PROBy ·Design problem·18 min read·Advanced → Staff
PCI DSStokenisationformat-preserving tokenscard data vaultHSMPCI scope reduction

01Understand the problem

✓What you will learn
  • 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
◎Interview radar

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

  1. Tokenise a PAN and return a token that looks like a card number: same length, last four preserved.
  2. The same PAN gets the same token (card on file, dedupe, fraud joins).
  3. Detokenise only for authorised callers and purposes, ideally by forwarding the PAN to the processor so the caller never sees it.
  4. Delete a card when the customer removes it, and audit every operation.

Non-functional requirements

  1. 50 million stored cards; tokenise 3,000/s at peak checkout, detokenise 1,000/s (authorisations, recurring billing).
  2. p99 tokenise < 150 ms (cross-region write), detokenise < 20 ms in-region.
  3. 99.99 % and RPO 0: a lost mapping is a lost card and a failed recurring payment.
  4. 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.
▭On the whiteboard · Scope3 points
01
FR
tokenise | deterministic | detokenise / forward | delete + audit
02
NFR
50M cards | 3k + 1k rps | RPO 0, 99.99 % | PCI DSS v4.0
03
out
acquirer integration details, fraud scoring, network tokens (follow-up)

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.