Guide
·
Data

How to Discover PII in Unstructured Data: PDFs, Email, and Shared Folders

Find Aadhaar, PAN and other PII hiding in PDFs, scans, mailboxes and shared folders: OCR, pattern and checksum checks, accuracy tests and a triage plan.

Chief Product Officer
Published
November 23, 2026
Reading time
15
min

My PII audits usually start the same way. The core database is locked down, encrypted and logged. Then I ask where last year's KYC scans went, and someone opens a shared mailbox full of attachments nobody has looked at in years. In late July 2026, Bank of Baroda said a data leak came from the "compromise of an employee's email account, resulting in unauthorised access to certain data", and that its core banking systems were not accessed. Two months earlier, the UK's data protection regulator reprimanded a police force after spreadsheets it published carried hidden raw data on at least 436 people. Neither problem sat in a database. If you are trying to find PII in unstructured data, such as PDFs, scans, mailboxes and shared folders, read on. You will leave with a five-step method I use, the checks that separate a real identifier from a random number, and a triage plan for what you find.

TL;DR

  • Unstructured stores hold the copies your database controls never see: KYC scans, loan PDFs, CV attachments, CSV exports and screenshots in tickets.
  • Get the text out before you detect anything. Native files need their hidden sheets and embedded objects read, and scans need OCR at a quality you have tested.
  • A 12-digit match isn't an Aadhaar finding until the check digit passes and a keyword sits nearby. Treat pattern-only hits as leads.
  • Measure the scanner on a hand-reviewed sample before you delete or move a single file, then triage each finding to delete, move, mask or restrict, with an owner.

Why Unstructured Data Is Where PII Hides

Structured systems get the attention because they have schemas, owners and access reviews. Files have none of that. A relationship manager emails a customer's PAN card to the credit team. Operations exports a loan book to CSV to check one branch's numbers. HR saves every CV that ever came in. A support agent asks a customer to upload a photo of an ID to prove who they are. Each copy is legitimate on the day it's made, and almost none of them gets deleted.

The worst stores I see in Indian companies are scanned KYC packs from before the bank or NBFC went digital. Paper was scanned in bulk, dropped into a shared folder by branch code and forgotten. That folder is now in scope. Section 3(a) of the DPDP Act reaches personal data gathered "in non-digital form and digitised subsequently", on top of anything born digital. Your scanned paper is digital personal data.

DPDP Act section 3(a)(ii) marked: data collected in non-digital form and digitised later is in scope
Marked: section 3(a)(ii), personal data collected "in non-digital form and digitised subsequently". DPDP Act 2023, MeitY PDF, 21 November 2026.

The dates matter for your plan. Section 8(5), which requires reasonable security measures including at your processors, applies from 13 May 2027, along with section 8(7) on erasure and Rule 6 on the minimum measures. Getting those measures wrong can cost up to ₹250 crore under item 1 of the Schedule. No Indian enforcement case exists yet, so the only precedents come from other regulators. If you start the scan now, you have time to clean up before the duty bites.

If you want the general discovery process first, our data discovery guide covers it. This post is about the file stores that guide doesn't reach.

Step 1: List the Stores

You can't scan what you haven't named. I list every place a file or message can sit and give each one an owner, an estimate of volume and a note on who can reach it.

Example diagram drawn by Redacto: five steps that take a file store from listing to a delete, move, mask or restrict decision
Marked: the five steps, from listing stores to a triage decision for each finding. Example diagram drawn by Redacto.

My usual list for an Indian bank, NBFC or fintech looks like this:

  • Mail servers and their archives, including shared mailboxes such as kyc@ or hr@ and the journaling archive compliance keeps.
  • Shared folders on file servers, often organised by branch, team or year.
  • Google Drive and SharePoint, including personal OneDrive folders that were shared with a team once.
  • Attachments inside ticketing tools, where customers upload screenshots of IDs and bank statements.
  • Chat files in Slack, Teams or WhatsApp exports kept for disputes.
  • Laptops, especially in collections, sales and HR, where people download files to work offline.

Then rank them. I put the ones that are both large and widely reachable first, because that combination is where a single compromised account does the most damage. A shared mailbox that forty people can open beats a locked archive with ten times the volume. Bank of Baroda's statement is a reminder that one email account can be the whole incident.

Step 2: Get the Text Out

Detection only works on text. Every miss I have traced in a file scan comes back to this step, where the scanner never saw the content in the first place.

Native PDFs and Office Files

