← All engineering notes

Enterprise AI

Build a secrets-redaction pipeline before AI requests leave your boundary

Choose detection, action and recovery paths for credentials in employee prompts, documents and model output.

A secret-redaction pipeline should make one explicit decision before an AI request crosses a provider boundary: allow unchanged content, replace a detected value, or stop the request. Detection is useful only when the selected action, evidence and recovery path are equally clear.

Start with known credential formats and organization-specific patterns. GitHub's custom-pattern reference shows why a pattern needs boundaries and additional match requirements, not only a broad regular expression. Broad matching can remove harmless identifiers; narrow matching can miss a newly introduced internal token.

Split the pipeline into four decisions

Stage Decision Evidence to retain
Classify Which input parts can contain credentials? Request part and policy version
Detect Which formats and custom prefixes should match? Detector name and finding category
Act Redact, block or escalate? Action and safe reason code
Recover How does the user complete legitimate work? Approved alternative path

For an internal assistant, scan user text, retrieved snippets, uploaded-text extracts and tool-call arguments separately. A code diff may legitimately contain a placeholder named API_KEY; a pasted production credential needs a different response. Keep the policy decision close to the request boundary so every provider and model path receives the same treatment.

Pick an action by workflow

Redaction works when the model can complete the task without the value. Replacing sk-live-… with a stable marker can let an assistant explain where a credential appears in a configuration file. Blocking works when the request asks the model to transform, send or store the credential. An escalation path is useful when a security engineer needs to inspect the original value in an approved system rather than pasting it into a chat.

Google's transformation reference distinguishes deletion, replacement, masking and cryptographic tokenization. The choice changes the result: deletion can break syntax, masking can preserve useful context, and reversible tokenization creates a key-management responsibility. Do not describe a masked value as anonymous. It can still be sensitive in its surrounding context.

A practical design review

Suppose an employee asks an AI assistant to diagnose a deployment manifest. The manifest contains an access key. The boundary should scan the text before the provider request, replace the matched value with [redacted:secret], and present a local message that names the affected field without echoing the key. The assistant can still recommend an environment-variable reference or a secret-manager path.

The failure case is a partial token split across fields, chunks or a generated tool call. Test every representation that the application supports, including streamed output. Test a near match that must remain visible, such as an example key from documentation. Log only the category, policy and outcome; a security log containing the credential recreates the exposure.

Do not overstate coverage

Pattern systems miss unknown formats, encoded values, values split across boundaries and credentials hidden in images or binary files. GitHub documents limits for custom patterns, and its syntax support is a subset of common regular-expression features. Treat a detector as a control with measured coverage, not proof that a request is safe.

Keep an inventory of the credential formats your teams issue. Add a test when a new provider, prefix or build system appears. Review false positives with the owners of the affected workflow before weakening a global rule. A broad exclusion is often worse than a narrow pattern correction.

Alectura's secrets guardrail can redact or block configured request and output parts; it also checks tool-call output when that part is selected. It cannot inspect image, audio or video input, and PDF coverage depends on the text layer. Use the technical coverage documentation to test one representative internal application before treating a rule as a production control.

Sources checked 15 November 2026. Provider capabilities and terms can change; check the linked documentation for your configuration.

Keep reading

Trace an internal AI incident without collecting every employee prompt ↗Validate LLM tool arguments before your application runs them ↗Account for attachments your AI controls cannot inspect ↗