DEV Community

OnaEiuspkz
OnaEiuspkz

Posted on

Terraform ignore rules can miss sensitive files after Unicode normalization

Terraform ignore rules can miss sensitive files after Unicode normalization

HashiCorp's go-slug library handled Unicode normalization incorrectly while matching .terraformignore patterns. CVE-2026-14978 affects versions 0.4.0 through 0.18.2 and is fixed in 0.18.3. On affected macOS filesystems, a local working directory can contain a filename and an ignore pattern that look equivalent to a user but have different byte representations. The matcher may keep the file in the Terraform Cloud or Terraform Enterprise upload when the operator intended to exclude it.

The vulnerability is local and requires interaction, but its consequence can be remote. The uploaded working directory leaves the operator's machine and enters a remote execution environment. If .terraformignore is being used to keep credential files, local state, environment files, or vendor material out of that upload, the visibility boundary is weaker than the file names suggest.

Path matching has to use one canonical form

Unicode allows several byte sequences to represent the same visible character. macOS file systems may normalize names on one path while the ignore parser compares a different input. A reliable matcher must decide whether it is comparing code points, normalized code points, case-folded values, or raw bytes. It must apply that rule consistently to both the path and the pattern, then test the final upload set.

A simple string comparison can appear to work in tests that use ASCII names. Add fixture files with composed and decomposed characters, different normalization forms, case variants, trailing dots, and directory components that change during traversal. The test should assert the resulting slug, not only whether one helper function returns a boolean.

Treat .terraformignore as a control that needs verification

The official bulletin says there is no workaround and recommends upgrading to 0.18.3. An immediate compensating control is to avoid keeping sensitive files inside the directory that feeds a remote run. Use a dedicated checkout, a clean workspace, and an allow-list build step where possible. Secrets should come from a secret manager at run time rather than from files that depend on an ignore rule.

If an upgrade cannot be deployed immediately, inspect the exact upload plan before sending it. List the files that are included after ignore processing and search for names that resemble policy files, keys, tokens, or local state. A filename review is not a substitute for the fix because an attacker can choose an unusual normalization form, but it can reveal an obvious exposure.

Review past uploads and rotate exposed material

Determine which Terraform clients and CI images used an affected go-slug version. For each workspace, ask whether .terraformignore was the only barrier protecting a sensitive path. If so, review the uploaded slug metadata and remote-run history for those files. Access to the upload may have been limited to the platform, but the wrong trust conclusion can persist long after the run finishes.

Rotate any credential that could have entered an affected upload. Check cloud keys, registry tokens, signing material, SSH keys, provider credentials, and state encryption keys. Remove stale remote state or workspace artifacts only through the supported Terraform process. A local file deletion does not revoke a credential that was uploaded elsewhere.

Update the toolchain, not just one laptop

Version inventory should include the CLI, CI runner images, wrapper scripts, and any vendored module that imports go-slug. Require a positive version check in build logs. A developer's local upgrade does not protect a scheduled pipeline that still runs an old container.

After the update, create a regression job with a test directory containing normalization collisions. Run it on macOS and on the other platforms used by the team. The job should fail if a file that policy marks as excluded appears in the slug manifest. Keep the test small enough to run on every change because path behavior is easy to regress.

Detection and assurance

Search build logs for use of affected releases and for uploads from macOS runners. Compare the set of files expected by policy with the slug contents. Store the comparison result as an audit artifact. If the tool offers a dry-run or inspection mode, use it before remote execution and preserve the output with the run record.

The most useful assurance statement is specific: which files were excluded, which version performed the match, and which platform produced the path. CVE-2026-14978 shows that a local naming detail can defeat a control whose failure appears in a remote service.

References

Top comments (0)