Native PDFs, Word files and spreadsheets carry real text, so extraction is cheap. The trap is everything a person doesn't see when they open the file: hidden worksheets, cached summary-table data, comments, tracked changes, embedded objects and metadata. Your extractor has to read all of it.

The ICO's reprimand of Suffolk Constabulary, dated 20 May 2026, shows how that goes wrong. Spreadsheets released in response to Freedom of Information requests contained hidden raw data, and the personal data of not less than 436 individuals was made public. A pre-publication check had looked at the file and missed a secondary worksheet holding the raw records. The force told the regulator that when the sheet was opened, the tabs with the raw data could not be seen.

ICO reprimand of Suffolk Constabulary marked: a pre-publication check missed the hidden worksheet with raw data
Marked: (1) the pre-publication check that failed to find the secondary worksheet with the raw data; (2) the force's explanation that the tabs could not be seen when the file was opened. ICO reprimand, 20 May 2026, ICO PDF, 21 November 2026.

If a trained person looking at the file missed it, a scanner that only reads visible cells will miss it too. When I test an extractor, I give it a spreadsheet with a hidden sheet, a very hidden sheet and a summary table built from personal data, and I check that all three come back as text.

Scans and Photos

Scanned KYC copies and phone photos of IDs are images. Nothing finds an Aadhaar number in an image until OCR turns it into text, and the quality of that OCR caps everything that follows.

Tesseract works best on images of at least 300 dpi, and a skewed page sharply reduces the quality of its line segmentation. Old branch scans fail on both counts. They were often scanned at low resolution to save disk, fed in at an angle, and photocopied twice before that. Mixed Hindi and English text adds another failure point, so load both language models and test on real samples from your archive.

My rule is to split OCR results from native text in every report. If a scanner tells me it found 3,000 Aadhaar numbers across a share, I want to know how many came from images, because that is the number I trust least.

Email Bodies, Attachments and Archives

Email is three problems in one. The body is text. The attachments are files, each needing Step 2 on its own. The archive formats hide both: a PST file holds thousands of messages, a ZIP holds a folder of scans, and a forwarded message holds another message with its own attachments.

Your extractor has to open containers recursively and keep a record of the path, such as mailbox, message, attachment and file inside the ZIP. Without the path, a finding is useless, because nobody can go and fix it. I also set a depth limit and log anything that hits it, since a deeply nested archive is often exactly where an old export ended up.

Step 3: Detect, With More Than a Regex

Once you have text, you can look for PII. The common mistake is to stop at a regular expression. A regex finds strings with the right shape. It doesn't tell you whether the string is an identifier.

Indian Identifiers

Aadhaar is the clearest example. Microsoft defines the Aadhaar pattern as 12 digits, the first not 0 or 1, with optional spaces or dashes, ending in a check digit. For high confidence it requires three things within 300 characters: the pattern, a keyword such as "aadhaar", "uid" or आधार, and a passing checksum. A pattern with a checksum and no keyword drops to medium confidence.

Microsoft Purview Aadhaar definition marked: the 12-digit pattern, plus a keyword and checksum within 300 characters
Marked: (1) the 12-digit pattern ending in a check digit; (2) high confidence, which needs the pattern, a keyword and a passing checksum within 300 characters. Microsoft Learn, 21 November 2026.

I agree with that design and I apply it to every tool, including ones I build. Loan account numbers, policy numbers, invoice references and phone numbers with a country code all produce 12-digit strings. In my experience the checksum removes most of them, and the keyword removes most of what is left. A 12-digit string that fails the check digit isn't an Aadhaar number, whatever the regex says.

The open source Presidio recognizers follow the same idea. Presidio detects IN_AADHAAR by "Pattern match, context, and checksum", and ships recognizers for PAN, voter ID, passport, GSTIN and vehicle registration.

Presidio India recognizers marked: IN_AADHAAR uses pattern match, context and checksum
Marked: the IN_AADHAAR row, detected by pattern match, context and checksum. Presidio supported entities, 21 November 2026.

PAN has a defined structure. The Income Tax Department explains that it has ten characters: three letters in a series from AAA to ZZZ, a fourth letter for the holder's status (P for an individual, C for a company, and others), a fifth letter from the surname or name, four sequential digits and an alphabetic check digit. That gives a tight pattern, `[A-Z]{3}[ABCFGHJLPT][A-Z][0-9]{4}[A-Z]`, and a useful filter. If you are looking for customers' PAN, a P in the fourth position tells you it belongs to an individual.

