Aadhaar, PAN, GSTIN and UPI: PII Detection Patterns for Indian Databases
A working reference for detecting Aadhaar, PAN, GSTIN, UPI and IFSC identifiers in Indian production databases: formats, checksum validation, false-positive behaviour and column-name heuristics.
Team Qarbix · · 7 min read
Security & Compliance

Every commercial data loss prevention tool ships with detectors for US Social Security numbers and EU passport formats. Support for Indian identifiers ranges from absent to badly wrong. If you are trying to find out which columns in your production database contain personal data before the DPDP compliance deadline, you will almost certainly have to build the detectors yourself.
This is a working reference for the five identifiers that matter most in Indian systems: Aadhaar, PAN, GSTIN, UPI virtual payment addresses and IFSC codes. It covers the format, the validation logic beyond the regex, realistic false-positive behaviour and the column-name heuristics that make discovery practical at scale.
A note on scope: this is about finding identifiers inside databases you own and are responsible for protecting. Detection is the first step of masking them.
Why regex alone produces unusable results
A naive twelve-digit pattern for Aadhaar matches order IDs, transaction references, device identifiers, timestamps in microseconds and a large fraction of anything numeric. Run it across a production schema and you get thousands of hits, an engineer who stops trusting the tool, and a discovery exercise that is quietly abandoned.
Usable detection needs three layers stacked together: a format pattern, a structural or checksum validation, and a contextual signal from the column name or surrounding data. Any one alone is noise. All three together produce a list short enough that a human will actually review it.
Aadhaar
Format
Twelve digits. The first digit is never 0 or 1, because the numbering scheme reserves those ranges. Commonly stored with spaces or hyphens in groups of four, so normalise before matching.
Pattern after stripping separators: ^[2-9][0-9]{11}$
Validation
Aadhaar numbers carry a Verhoeff checksum over all twelve digits, where the twelfth digit is the check digit. Verhoeff is a dihedral-group algorithm implemented with three lookup tables: a multiplication table, a permutation table and an inverse table. Implementations are short and available in every common language.
The checksum is the difference between a detector that is useful and one that is not. In testing against mixed transactional data, the bare twelve-digit pattern produced roughly one true positive for every several hundred matches. Adding the leading-digit constraint cut that sharply. Adding Verhoeff validation reduced false positives by well over ninety percent, because arbitrary twelve-digit values pass a valid Verhoeff check only about one time in ten.
Column heuristics
Match column names case-insensitively against aadhaar, aadhar, adhaar, uid, uidai, and the frequently used euphemism govt_id or government_id. Misspellings are extremely common in real schemas and a detector that only matches the official spelling will miss production tables.
PAN (Permanent Account Number)
Format
Ten characters: five letters, four digits, one letter. Pattern: ^[A-Z]{5}[0-9]{4}[A-Z]$
Structural validation
PAN has no checksum, but it has meaningful internal structure that acts as one. The fourth character encodes the holder type and is drawn from a fixed set: P for individual, C for company, H for Hindu Undivided Family, F for firm or LLP, A for association of persons, T for trust, B for body of individuals, L for local authority, J for artificial juridical person, G for government. The fifth character is the first letter of the surname for an individual, or of the entity name otherwise.
Constraining the fourth character to that set is a cheap and effective filter. It eliminates most random alphanumeric strings, product SKUs and internal reference codes that would otherwise match the shape.
A tighter pattern: ^[A-Z]{3}[ABCFGHJLPT][A-Z][0-9]{4}[A-Z]$
Column heuristics
pan, pan_no, pan_number, pan_card, tax_id, income_tax_no. Also check KYC document tables where a generic document_number column holds mixed identifier types distinguished by a document_type field. Those columns need per-row detection rather than per-column classification, and they are the ones most commonly missed.
GSTIN
Format
Fifteen characters, built compositionally: a two-digit state code (01 to 38), the ten-character PAN of the entity, a one-character entity number for that state, the literal letter Z in the fourteenth position, and a final check character.
Pattern: ^[0-3][0-9][A-Z]{5}[0-9]{4}[A-Z][1-9A-Z]Z[0-9A-Z]$
Validation
GSTIN uses a modulo-36 weighted checksum across the first fourteen characters, with alternating weights of 1 and 2 and digits mapped 0 to 9 and letters A to Z as 10 to 35. The fixed Z at position fourteen and the embedded PAN structure already make this pattern highly specific; the checksum takes it close to zero false positives.
GSTIN is business data rather than personal data for a company, but for sole proprietors it identifies an individual. Treat it as personal data unless you can establish otherwise for a given table.
UPI virtual payment address
Format
A local part, an at sign, and a handle. Pattern: ^[a-zA-Z0-9.\-_]{2,256}@[a-zA-Z]{2,64}$
The obvious problem is that this also matches email addresses. Disambiguation relies on the handle: UPI handles are a bounded, known list published by NPCI, including okhdfcbank, oksbi, okaxis, okicici, ybl, paytm, apl, ibl, axl and others. Match against that list rather than trying to distinguish structurally.
A second signal: a very common UPI local part is a ten-digit Indian mobile number, which almost never appears as an email local part.
Indian mobile numbers and IFSC codes
Mobile: ten digits beginning 6, 7, 8 or 9, optionally prefixed with +91, 91 or 0. Pattern after normalisation: ^[6-9][0-9]{9}$. This is high-recall and moderate-precision; ten-digit numeric columns are common. Column-name context does most of the work here.
IFSC: eleven characters, four letters for the bank, a mandatory 0 in the fifth position, then six alphanumeric characters. Pattern: ^[A-Z]{4}0[A-Z0-9]{6}$. The fixed zero makes this unusually specific and it rarely produces false positives.
Making discovery practical
Scanning every row of every table is not viable on a production system. A workable approach samples: pull a bounded random sample per column, run the layered detectors, and classify a column as containing personal data when the validated match rate crosses a threshold rather than on a single hit. This keeps the scan cheap and produces a stable classification you can act on.
Run detection against the schema on a scheduled basis, not once. New columns appear constantly, and the personal data problem in most organisations is not the customers table everybody knows about. It is the support ticket export, the debug log table, the abandoned migration staging table and the analytics copy nobody owns.
How Qarbix DataGuard helps
DataGuard performs sensitive data classification across connected databases and then, critically, connects that classification to enforcement. Detection that produces a report is a compliance artefact; detection that automatically drives a masking policy is a control.
Classification identifies which columns hold personal data, including Indian identifier types that generic tooling misses.
Classified columns feed directly into dynamic masking rules, so an analyst sees a masked value while a billing administrator sees the full one, without either of them changing their query.
Re-scanning on a schedule catches the new columns and forgotten tables that manual inventories never reach.
Because DataGuard runs self-hosted, the scan and its results stay inside your infrastructure. Sending a sample of production data containing Aadhaar numbers to a vendor cloud in order to classify it is a poor trade.
Frequently asked questions
What is the Aadhaar checksum algorithm?
Aadhaar uses the Verhoeff algorithm, a dihedral-group checksum, computed across all twelve digits with the last digit serving as the check digit.
Can you validate a PAN number without calling an API?
You can validate its structure offline: the ten-character shape and the constrained fourth character indicating holder type. Confirming that a structurally valid PAN actually exists requires the income tax department's verification service.
Is a GSTIN personal data under the DPDP Act?
For an incorporated entity it is business information. For a sole proprietor it embeds the proprietor's PAN and identifies an individual, so it should be treated as personal data absent a clear determination otherwise.
How do you tell a UPI ID from an email address?
By the handle. UPI handles come from a bounded list of NPCI-registered payment service provider handles, so matching against that list is far more reliable than any structural rule.
Tags
#database security, #database governance
Written by Team Qarbix, the engineers who build CloudLens and DataGuard.