Join our Newsletter — 33% off our NHI Course

Format-Preserving Substitution

Format-preserving substitution replaces a sensitive value with another value that looks structurally similar, such as matching length, character class, or syntax. This helps preserve the readability and tooling compatibility of logs while reducing exposure of secrets, account details, and other sensitive fields.

How format-preserving substitution works

Format-preserving substitution is most useful when the downstream system still needs to parse, sort, display, or validate a field, even though the original value is too sensitive to expose. Instead of blanking the field, the replacement keeps the same broad structure so dashboards, alerts, and analytics remain usable.

That structural similarity can include length, delimiter pattern, character class, or syntax. A token may still look like a token, an account number may still look like an account number, and an identifier may still fit the schema expected by a log parser or export pipeline.

Where it fits in logging, masking, and tokenisation

This technique sits between full redaction and reversible tokenisation. Redaction removes the value entirely, which is safer for exposure reduction but can break operational workflows. Reversible tokenisation preserves a lookup path back to the original value, which is useful when a trusted system must re-identify data later. Format-preserving substitution usually aims for operational continuity first, not reversibility.

For teams handling secrets or sensitive operational data, the method is often applied to logs, telemetry, support exports, and troubleshooting views. It allows engineers to correlate events without handing over the original credential, account detail, or other sensitive field. When the source data is heavily structured, a well-chosen substitution can keep the record readable enough for analysis while still lowering exposure.

The value is strongest when the consuming tools are brittle. If a parser expects a fixed-width field, a known prefix, or a valid syntax pattern, simple removal can cause ingestion failures or false alerts. Substitution avoids that friction, but only if the replacement does not accidentally reveal the original value’s format too precisely.

Security boundaries and common failure modes

Format-preserving substitution reduces direct exposure, but it does not make the underlying data safe by itself. If the substituted value is deterministic, predictable, or generated from weak rules, attackers may infer the original field or link multiple events to the same subject. If the replacement is too similar to the original, the output can still leak business context, account structure, or naming conventions.

It also depends on the surrounding control environment. Logs that are still broadly accessible, forwarded without protection, or stored outside trusted systems can remain a disclosure risk even after substitution. In practice, this technique is a visibility control, not a substitute for access restriction, retention discipline, or secure handling of the original source data.

When the field being substituted is a credential, token, API key, or other secret, preserving format may help operations, but the original value should still be treated as highly sensitive material. The goal is to make the copy safe enough for the log consumer, not to relax the handling standard for the underlying secret.

When practitioners should use it

Why practitioners should care: Use format-preserving substitution when teams need searchable, schema-compatible logs without exposing the real value. It is especially helpful in support, detection, and debugging workflows where the shape of the data matters more than the exact content.

Common misunderstanding: People often assume any masking is equally safe. In reality, the degree of preservation matters, because a replacement that keeps too much structure can still disclose sensitive patterns or enable correlation across records.

Practitioner note: Treat the substituted field as a derived artifact with its own access expectations. If the original value would have required tight control, the substituted copy should still be limited to the smallest audience that genuinely needs it.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

NIST CSF 2.0, CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
NIST CSF 2.0 PR.DS — Data Security Format-preserving substitution protects sensitive data while keeping it usable in logs.
Recommendation — Apply PR.DS to limit sensitive-field exposure in telemetry and exports while preserving necessary operational utility.
CIS Controls v8 3 — Data Protection This technique is a data-protection control for reducing exposure in stored and shared records.
6 — Access Control Management Substitution reduces exposure, but access control still governs who can view original and substituted records.
Recommendation — Use Control 3 to mask sensitive fields before they reach logs, reports, or support tooling. Apply Control 6 to restrict access to raw values and the systems that can reverse or rehydrate them.
NIST SP 800-53 Rev 5 SC-28 — Protection of Information at Rest Substituted values are part of protecting sensitive information stored in operational datasets.
AU-9 — Protection of Audit Information Logs often carry substituted sensitive values and still need strong protection as audit records.
Recommendation — Use SC-28 to protect sensitive log and export data that still contains derived identifiers. Apply AU-9 to safeguard audit and log data that contains masked or substituted fields.