How to Redact SSNs and Bank Routing Numbers Before Files Reach OpenAI Vector Stores
Place redaction in the upload path, before any file reaches the OpenAI Files or vector store APIs. Detect SSNs with format patterns plus context, detect routing numbers with the ABA check digit plus context, handle OCR and tables explicitly, block files that cannot be processed, re-scan the output, and record what was done per file without storing the sensitive values.
Placing enforcement in the upload path
- 1
1. Intake
Accept files only through the enforcement service, with authentication and encrypted transport.
- 2
2. Extract
Parse text, OCR images, read tables, metadata and embedded objects.
- 3
3. Detect and decide
Score matches, apply policy, and route ambiguous cases to human review.
- 4
4. Transform
Redact, mask or tokenize, then rebuild the file so removed content is gone.
- 5
5. Verify
Re-scan the output with an independent pass before release.
- 6
6. Upload and record
Send the verified file to the vector store and write the evidence record.
Why redaction belongs before the upload
Once a file is uploaded, chunked, embedded and made retrievable, a Social Security number or routing number can surface in a model response, and removing it selectively is difficult. Cleanup after ingestion is therefore the weaker position. The stronger one is to treat redaction as an enforcement point that every file must pass before it is sent to the Files or vector store APIs.
There is precedent for this ordering. An FTC privacy impact assessment describes a policy of redacting SSNs, dates of birth and similar identifiers from documents before they are saved into the target system, followed by supervisory review and approval of the redacted records. A vector store is a different system, but the principle carries over: sensitive values should not enter it in the first place.
Two cautions apply. NIST describes redaction, also called suppression, as the removal of information and notes that it does not alone provide formal privacy guarantees. NIST also notes that selective redaction can reduce accuracy and introduce bias. For retrieval, that means you should test answer quality on redacted content rather than assume it is unchanged.
Detecting SSNs and routing numbers
Neither identifier is reliably found by a single regular expression. Use layered signals and decide how each layer affects the action.
For SSNs, match the common shapes: three, two and four digits separated by hyphens, by spaces, or with no separator at all. Also account for values broken across lines or split across spreadsheet cells. Add context cues such as nearby labels like SSN, Social Security or taxpayer ID, which raise confidence for unseparated nine-digit strings. Avoid hard-coding area-number validity rules. Those rules may not reflect how numbers are assigned today, and a strict filter can produce false negatives.
Routing numbers are nine digits, so they collide with SSNs, account numbers, order IDs and phone-like strings. The ABA check digit helps. Multiply the digits by the repeating weights 3, 7, 1, sum the results, and confirm the total is divisible by 10. A failing value is almost certainly not a routing number. A passing value is not proof, because roughly one in ten arbitrary nine-digit strings passes the checksum. Combine it with context such as routing, ABA, RTN, wire or ACH labels and with proximity to an account number field.
A workable scoring approach is to redact automatically when format and strong context agree, route ambiguous matches to human review, and tune thresholds against a labeled sample of your own documents. Bias toward over-redaction for these two identifiers, then measure what that costs in retrieval quality.
File formats, OCR and hidden content
Detection only works on text the pipeline can see, so extraction is where most completeness failures occur.
Scanned PDFs and images need OCR before detection, and OCR errors can turn a digit into a letter and defeat a pattern. Run detection on the OCR output with tolerance for common character confusions, and keep a confidence signal so low-quality pages can be sent to review or blocked. For PDFs that contain both an image and a text layer, inspect both. Drawing a black box over text does not remove the underlying characters, so write the output as a flattened or rebuilt file in which the redacted content no longer exists.
Spreadsheets and tables need cell-aware handling. Check every sheet, including hidden ones, along with formulas, comments and named ranges. Digits split across adjacent cells or columns should be reassembled for detection. Embedded images, attachments and document metadata such as titles, author fields and file names should be treated as content in scope, not ignored.
Set a fail-closed rule. If a file type is unsupported, extraction fails, or OCR confidence is below your threshold, the file is blocked or escalated. It should not pass through by default.
Redaction, masking or tokenization
The right transformation depends on whether anyone needs to recover or correlate the original value. For most vector store use cases, the retrieval workload has no need for the raw identifier.
- Redaction: Removes the value, typically leaving a label such as [SSN]. Irreversible and the simplest to defend. Best default for retrieval content.
- Masking: Keeps part of the value, for example the last four digits. Useful when users must recognize a record, but partial values can still be sensitive, so apply it deliberately.
- Tokenization: Replaces the value with a reversible token. Lets you re-link records, but the mapping and keys must be stored securely and separately from the redacted output.
Verifying output and retaining evidence
Verification should be a separate step from redaction. Extract text again from the output file, including metadata and any OCR of rendered pages, and run detection a second time, ideally with a different implementation. Any remaining match blocks the upload. Maintain a test set of synthetic files covering each format and each SSN and routing number variant, and run it whenever detection rules change. Also run representative retrieval queries before and after redaction to see whether answer quality has degraded.
For each file, record the evidence needed to show what happened without keeping the values themselves: a file identifier and content hash, the policy and version applied, detection types and counts, the action taken, the timestamp, and any reviewer decision. Store positions or page references only if they cannot be used to reconstruct the value. Reviewers should see masked context, not raw identifiers.
This record supports your own safeguards program. If the FTC Safeguards Rule applies to your organization, its text calls for designated coordination, risk identification, assessment of existing safeguards and ongoing monitoring of effectiveness. Per-file evidence and review records give you material for each of those. Trussed generates audit-ready evidence from enforcement, mapped to HIPAA, NAIC, NYDFS, EU AI Act and NIST, so the record is a by-product of the decision itself.
Pre-ingestion redaction path
Intake
File arrives at a single enforcement point
Detect
Patterns, checksum and context cues
Act
Allow, redact, mask, tokenize or block
Verify
Re-scan the output file
Upload
Only verified files go to the vector store
Enforce redaction where files enter the AI path
Talk to an expert about enforcing allow, redact and block decisions at runtime and producing audit-ready evidence for each one.
Talk to an ExpertHow does your AI governance program compare?
See where your program has gaps in less than 2 minutes.