Security Fix: Sensitive Attribute Disclosure in Array/Nested Structures
This patch fixes a HIGH severity security vulnerability where sensitive attribute values inside arrays and nested objects were exposed in markdown reports even when the --show-sensitive flag was not set.
๐ Security fixes
Fixed sensitive data disclosure in array and nested attributes
Problem: Sensitive attribute values inside arrays or nested objects were displayed in plain text in markdown reports, even when the --show-sensitive flag was not provided. This caused secrets (API keys, passwords, tokens) to be exposed in PR comments and CI/CD logs.
Example affected resources:
azuredevops_build_definitionโvariable[0].secret_valueshown in plain textazuredevops_variable_groupโsecret_variable[0].valueshown in plain text- Any Terraform resource with array-typed sensitive attributes
Symptom: When running tfplan2md plan.json (without --show-sensitive), reports displayed actual secret values like variable[0].secret_value: my-secret-123 instead of masking them as variable[0].secret_value: (sensitive).
Root cause: The IsSensitiveAttribute() method in ReportModelBuilder.ResourceChanges.cs only performed exact key matching against Terraform's after_sensitive markers. When Terraform marks an entire array as sensitive (e.g., "variable": true), individual array items have flattened paths like variable[0].secret_value, which didn't match the exact key variable and were therefore not masked.
Fix: Implemented hierarchical sensitivity checking. The method now checks not only the exact attribute key but also all parent paths in the hierarchy. For example, when evaluating variable[0].secret_value, it now checks:
variable[0].secret_value(exact match)variable[0](parent array item)variable(parent array)
If any parent path is marked as sensitive in Terraform's plan JSON, the attribute value is masked.
Impact on reports
- Before: Secret values in arrays/nested structures were exposed regardless of
--show-sensitiveflag - After: Secret values are properly masked as
(sensitive)by default and only shown when--show-sensitiveis explicitly set
Security Impact
Severity: HIGH โ Secrets could be disclosed in reports shared publicly or stored in insecure locations.
Attack scenario:
- Developer runs
terraform plan -out=plan.tfplanwith resources containing array-based secrets - Developer runs
terraform show -json plan.tfplan > plan.json - Developer runs
tfplan2md plan.json(without--show-sensitive) - Developer posts markdown report as a PR comment
- Result: Secret values (API keys, passwords, tokens) visible in PR comment
- Impact: Secrets exposed to unauthorized users with PR read access
Mitigation: Users affected by this vulnerability should:
- Upgrade immediately to this release
- Review past PR comments for exposed secrets and rotate any credentials that may have been disclosed
- Avoid using older versions of tfplan2md with resources containing sensitive array attributes
๐ Commits
11f816afix: prevent sensitive data disclosure for array/nested attributes
๐งช Test coverage
Added 3 comprehensive unit tests to verify the fix:
- Array-based sensitive attributes โ Verifies
variable[0].secret_valueis masked when parent array is marked sensitive - Nested object sensitive attributes โ Verifies
config.database.passwordis masked when parent object is marked sensitive - Multi-level nested arrays โ Verifies deeply nested paths like
items[0].subitems[1].secretare masked correctly
All 1,132 tests passing.
๐ Related Documentation
The --show-sensitive flag is documented in:
- README.md โ CLI options section
- docs/features.md โ Sensitive Values section (lines 823-826)
Users should review these resources to understand the proper usage of the --show-sensitive flag:
- By default, sensitive values are masked as
(sensitive)for security - Use
--show-sensitiveonly in secure environments where sensitive data disclosure is acceptable - Always review generated reports before sharing them in public channels