Implementation Guide

Preventing account numbers and Social Security numbers from reaching AI coding assistants through runtime controls

Treat this as a data flow problem, not a user-awareness problem. Remove sensitive data at the source, scope what the assistant can read, inspect content before submission, enforce policy at runtime on prompts and tool calls, and log every action without storing the values. Pattern-based detection is imperfect, so validate the controls continuously with synthetic test data.

How account numbers and SSNs enter assistant context

Treat this as a data flow problem, not a user-awareness problem. The useful question is where sensitive values can enter the assistant's context, and which control sits at each of those points.

The testing checklist later in this guide names the channels to account for: pasted text, repository files, terminal output, and tool responses. Real values can also sit in fixtures, logs, and configuration, and prompts and tool calls are the points where runtime policy applies.

Control points from source to model

Five layers of control apply between the source data and the model, in this order:

  1. Source data hygieneRemove or mask real values in fixtures, logs, and configuration.
  2. Context scopingLimit the files, paths, and tools the assistant can read.
  3. Pre-submission inspectionCheck pasted and editor content before it leaves the client.
  4. Runtime policy enforcementBlock, redact, or escalate on prompts and tool calls.
  5. Logging and testingRecord events without raw values and verify controls regularly.

Layers one and two: fix the source and scope the context

The first two layers reduce what the assistant can ever see. They do not depend on detecting a value in transit.

Layer one: source data hygiene

Remove sensitive data at the source. Remove or mask real values in fixtures, logs, and configuration so they are not available to be read or pasted.

Layer two: context scoping

Scope what the assistant can read. Limit the files, paths, and tools it can access, so that sensitive locations are outside its context by default.

Layers three and four: inspect before submission and enforce at runtime

The next two layers examine content as it moves toward the model.

Layer three: pre-submission inspection

Inspect content before submission. Check pasted and editor content before it leaves the client.

Layer four: runtime policy enforcement

Enforce policy at runtime on prompts and tool calls. Depending on configuration, the policy can block, redact, alert, or request approval. Each of these actions should be confirmed during testing.

Enforcement points and their tradeoffs

Enforcement happens in more than one place: on content before it leaves the client, and at runtime on prompts and tool calls. Controls at the source and in context scoping reduce what the later layers must catch.

Detection limits and what to log

Because pattern-based detection is imperfect, format variations and look-alike values affect results. The checklist below covers variations such as hyphens, spaces, line splits, and JSON or encoded wrappers, as well as non-sensitive values such as order and transaction IDs that can cause false positives.

Log every action without storing the values. Each event record should show that a control acted, and it should contain no raw account numbers or SSNs.

Testing control effectiveness

  • Seed synthetic SSNs and account numbers into each channel: pasted text, repository files, terminal output, and tool responses.
  • Test format variations: with and without hyphens, spaces, line splits, and JSON or encoded wrappers.
  • Run look-alike non-sensitive values, such as order and transaction IDs, to measure false positives.
  • Confirm that each configured action fires as intended: block, redact, alert, or approval request.
  • Verify that log entries exist for every test event and contain no raw values.
  • Repeat after changes to assistants, plugins, MCP servers, or policies, and track results over time.

Review your enforcement points

Discuss how runtime policy enforcement, tool-call governance, and audit logging fit your AI coding assistant environment.

Talk to an Expert