GSTIN is fifteen characters built from a state code, the PAN, a registration number, the letter Z and a checksum, so it carries a PAN inside it. Decide up front whether you want those reported as PAN findings, because a vendor master file will light up otherwise. Voter IDs are ten alphanumeric characters, and passports have their own format. For cloud stores, Google ships detectors for Aadhaar, GST, PAN and passport numbers.

Google Sensitive Data Protection infoTypes marked: the four Indian detectors for Aadhaar, GST, PAN and passport numbers
Marked: the INDIA_AADHAAR_INDIVIDUAL, INDIA_GST_INDIVIDUAL, INDIA_PAN_INDIVIDUAL and INDIA_PASSPORT detectors. Google Cloud documentation, 21 November 2026.

Our post on automated sensitive data detection gives a broader view of pattern recognition. For Indian identifiers, my position is simple: no finding counts until a checksum, where one exists, and a nearby keyword back up the pattern.

Names, Addresses and Phone Numbers

Names and addresses have no pattern and no check digit, so regex is the wrong tool. Entity recognition models find them by context, and they make different mistakes from pattern matchers. Indian names that are also common words, addresses written without commas and transliterated names all cause misses.

I use context words to tighten these too. A ten-digit mobile number near "mobile", "contact" or "ph" is far more likely to be personal than one in a column of order IDs. A name next to "father's name" or "nominee" on a form is almost certainly personal data about someone other than the account holder, which is worth knowing when you decide what to do with the file.

Sensitive Documents as a Whole

Some files are sensitive because of what they are, whatever fields a scanner picks out. A KYC pack, a medical report, a salary slip or a bank statement is personal data from top to bottom. I classify the document type as well as the fields, so a scanned salary slip with an unreadable PAN still gets flagged as a salary slip.

Document classification also helps triage. Our guide to classifying personal data sets out classes that work well as the labels you attach here, so a finding arrives with a class and not only a field name.

Step 4: Measure Accuracy Before You Act

I never let a team delete or move files on a scanner's word alone. Before any action, take a sample and check it by hand.

Mock-up drawn by Redacto with invented test data: false positives and misses on a 200-file sample, native files versus scans
Marked: false positives and misses on a 200-file sample, split by native PDFs and scanned copies before and after cleanup. Mock-up drawn by Redacto with invented test data.

Here is how I run it. Pick around 200 files from one store, mixing native files and scans in roughly the proportion the store holds. Have a reviewer open each file and record every Aadhaar, PAN and other identifier they see. Then compare against the scanner's output and count two numbers. False positives are hits the reviewer rejects. Misses are identifiers the reviewer found that the scanner didn't.

The confirmed rate tells you how much of your triage queue is noise. The miss rate tells you how much PII will still be sitting in the store after you finish. Report both, separately for native text and for OCR, because they behave differently. In the mock-up above, the native files look excellent once the checks are on, while a third of the scans with identifiers in them were missed until the images were cleaned up.

My own target, which is a recommendation and nothing more formal, is a confirmed rate above 90% on native text before I let anyone act on findings, and a miss rate on scans that the data owner has seen and signed off. If OCR misses are high, fix the images or rescan before you trust a clean result from that store.

Remember that the review sheet itself now holds personal data. Keep it in the same controlled place as the findings and delete it when the exercise closes.

Step 5: Triage What You Find

Every confirmed finding needs a decision and an owner. I use five outcomes.

  1. Delete. If the file has no current purpose and no law requires you to keep it, delete it, and record what you deleted, from where and on whose approval. Section 8(7) requires erasure once the purpose is served, from 13 May 2027.
  2. Move to a controlled store. If you must keep it, such as KYC records within their legal retention period, move it out of the shared mailbox into a store with access control and logging.
  3. Mask. Where the file has to stay in place for a business reason, mask the identifier. Rule 6(1)(a) lists "encryption, obfuscation, masking or the use of virtual tokens mapped to that personal data" among the minimum measures.
  4. Restrict access. Some stores can't be cleaned quickly. Cut access down to the people who need it while you work through the backlog. Rule 6(1)(b) asks for measures to control access to the computer resources involved.
  5. Add to the inventory. Whatever you decide, record the store, the data type, the volume and the owner in your data inventory.

Retention periods decide whether a file can go. Check the period for each record type before you delete, and stop if a legal hold applies. Our data minimisation guide explains why deleting what you don't need is the cheapest risk reduction you have.

