Part 2: Vault tokens
Part 2 of 5 in a deep dive on card tokens, token vaults and where the card number went. Start with Part 1 if you are new to the series.
What a card number is
The number on the front of a card is the primary account number, or PAN. It has three parts. The first six or eight digits are the issuer identification number, usually called the bank identification number or BIN, and they identify the bank that issued the card. The digits after that identify the account. The last digit is a check digit, computed from all the others so that a mistyped number is caught before it is sent anywhere.
The check digit comes from the Luhn algorithm. Starting from the right, double every second digit, and if a doubled digit is greater than 9, subtract 9 from it. Add up all sixteen results. The number is valid if the sum is a multiple of 10. For the test number 4111 1111 1111 1111 the doubled digits give 8 and seven 2s, the others give eight 1s, and 22 + 8 = 30. For any choice of the first fifteen digits exactly one check digit works, so one string of digits in ten is a valid number.
This makes a card number a weak secret. The BIN identifies the bank, so it is the same on many cards and is not secret. The card industry's security rules are called PCI DSS, short for Payment Card Industry Data Security Standard. A body called the PCI Security Standards Council writes them, and I will call it the PCI council. Under those rules a company may show the BIN and the last four digits on screens and reports. On a 16-digit card with a six-digit BIN that leaves nine account digits unknown. The check digit follows from them, so there are 109, one billion, possible numbers. A billion is a small space for a computer to search, and the next section shows what the search costs.
Why a hash is not a token
A hash function is a calculation that turns any input into a short fingerprint of fixed length. It is built to be quick to compute and practically impossible to run backwards. SHA-256 is one such function, and it is the one in the speed test below. Storing the SHA-256 fingerprint of a card number looks like a way to recognize the card later without keeping the number. It fails because there are so few possible card numbers. A thief with the fingerprints can hash every possible number and see which results match.
Hashcat is a password-recovery program, and its users publish speed tests of new hardware. In one such test a single consumer graphics card, the Nvidia RTX 4090, computed about 22 billion SHA-256 hashes per second. Divide the billion candidates behind one six-digit BIN by that rate and the search takes 109 ÷ (2.2 × 1010), about 0.045 seconds. Now drop the assumption that the BIN is known. There are 1016 strings of 16 digits and one in ten passes the Luhn check, so 1015 are valid numbers. Hashing all of them takes 1015 ÷ (2.2 × 1010), about 45,000 seconds or 12.5 hours. The divisions are my arithmetic.
It gets worse when a shortened copy of the number sits next to the hash. A truncated number is a copy with some of the digits permanently removed. Under PCI DSS a merchant may store one. For a 16-digit Visa or Mastercard number the council's table of formats requires at least four digits to be removed and allows at most the first eight and any other four to be kept. Take a database that keeps the first six and the last four. Six digits are missing, which makes 106 combinations. The check digit is among the known last four and only one combination in ten agrees with it, so 105 = 100,000 candidates remain. With the first eight and the last four, 1,000 remain.
The PCI council has two rules for this. Hashes created after March 31, 2025 must be keyed. A keyed hash mixes a secret key into the calculation. A thief who copies the database without the key cannot compute the fingerprint of even one candidate, so the search in Figure 4 cannot start. The second rule covers hashed and truncated copies of the same number kept in one environment. The merchant then needs extra controls so the two cannot be matched. The council's own recommendation is simpler. Hashing is for cases where the number is never needed again, and in those cases it advises removing the number altogether.
A token is a random stand-in
Tokenization works differently. The PCI council's tokenization guidelines from 2011 list three ways to make a token. The first derives it from the card number with an encryption key. Encryption scrambles data so that only someone with the key can unscramble it. The second derives the token with a one-way function, such as a hash mixed with a secret value. That secret value is called a salt. The third assigns a random value and keeps a lookup table. The third is the classic vault design. The token is drawn at random, so no amount of computing on it reveals the number. The only way back is to ask the system that holds the table.
That table is the vault. The guidelines call it the card data vault, the central repository that maps tokens to card numbers. Turning a token back into a number is called detokenization. Once a merchant's order system, customer database, reporting tools and backups hold tokens, a thief who copies those systems gets values that mean nothing without the vault.
Many tokens keep the shape of a card number, because tokenization is meant to preserve the type and length of the data so that existing software keeps working. VGS's own setup workshop has the engineer choose a format called “Payment Card - Format Preserving, Luhn Valid”.
Card-shaped tokens come from a limited set of values, which is one reason a vault has to be a database. Suppose N tokens are drawn at random from S possible values. There are about N2/2 pairs of tokens, and any one pair matches with probability 1/S, so the expected number of matching pairs is about N2/2S. Take N = 1010 tokens and S = 1016, all the strings of 16 digits. The result is 1020 ÷ (2 × 1016) = 5,000 matching pairs. Two cards must never share a token, so the vault has to check each new token against the table before it issues it. The numbers are my own example.
“…the data vault often presents the most attractive target for attackers.”
PCI DSS Tokenization Guidelines, PCI Security Standards Council, August 2011
How a vault like VGS keeps the number off your servers
The simple way to use a vault is an API call. An API call is a request that one program sends to another. The merchant's server receives the card number, sends it to the vault, and stores the token that comes back. For a moment the number is on the merchant's server. The guidelines say tokenization helps by reducing the number of systems PCI DSS applies to, and a server that sees the number is still one of those systems.
VGS, short for Very Good Security, puts the vault in the network path. A proxy is a server that sits between the two ends of a connection and passes their traffic along. This kind also rewrites what passes through. VGS's documentation describes two. An inbound route sits in front of the merchant's server. When a shopper submits a card, the proxy stores the number in the vault and passes the request on with a token in its place. VGS calls its tokens aliases. An outbound route sits between the merchant's server and third parties. When the merchant sends a charge to its payment processor, the proxy swaps the alias for the real number in transit.
The merchant's code handles card payments from start to finish. In the words of VGS's documentation, sensitive data “never hits your systems”. Figure 5 follows one payment through both proxies.
Two things follow from this design. The first is that the merchant can change payment processors without asking the old one to hand over its card file, because the vault belongs to neither. Lock-in means a customer cannot leave a supplier without heavy cost. Sam Boboev's Fintech Wrap Up deep dive on payment stacks with several processors describes a processor's own tokens as proprietary lock-in, because they work only inside that processor's systems. He recommends a token vault that is not tied to any provider.
The second is that the merchant's security work moves from guarding 16-digit numbers to guarding the rules that decide which outbound requests get a real number put back in. Part 4 comes back to those rules.
VGS is one of several independent vault companies. Basis Theory describes its vault as designed for merchants that use several processors, and IXOPAY sells a vault whose tokens work with any processor. VGS says its infrastructure secures over a third of the world's e-commerce transactions. That is a company claim, and I could not check it independently.
Tokens without a vault
There is also a way to make a reversible token with no table. Format-preserving encryption, or FPE, encrypts a 16-digit number into another 16-digit number under a secret key. The Wikipedia article on tokenization describes this as stateless tokenization, because nothing has to be looked up in a database.
A permutation is a rearrangement of a set in which every item goes to exactly one place and no two items share a place. FPE is a permutation of all the digit strings of one length, and the key decides which permutation. Take a toy version on single digits. One key might send 0 to 7, 1 to 3, 2 to 9 and so on, using each digit once. Whoever knows that table can read it backwards. Real FPE does the same to all 1016 strings of 16 digits without writing the table down. The toy table is mine.
Its record is mixed. NIST is the US National Institute of Standards and Technology, the agency that publishes the federal government's encryption standards. It approved two methods, FF1 and FF3, in 2016. Its February 2025 draft revision no longer specifies FF3. The draft cites a weakness, described by the researcher Beyne, that affects FF3 and not FF1. The domain of a method is the set of all its possible inputs, and the same draft increases the domain size it requires for FF1. The PCI guidelines add that a token derived from the number with a key is effectively an encrypted card number. Whoever gets the key can turn every token back at once. A random token has no such key, and its secret is the table.
Three cases
Three cases show what a vault token covers and what it leaves.
Capital One
In July 2019 Capital One disclosed that an intruder had taken data on about 100 million people in the United States and 6 million in Canada. The bank said it encrypts data as standard, and that the access gained in this incident also allowed the data to be decrypted. It also tokenizes selected fields, mainly Social Security numbers and account numbers, with a method and keys separate from those used for encryption. Its statement on those fields was “Tokenized data remained protected.” About 140,000 Social Security numbers were compromised, and the bank said more than 99% were not.
Revolve
The fashion retailer told the Securities and Exchange Commission on October 29 that an unauthorized actor may have obtained, “through automated means”, the name, contact information, card number and card expiration date of customers who saved payment information in their online accounts. According to SecurityWeek, the intrusion began on September 11, Revolve discovered it on September 29, and it reported 1,515,073 affected people to Indiana's attorney general. The filing does not say how the numbers were stored.
AI agents against online shops
The security startup Gambit, as reported by BleepingComputer, found an operator running three open-source AI agent tools against online retailers from at least July. In five days in September the agents compromised at least 27 companies. They took more than 600,000 valid card records from two of them. On the websites of five others they placed skimmers. A skimmer is a script that copies card details as customers type them. An instruction file told one agent to wipe the card fields in the source database after downloading them. Gambit put the cost at about $25 per target.
A vault token does one thing well. It takes card numbers out of the merchant's stored data. The number still passes through the checkout page on the way in, and it still goes to the processor, the card network and the issuing bank on the way out. Network tokens, in Part 3, change what travels along that second stretch.
Continue to Part 3: Network tokens