‘We encrypt everything’ will not get you past a security review
Choose encryption, tokenization or masking field by field, and be ready to say who holds the keys, who sees what and how a person’s data is deleted.

In brief
- Each data field needs its own technique. Encryption answers who holds the key, tokenization answers who holds the mapping table, and masking answers who gets to see what.
- Envelope encryption with KMS separates keys from data and logs every use of a key. Have both points ready to present at the review.
- Avoid shuffling and indiscriminate nulling. The pipeline must also be able to delete one person's data, even after it has been masked or tokenized.
“Which systems do customers’ phone numbers pass through, who can read them, and where are the keys?” Say that is the first question on a questionnaire from the client’s security team, and it lands in your second week on site. In this hypothetical case, the pipeline that feeds customer support tickets to an LLM for classification is already running, and the demo went smoothly.
Many engineers answer by reflex: “We encrypt everything.” That tells the security team almost nothing. They need to know how each field is handled, who holds the keys and who can see what.
An FDE should treat clear answers to these questions as part of the job and not leave them to the security team. You understand the pipeline best, so you are the best person to explain it.
This guide covers three tools: encryption, tokenization and data masking. It applies them field by field to the support ticket pipeline, then lists the mistakes that often add weeks to a security review.
Each tool protects data differently
Encryption keeps data intact, and only someone with the key can read it. The question that matters most is therefore where the key is kept. OWASP recommends storing encryption keys separately from the encrypted data where possible. The reason is simple: if the key sits beside the data, whoever steals the disk gets both.
Data masking takes the opposite approach. Wikipedia defines it as modifying sensitive data so that it has little or no value to people without authorized access. AWS puts it in terms closer to engineering work: masking creates a fake version of the data with the same structure as the real one, so developers and analysts can still work with realistic data.
There are two kinds. Static masking is applied to a stored copy of a database, typically for dev or test environments. Dynamic masking is applied at query time.
AWS describes dynamic masking as a filter: the original data stays the same, while what is displayed changes with the viewer’s permissions. It fits well with role-based access control in a client’s systems.
Security tokenization sits between the two. In the design below, the real value is replaced by a random code, and the table that maps codes back to real values is stored separately under tight protection. Downstream systems see only the code, but can still join and count on it.
The two meanings of “tokenization”
This is where AI engineers often get confused in meetings with a security team. NVIDIA explains that tokens in AI are small units of data produced by breaking down larger chunks of information. Converting input data into tokens before a model processes it is also called tokenization.
Tokenization in this sense protects nothing. A phone number that has been through an LLM’s tokenizer is still a phone number, only cut into pieces. When the security team asks “do you tokenize PII?”, they mean it in the security sense.
If your pipeline has both, give them different names in your documentation, such as “LLM tokenizer” and “PII token vault”, so that nobody confuses them.
The support ticket pipeline, field by field
Suppose each ticket has five fields: customer ID, full name, phone number, a bank card number the customer accidentally pasted into the text, and a description of the incident. Some of the company’s customers live in California.
The California attorney general’s office lists several rights under the CCPA, including the right to request deletion of personal information and the right to limit the use and disclosure of sensitive personal information. IBM says the CCPA requires reasonable safeguards, and that the fine for an intentional violation is $7,500.
These two rights bear directly on the design. The right to delete means the pipeline must be able to find and delete one person’s data. The right to limit means you have to consider which fields may travel on to downstream systems or to the LLM. Applying both requirements to each field gives this table:
| Field | Technique | Reason |
|---|---|---|
| Customer ID | Tokenization | Downstream systems still need to join; to delete, remove the mapping row |
| Full name | Dynamic masking | Support staff see the real name; analysts see only the masked one |
| Phone number | Envelope encryption | Someone may need to call the customer back, so it must be reversible |
| Card number in the text | Detect and replace before sending to the LLM | The model does not need a card number to classify an incident |
| Incident description | Static masking in the dev copy | Engineers need realistic data to debug |
For phone numbers, the standard implementation is envelope encryption. According to the AWS KMS documentation, the data key is generated on an HSM and protected by a KMS key. The data key encrypts the data, and the KMS key (acting as the KEK) wraps the data key. This follows OWASP’s recommendation to separate keys from data.
import os, boto3
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
kms = boto3.client("kms")
def encrypt_field(plaintext: bytes, key_id: str) -> dict:
dk = kms.generate_data_key(KeyId=key_id, KeySpec="AES_256")
nonce = os.urandom(12)
ct = AESGCM(dk["Plaintext"]).encrypt(nonce, plaintext, None)
# Store only the KMS-wrapped data key, never the plaintext key
return {"ct": ct, "nonce": nonce, "edk": dk["CiphertextBlob"]}
This approach also gives you something to show at the review. According to AWS, every request made to a customer managed key is recorded as a CloudTrail event. When the security team asks “who decrypted phone numbers last week?”, you can answer with logs instead of promises.
For customer IDs, the key to designing the token vault is to tie each token to an owner. When a deletion request arrives, you can then find all of that person’s tokens before deleting them.
import secrets
def tokenize(owner_id: str, value: str, vault) -> str:
token = "tok_" + secrets.token_hex(16)
vault.put(token, owner=owner_id, blob=encrypt_field(value.encode(), KEY_ID))
return token
def forget(owner_id: str, vault, stores) -> None:
tokens = vault.tokens_of(owner_id)
for store in stores: # main DB, masked dev copy, cache
store.delete_where_token_in(tokens)
vault.delete_by_owner(owner_id) # any leftover token now points nowhere
The order in forget is deliberate. The statically masked dev copy holds no real names or phone numbers, but its customer ID column is kept as a token and is not masked.
You can therefore still find the rows to delete in the dev copy, while the masked columns remain unrecoverable: getting from a token back to a real person means going through the tightly protected vault.
Five steps before the security review
First, build a field-by-field classification table like the one above, including fields you consider harmless. Free text such as an incident description often contains things nobody expected. Second, map the data flow: where each field appears in its original form and where it appears in processed form.
Third, choose where the keys and the token vault will live, separate from the main data store. Ideally, use a KMS managed by the client, so that the power to revoke keys is in their hands.
Fourth, be able to prove it with logs: have a few sample CloudTrail events ready to present. Finally, rehearse a deletion request from end to end, covering the main database, the masked dev copy (finding rows by customer ID token), caches and any logs that contain prompts sent to the LLM.
Mistakes that cost you the security team’s trust
The first mistake is masking by shuffling, or swapping values between rows. Wikipedia notes that this can be reversed if someone works out the shuffling algorithm. Masked data must not be recoverable.
The second is nulling out a whole column because it is quick. The method is simple, but it damages data integrity and reveals that the column has been masked. A dev copy full of nulls also leaves engineers unable to debug anything, and they end up asking for access to the real data.
The third is keeping keys beside the data, such as a plaintext data key in a config file in the same repo. The fourth is masking the identifier column in the dev copy as well, so that when a deletion request arrives nobody knows which row belongs to whom.
The fix is to keep that column as a token, as described above: the sensitive columns are still irreversibly masked, and only the link to the owner goes through the vault.
If you are preparing to apply for FDE roles, read the job description closely for terms such as “PII”, “KMS”, “data residency” or “security review”. On your CV, replace “experienced in data security” with a specific line such as: “Designed envelope encryption and a token vault for a ticket pipeline, passed the client’s security review, and supported per-customer data deletion.”
Plenty of engineers know encryption algorithms. A security team needs someone who can answer three questions for every field: who holds the key, who sees what, and whether deleting a person really deletes everything.
Was this article useful?
Thanks for the feedback!
7 sources
- What Are AI Tokens? The Language and Currency Powering Modern AI · 2025-03-17
- Data masking - Wikipedia
- What is Data Masking? - Static and Dynamic Data Masking Explained - AWS
- Basic concepts - AWS KMS Cryptographic Details
- Cryptographic Storage Cheat Sheet - OWASP
- California Consumer Privacy Act (CCPA) - California Attorney General · 2026-08-28
- What is the California Consumer Privacy Act (CCPA)?