Implementation Guide | Financial Services

    Redacting Social Security Numbers and Passport Numbers from ID Images Before a KYC Agent Calls the LLM

    Run redaction as a runtime policy stage in the execution path, after the ID image is received and before any prompt or tool-call argument is built. Detect SSN and passport number regions with OCR, layout and MRZ parsing, and pattern validation. Mask the pixels, not only the extracted text. Then return allow, redact or block, and fail closed when detection confidence is low. Record what happened and under which policy, without storing the raw identifiers.

    Define allow, redact and block outcomes, and fail closed

    1. 1

      Allow

      The document type is in scope, quality checks pass, and no SSN or passport number is detected in the content to be sent. The original image proceeds.

    2. 2

      Redact

      One or more identifiers are detected with sufficient confidence. The regions are masked, the output is re-verified, and only the masked image is sent.

    3. 3

      Block

      Detection confidence is below threshold, the image fails the quality gate, the layout is unrecognised, or post-mask verification still finds an identifier. Nothing is sent to the model or tools.

    4. 4

      Escalate

      A blocked item is routed to a person or a recapture request, such as asking for a clearer image. Retry paths must pass through the same stage.

    Decide what to redact and what to preserve

    Start with an inventory of the direct identifiers on each document type in scope: driver's licences, passports and SSN cards. NIST's de-identification guidance opens with the same step, determining the direct identifiers before removing them. That guidance is written for datasets, so treat it as a method to borrow rather than a procedure for images.

    Then define what the verification task needs the model to see. In most KYC flows the LLM is asked about document type, name, date of birth and expiry. Those fields stay visible. An SSN has no role in those checks, and a passport number may not either, so both are masked by default. Licence numbers and addresses are decisions for your own policy, and you should make them explicitly instead of leaving them to whatever the OCR step happens to return.

    The passport needs particular care because the same number can appear twice: in the visual inspection zone and in the machine-readable zone (MRZ). The MRZ also carries name, date of birth and expiry. If the task needs those, extract them in a controlled step and pass them as structured values. Mask the MRZ band in the image so the number does not travel with it.

    Place the control in the execution path, before the model and tool calls

    Sensitive information can affect both the model and the application context around it, which is the framing OWASP uses for sensitive information disclosure. For a KYC agent that context includes prompts, tool-call arguments, caches and downstream stores. A raw SSN that reaches any of them is already disclosed, so the redaction stage has to sit upstream of all of them.

    The practical rule is that nothing assembles a prompt or tool arguments from the original image. The agent receives the image, the redaction stage produces a masked image and a decision, and only the masked image moves forward. OWASP describes redaction as a step applied before content is processed, which matches this placement.

    The alternative is redaction in application code, written separately by each agent team. That approach produces different behaviour per agent and is difficult to demonstrate to an examiner. Enforcing the same policy in the execution path, at the level of each interaction and each tool call, gives one place to define the rules, one place to change them and one record of what was enforced. This is also where Trussed operates: it enforces policy in the execution path across models, agents, tools and MCP servers, with allow, redact and block outcomes.

    Detect identifiers with layered methods and plan for misses

    No single technique is sufficient, so use layers and treat disagreement between them as a signal. OWASP names pattern matching as a way to detect and redact confidential content before processing. On images, that means running patterns over OCR output, which makes OCR quality a dependency of every layer.

    The layers below work together. Their accuracy on your documents is something to measure against your own samples, not assume.

    • OCR with bounding boxes: Extract text with coordinates so a detected value maps back to a pixel region. Text without coordinates cannot drive image masking.
    • Layout and label anchoring: Locate fields by document template and nearby labels. Non-standard or unfamiliar layouts should lower confidence instead of falling through to a default.
    • MRZ parsing: Detect the machine-readable band, parse it and use its check digits to confirm that a candidate document number is well formed.
    • Pattern validation: Apply nine-digit SSN formats and passport number formats to OCR output, with validity rules to reduce false matches.
    • Image-quality gate: Score skew, glare and resolution before detection. A low-quality image can hide an identifier from every other layer.
    • Confidence aggregation: Combine layer outputs into a per-field and per-image confidence that the policy can act on.

    Mask pixels, not only extracted text

    Text-level redaction cleans the OCR string handed to the model. It does nothing for the image if the image is also sent, and a multimodal model reads the image directly. Because the image is the transmission path, the control must alter the image itself.

    Fill each detected region, with a margin, using an opaque block. Blurring and light overlays can leave characters recoverable, so avoid them. Re-encode the result as a new image and drop the original from the request. Metadata and any embedded text layers should not carry over from the source file.

    Mask the whole MRZ band when the passport number is present, since the number sits inside it. Verify masking by running OCR and pattern checks again on the output image. If an identifier is still detected, treat that as a failure of the stage, not a pass.

    There is a tradeoff. A generous mask protects against small bounding-box errors but may cover fields the task needs, such as a date of birth printed next to an SSN on a non-standard document. Decide in advance which error you prefer and tune it with your own samples.

    Record evidence of redaction without keeping the identifiers

    An examiner will want to see what the control did, when, and under which rule. In a financial services setting, that scrutiny usually comes through model risk management and evidence expectations. The record should answer those questions without becoming a second place where SSNs and passport numbers are stored.

    The fields below are proposed design requirements. Never store the raw value, a crop of the region, or a hash of the value. SSNs have a small enough space that hashes can be reversed by brute force. Store entity types and counts, not content.

    Measure the control over time as well. Track block rates, low-confidence rates and sampled reviews of masked output, because detection misses are the failure that single-transaction evidence cannot reveal.

    Trussed generates audit-ready evidence from enforcement itself, mapped to frameworks including NYDFS and NIST, and supports configurable retention and data residency in a self-managed deployment in the customer cloud. Trussed's deepest experience is in insurance, a regulated financial sector, and it does not claim financial-services deployments. The design above is useful whichever tooling you choose.

    • Timestamp, agent identifier and interaction or tool-call identifier
    • Policy name and version that was enforced
    • Entity types detected (for example SSN, passport number, MRZ) and counts
    • Action taken: allow, redact, block or escalate
    • Per-field and aggregate confidence, plus the image-quality result
    • Failure outcome and reason, and a reference to the masked image, never the original

    Pre-inference redaction path for a KYC agent

    Intake

    ID image received by the KYC agent

    Detect

    OCR, layout, MRZ parsing and pattern validation

    Decide

    Policy returns allow, redact or block

    Mask

    Pixels covered before the image leaves the boundary

    Call

    Model and tool calls receive only the masked image

    Evidence

    Policy version, entity types, action and outcome recorded

    Put redaction in the execution path

    See how policy enforcement at the interaction and tool-call level can allow, redact or block, and produce audit-ready evidence for each decision.

    Talk to an Expert