PCI DSS applies to every system component that stores, processes or transmits cardholder data, and to everything connected to those components. The fastest way to make an assessment smaller is not to defend more systems but to make fewer systems see a real card number. This post works through that on the fictional Northmere Bank: where its card numbers live, how they are masked for the people who read them, tokenized for the systems that only need a stand-in, made unreadable where nobody needs them, and what InsightAIShield’s PCI DSS v4.0 evidence says is met and what is still partial.
In short
- Find every PAN first. The read-only harvest and the classifier find 4 card-number columns across the cards platform and the lake, plus the CVV and expiry columns next to them.
- One policy for cardholder data.
pci_cardholder_datamasks card numbers to the last four, makes CVV unreadable, refuses destructive commands and refuses joining cards to disputes. - Tokens where a stand-in will do. Format-preserving tokens keep the last four and the shape, so look-ups and joins work on systems that never hold a PAN.
- Evidence from the records. Seven PCI DSS v4.0 requirements are computed from what the product holds: in the demo 3 are met and 4 partial, each with the figures and the note that says what would close it.
Scope follows the card number
An assessor scoping a PCI DSS environment asks the same question of every database, warehouse, file store, report and application: can a full primary account number (PAN) reach it? If yes, it is in scope, with everything that implies for access control, logging, change management and testing. If a component only ever sees a masked value or a token that cannot be turned back into a PAN without a separate, controlled system, the argument for keeping it out of scope is much stronger.
So scope reduction is three practical jobs, in order:
- Know where PANs are. Not where the data dictionary says they are: where the bytes actually are, including exports and copies nobody documented.
- Decide, per reader, what they get. Most people who read card tables need the last four digits. Some systems need a consistent stand-in. Very few need the full number, and only for a stated reason.
- Prove it. Show the assessor the policy, the decisions it made and the record of who saw a clear value and why.
Three jobs: find, decide per reader, prove. Every step writes the record the evidence is computed from.
Step one: where Northmere’s card numbers are
Northmere’s estate has four sources: core banking on PostgreSQL, a cards platform on MySQL, a warehouse
on Snowflake and a data lake on S3. The discovery scout harvests each catalogue read-only, through a
secret reference rather than a pasted password, and the classifier looks at every column three ways: its
name, its values and its type. For card numbers the value check is strict. A sample must pass the Luhn
checksum and carry a plausible issuer prefix, and a four-byte integer column is never a card number
whatever it is called. A column named card_no full of values that fail Luhn is lowered, not
raised.
The result for card data: 4 card-number columns. Three are on the cards platform
(cards.card.pan, cards.authorization.card_pan and
cards.dispute.card_pan), and the fourth is in the lake, in an export table
(northmere_lake.exports_cards.pan) that someone wrote for a partner file. That fourth one is
the reason discovery comes first: it is exactly the kind of copy that widens scope without anyone
deciding it should. Next to the PANs sit the card security code (cvv2) and expiry dates,
which the classifier marks as PCI too.
Step two: one policy for cardholder data
Northmere’s cardholder-data policy is short. It grants read on the cards platform and the lake to the groups that work with cards, and then adds four rules:
| Rule | Target | Effect |
|---|---|---|
MASK | class:card_number | Every card-number column, wherever it is, comes back with only the last four digits in clear |
BLOCK_FIELD | class:card_cvv | The security code can’t be read at all; a query that asks for it is refused |
SQL_COMMAND | cards_mysql | DELETE, DROP, TRUNCATE, UPDATE and ALTER are refused on the cards platform |
DISALLOW_JOIN | cards.card | The card table may not be joined with the dispute table in one query |
Two design choices matter for PCI. The mask targets a data class, not a column list, so a card-number column that appears next month in a new export table is covered the day the classifier finds it and a person confirms it. And the policy was written by the data security lead, proposed by her, and activated by the administrator: a lead who neither wrote nor proposed a version is the one who activates it. The version page keeps both names and the version’s hash.
What a card-operations analyst actually gets
Masking happens inside the query. When a card-operations analyst runs select pan, holder_name from
card on the cards platform, the engine checks the analyst’s grants, finds the mask on pan, and
rewrites the SQL in MySQL’s own dialect so the database returns twelve asterisks and the last four
digits. The rewrite happens where the base column is read, so an alias, a subquery or a CONCAT
in an outer query can’t undo it. The analyst sees enough to confirm a card with a customer, and the
report server, the spreadsheet and the laptop the analyst exports to never hold a full PAN.
The same policy behind the PostgreSQL wire proxy or the query gateway produces the same decision with the SQL rendered for that dialect. Nothing about the application changes: it connects to the proxy’s address instead of the database’s, and the masking travels with the data class.
Systems that need a stand-in, not a number
Masking suits people. Systems that link records or pass a card reference along need something consistent:
the same card should always give the same value, so that a dispute can still be matched to its
authorization. That is what tokens are for. With the NUMERIC_SAME_LAST_FOUR format, a card
number becomes another sixteen-digit number with the same separators and the same last four. In FPE mode
it is computed with FF1 or FF3-1 under a key the vault only knows by reference, with a tweak derived from
the column’s scope; in vault mode it is random and the value is sealed with AES-GCM. Either way the
system holding the token holds no PAN.
A TOKENIZE rule can also apply this on the way out: the query is unchanged and the result set
carries tokens. That is how a reporting feed or an AI agent reads card-adjacent data without becoming a
PAN-holding system.
When someone does need the clear number, for example to fill in a card network’s chargeback form, they ask the vault. The request needs a purpose in words, a person allowed to see that scope in clear, and stays under an allowance of 1,000 tokens per 60 minutes per person by default. In the demo the administrator’s request for chargeback 7781 was allowed and revealed 2 values; an analyst’s request “for a customer call” was refused. Both are on the record.
Card numbers in clear in the cards database, its exports, the lake copy, the reports and every analyst’s download. Each is a component the assessment must cover.
Readers get the last four; systems get tokens; the clear value comes back only through a recorded, purpose-stated detokenize. Fewer components ever hold a PAN.
Step three: the evidence, requirement by requirement
The compliance page maps seven PCI DSS v4.0 requirements to what InsightAIShield records, and computes each one’s status from those records. A requirement is never marked met without evidence, and each one carries a note in plain words. On Northmere’s demo the framework shows 3 met and 4 partial:
| Requirement | Status | What the product shows |
|---|---|---|
| 3.4.1 PAN is masked when displayed | Met | 4 card-number columns found, 4 protected by an active policy |
| 3.5.1 PAN unreadable where stored | Partial | Tokens in the vault and 2 active keys; the note says masking at query time doesn’t make stored PAN unreadable: tokenize it at rest |
| 7.2.1 Least privilege | Partial | 1 access review campaign; 2 of 55 grants reviewed, 2 revocations approved with four eyes |
| 10.2.1 Audit logs capture access | Met | Every query recorded with user, client address, objects, rows, decision and policy; 8 enforcement and monitor points |
| 10.4.1 Logs reviewed for anomalies | Partial | 7 anomalies scored; 1 critical or high still open; SIEM batches held for release |
| 12.10.1 Incident response followed | Partial | Incidents scored, investigated and decided by a person, with four eyes on high and critical |
| 6.5.1 Changes reviewed and approved | Met | Every active policy version activated by a second person |
The partial on 3.5.1 is the most useful line on the page. Masking on read covers display; it does not change the bytes on disk, and the page says so. The fix is concrete: tokenize the stored PAN columns with the vault’s keys, which also makes those copies something other than PAN. The compliance evidence agent prepares the narrative for the pack from these records, and a person signs it off; the mapping is an aid for the people who sign, not an assessor’s opinion.
Read-only, through secret references. Confirm the card-number and CVV columns; send close calls to the review queue.
Mask by data class, block CVV, deny destructive commands. Simulate it on last week’s queries first.
Applications connect to the proxy or call the gateway; monitor mode on the audit logs shows what would change before anything is enforced.
Exports and lake copies first: they are the copies nobody decided to keep in clear.
Grants against observed use, revocations with four eyes, and the PCI DSS v4.0 pack signed by a person.
Scope shrinks when fewer systems can see a card number, and you can show it.
Discovery finds the copies, a policy on the data class decides what each reader gets, tokens stand in where a number isn’t needed, and the evidence is computed from the same records the engine wrote while it decided.
Where people stay in charge
- The cardholder-data policy was proposed by the data security lead and activated by the administrator: the version page shows both names.
- Every agent action is capped at L2, “ask first”: an agent prepares, and a person confirms, activates, revokes, sends or decides.
- A policy version goes live only when a second lead, not the person who proposed it, approves it.
- A revocation is proposed by one reviewer and approved by another; the REVOKE statement is kept on the record for your DBA to run.
- Detokenizing needs a stated purpose, is recorded, and is capped per person per period.
- SIEM batches and attestation requests are held until a person releases them.