Dev.to Security 🔐 Cybersecurity 👁 0

Sanitizing PDFs Before Uploading to ChatGPT or Claude: Stripping Aadhaar, PAN & XMP Metadata Offline

Millions of professionals upload resumes, tax forms, and contracts directly into ChatGPT, Claude, or Gemini every day — without realizing that PDFs often contain hidden XMP author metadata and selectable PII (Aadhaar num

Millions of professionals upload resumes, tax forms, and contracts directly into ChatGPT, Claude, or Gemini every day — without realizing that PDFs often contain hidden XMP author metadata and selectable PII (Aadhaar numbers, PAN IDs, phone numbers).

Even worse, drawing a black rectangle in a standard PDF viewer only hides the pixels visually while leaving the underlying text stream 100% readable to AI parsers.

How Client-Side PDF Sanitization Works

Using WebAssembly (pdf.js + pdf-lib), you can sanitize any PDF in local browser RAM before uploading it to an LLM:

  1. Regex PII Detection: Scan the PDF text layer locally for 12-digit Aadhaar patterns, 10-character PAN IDs, and phone numbers.
  2. 200 DPI Raster Burn-In: Render affected pages to an HTML5 Canvas, burn permanent black boxes over the coordinates, and rebuild the PDF without the underlying vector text layer.
  3. Metadata Scrubbing: Strip Title, Author, Subject, Keywords, and Creator XMP traces.
  4. Post-Mask Cryptographic Audit: Re-scan the exported PDF bytes to verify 0 remaining PII patterns.

Try the free open-source tool (GNU AGPL-3.0, 0 server uploads): Sanitize PDF for ChatGPT / AI

Benchmarks & dataset: PDFCraft 10-Document Benchmarks | Source: GitHub

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.