Only the display changes. The secret can still be written into state, plan files, or outputs, so the underlying storage exposure remains even when the CLI shows redacted values. Teams should treat sensitive=true as a presentation control, not a protection boundary, and pair it with runtime retrieval or state hardening.
Why Terraform’s sensitive flag only hides values, not the secret itself
Terraform’s sensitive = true marks values for redaction in human-facing output, but it does not change where Terraform stores or propagates them. The same value can still be persisted in state, written into plan artifacts, or surfaced through outputs and downstream tooling, so the real question is not visibility in the CLI but whether the secret ever enters Terraform’s data flow at all.
That distinction matters because Terraform state is a durable record, not a temporary display layer. If a secret is placed into configuration, variables, data sources, or module outputs, sensitive = true only affects presentation at the end of the pipeline; it does not remove the value from storage, access paths, or backup copies.
Where the exposure actually persists
The practical failure mode is storage exposure. A redacted value can still be present in local files, remote state backends, cached plans, CI logs, or tooling that inspects the state machine-readable form. In other words, sensitive marking can reduce accidental disclosure to a person reading the terminal, but it does not protect the secret from anyone or anything that can access the state or plan artifact.
This is why teams should think in terms of secret handling, not output formatting. If the secret is needed only at runtime, the better pattern is to fetch it at runtime from a dedicated secret store or identity-backed service rather than letting Terraform materialise it in state in the first place.
What to use instead of relying on redaction
Use sensitive = true only as a limited presentation control, then pair it with controls that change the storage and exposure model. That usually means runtime retrieval, shorter-lived credentials, tighter state access, and careful review of module outputs so that hidden values are not accidentally exported into other systems.
For infrastructure teams, the key design decision is whether Terraform is provisioning a configuration that references a secret or whether Terraform is being asked to manage the secret itself. When Terraform manages the secret value, the exposure surface expands to every place state and plan data can travel. When Terraform only injects a reference to a runtime secret source, the blast radius is materially smaller.
Risk and Threat Considerations
Using sensitive = true as a substitute for secret protection creates a false sense of safety. The credential may be hidden from the console but still accessible to anyone with state access, CI artifact access, backend permissions, or downstream automation that can parse the plan or state file.
Failure mechanism: Terraform redacts display output while leaving the secret intact in state, plans, or outputs, so disclosure controls that depend on terminal masking do not reduce the underlying exposure.
Impact: A leaked state file or overbroad backend permission can expose API keys, tokens, certificates, or other credentials even when the Terraform run appeared to handle them safely, which can lead to unauthorized access, secret reuse, and delayed detection.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 and OWASP ASVS set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | IA-5 — Authenticator Management | Stateful secret handling and rotation are central to Terraform-managed credentials. |
| AC-6 — Least Privilege | Terraform state and backend access should be tightly limited because redaction does not remove stored secrets. | |
| SC-28 — Protection of Information at Rest | Terraform state files and plan artifacts can retain secret material at rest. | |
| Recommendation — Manage Terraform-handled secrets with lifecycle controls and rotate any exposed authenticators promptly. Restrict state-backend access to the minimum set of operators and automation. Protect state and plan artifacts with encryption and controlled storage. | ||
| OWASP ASVS | V14 — Data Protection | The issue is whether secret material is protected beyond display redaction. |
| Recommendation — Treat secret values as protected data and prevent them from being serialised into durable artifacts. | ||
| OWASP Non-Human Identity Top 10 | NHI-02 — Secret Leakage | Terraform redaction that leaves secrets in state is a secret leakage pattern. |
| Recommendation — Prevent secrets from entering Terraform state and plan outputs in the first place. | ||
Practitioner Guidance
What to verify: Confirm whether the secret is being passed through Terraform as a value, because if it is, the state file is part of the trust boundary. Review outputs, data sources, and module boundaries for any place the value can be re-serialised.
Decision rule: If a secret can authenticate to another system, prefer runtime retrieval or ephemeral credentials; if Terraform must touch the value, treat state hardening and backend access as mandatory, not optional.
Common mistake: Teams often equate redaction with protection and stop there. The safer interpretation is that sensitive = true lowers casual disclosure risk but does not change secret lifecycle, storage, or recoverability.
Practitioner takeaway: Use Terraform to declare infrastructure, not to create a false boundary around secrets. If the secret matters enough to protect, assume state exposure matters too.
Related resources from NHI Mgmt Group
- What fails when telemetry pipelines carry secrets in plaintext or poorly governed formats?
- What fails when sensitive data discovery only happens after SIEM ingestion?
- What fails when cloud threat hunting only uses alerts and not identity context?
- What fails when a spreadsheet containing sensitive identities is sent to the wrong recipient?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 13, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org