One more control I add at this step: limit who can view the contents of findings. In Microsoft Purview's content explorer, seeing the list of items and seeing their contents are separate role groups. Give most reviewers the list role, and keep the content role for the few who actually need to open files.

Keep It Clean

A one-off scan decays within months. New attachments arrive every day, and someone will export a customer list to a shared folder next week. Four habits keep the store from refilling.

  • Stop it at the point of entry. Data loss prevention rules on email and uploads can warn or block when an Aadhaar or PAN is attached to an outgoing message or dropped into a broadly shared folder.
  • Set retention rules on the stores. Mailboxes and shared folders can delete by age. A rule that removes KYC attachments from a shared mailbox after a set period does more than a yearly clean-up campaign.
  • Rescan on a schedule. I rescan high-risk stores at least quarterly, and immediately when a new system or shared folder starts holding customer files.
  • Get the owner to sign off. Each store's owner confirms the findings and the actions once a quarter. That signature is what turns a scan into a control.

Feed every new store and finding into your data inventory, so the next audit starts from a list.

Where Tools Fit

You can build this with open source. OCR from Tesseract, recognizers from Presidio, your own extractors for mail and archives, and a review sheet will get a small team a long way, and I'd tell any engineering team to do it once just to understand the failure modes.

The build gets hard at scale. Recursive extraction across mail archives, OCR tuning per document type, keeping recognizers current, and tracking findings to owners all take continuing effort. That is when teams buy.

When you assess vendors, the security and compliance features enterprises should demand from unstructured data management vendors are the ones this method needs: OCR you can measure, Indian identifiers checked by checksum and context, findings tied to a path and an owner, scanning that keeps your files inside your environment, and role-based access to the findings themselves. Ask each vendor to run your 200-file sample and show you the confirmed rate and the misses on it.

Our rankings of PII discovery tools and data discovery tools compare the products on that job.

What to Do, by Situation

A Bank or NBFC With Years of Scanned KYC

Start with the shared folders and mailboxes that held branch scans, and run the accuracy check on scans before anything else, since OCR will be your weakest link. Separate records still inside their KYC retention period from those past it. Move the first group into a controlled store and delete the second with a record, after confirming no legal hold or open dispute applies.

An HR Team With Candidate CVs in a Shared Mailbox

CVs carry names, phone numbers, addresses, dates of birth and sometimes ID numbers, and most of them belong to people you never hired. Agree a retention period for unsuccessful candidates, delete everything older, and move the rest out of the mailbox into the applicant system. Then stop the problem at entry by routing new applications away from a shared inbox.

A Support Team With Screenshots of Customer IDs in Tickets

Ticket attachments are images, so this is an OCR job. Scan the attachment store, mask or delete ID images once the verification they supported is complete, and change the process so agents verify identity without asking for a photo of the document. If the ticketing tool can delete attachments by age, switch that on.

FAQs

What counts as unstructured data?

Files and messages with no fixed schema, such as PDFs, scans, emails, chat files and documents in shared folders.

Can a scanner find Aadhaar numbers in scanned images?

Yes, if it runs OCR first. Accuracy depends on scan quality, so test it on a sample of your own files before you rely on it.

Why do Aadhaar searches return so many false matches?

Any 12-digit number can match the pattern. A check digit test and a nearby keyword cut most of those out.

Does DPDP cover old paper records we scanned?

Yes. Section 3(a) covers personal data collected on paper and digitised later.

What should we do with KYC copies nobody needs?

Check the legal retention period first. If it has passed and no hold applies, delete them and record the deletion; if not, move them to a controlled store.

How often should we rescan?

At least quarterly for high-risk stores, and whenever a new system or shared folder starts holding customer files.

Find It Before Someone Else Does

The PII that hurts you is rarely in the system you audit every year. It is in the mailbox a team shares, the folder of scans nobody opens and the spreadsheet with a sheet nobody can see. List the stores, get the text out properly, detect with checks, measure before you act and give every finding an owner. If you want that done across file shares, shared folders and scanned documents with Indian identifiers classified as their own types, see how Redacto handles data discovery and classification.

Related Reading

Get the practical version, monthly.

One email a month on what changed in Indian privacy practice.

One email a month. Unsubscribe in one click.
You are on the list. The next issue lands at the start of the month.
That did not go through. Check the email address and try again.
See it against your own data

Thirty minutes. We map one of your processing activities end to end.

Book a demo