Most RAG pipelines redact the text they see. The problem is that document parsers extract a lot of text that humans never see when they review a file before uploading it:

  • Hidden and "veryHidden" Excel sheets (veryHidden sheets don't even appear in Excel's Unhide dialog)
  • Document metadata: author, last-modified-by, company, comments, custom properties
  • DOCX headers and footers (often contain names, phone numbers, internal ticket IDs)
  • PPTX speaker notes

All of this lands in your chunks, your embeddings, and eventually your model's context window. This post shows how to audit for it in ~40 lines of Python, and how we handle it in production.

1. Find what your parser will see but your reviewer won't

# pip install openpyxl python-docx pypdf import sys from openpyxl import load_workbook from docx import Document from pypdf import PdfReader def audit_xlsx(path): wb = load_workbook(path, read_only=False) for ws in wb.worksheets: if ws.sheet_state != "visible": print(f"[xlsx] sheet '{ws.title}' is {ws.sheet_state} " f"({ws.max_row} rows x {ws.max_column} cols)") p = wb.properties for field in ("creator", "lastModifiedBy", "title", "subject", "keywords"): val = getattr(p, field, None) if val: print(f"[xlsx] metadata {field} = {val!r}") def audit_docx(path): doc = Document(path) cp = doc.core_properties for field in ("author", "last_modified_by", "comments", "title", "subject"): val = getattr(cp, field) if val: print(f"[docx] metadata {field} = {val!r}") for i, section in enumerate(doc.sections): for kind, part in (("header", section.header), ("footer", section.footer)): text = " ".join(p.text for p in part.paragraphs).strip() if text: print(f"[docx] section {i} {kind}: {text[:80]!r}") def audit_pdf(path): meta = PdfReader(path).metadata or {} for k, v in meta.items(): print(f"[pdf] metadata {k} = {v!r}") for f in sys.argv[1:]: {"xlsx": audit_xlsx, "docx": audit_docx, "pdf": audit_pdf}[f.rsplit(".", 1)[-1].lower()](f) 

Run it over a sample of the files your users actually upload. In our experience the first run is usually an unpleasant surprise: a "clean" pricing sheet with a veryHidden customers_raw tab, or every DOCX carrying the original author's full name and employer.

2. Decide a policy, don't just redact blindly

There are two reasonable policies for hidden content, and which one is right depends on the use case:

Policy When it fits
Skip hidden sheets entirely The hidden data was never meant to be part of the knowledge base (lookup tables, raw exports)
Include but redact Hidden sheets contain formulas/reference data the answers depend on

Metadata is simpler: it almost never helps retrieval, so strip or redact it by default.

3. How we handle it: Doc & PII MCP v1.1.0

We shipped these as explicit options in CoreNova Doc & PII MCP v1.1.0, after a reader asked about exactly this case in the comments on a previous post:

  • include_hidden_sheets — choose between skipping or redacting hidden/veryHidden sheets
  • redact_metadata — scrubs PII from PDF and Office metadata
  • DOCX headers/footers and PPTX speaker notes are now extracted and redacted, instead of silently passed through

It runs as an MCP server inside your own VPC (EKS, ECS Fargate, or alongside Amazon Bedrock Agents), so documents never leave your account. The open-source starter repo has deployment templates for all three.

Takeaway

Before you trust your redaction layer, check what your parser extracts, not what Excel or Word shows you. The audit script above takes five minutes to run and will tell you whether you have this problem.

If you've hit other "invisible text" sources (embedded OLE objects, tracked changes, alt-text on images), let me know in the comments. Those are next on our list.