GHSA-8394-6f8r-whxg: Input Validation
Summary
Terragrunt is vulnerable to an arbitrary file deletion flaw when downloading external modules. If a remote module contains a maliciously crafted .terragrunt-module-manifest file, Terragrunt can be tricked into deleting files anywhere on the local filesystem that the Terragrunt process has access to.
Impact
This vulnerability impacts users who download and run untrusted or compromised OpenTofu/Terraform modules. The file deletion occurs during the module download and initialization phase, meaning it happens before OpenTofu or Terraform executes.
In a CI/CD environment or automated runner, an attacker-controlled module could delete arbitrary files, causing denial of service in the deployment pipeline. In a local environment, it could lead to the loss of local source code or configuration files.
This vulnerability is a deletion-only primitive; it does not directly allow for arbitrary code execution (RCE) or data exfiltration.
Affected Versions
- Terragrunt < v1.0.4
Patches
This vulnerability has been resolved in Terragrunt version v1.0.4.
All users are strongly advised to upgrade.
Workarounds
If users cannot upgrade immediately, they can mitigate this risk by:
1. Strictly auditing the source URLs of all remote modules used in their Terragrunt configurations. 2. Only consuming modules from trusted, internally vetted sources or verified registries. 3. Pinning module versions to specific, known-safe Git commit SHAs rather than mutable tags or branches.
Technical Details
Terragrunt tracks files copied into a downloaded module's working directory using a .terragrunt-module-manifest file. During the directory cleanup process, Terragrunt decodes the entries in this manifest and removes the listed files to prepare a fresh directory for OpenTofu/Terraform runs.
Previously, Terragrunt trusted the manifest provided by the downloaded module without verifying that the paths scheduled for deletion remained within the boundaries of the module's destination directory. An attacker could forge a manifest containing directory traversal paths, causing the cleanup function to target files outside the cache. The patch introduces a secure boundary check to ensure all cleaned paths remain safely isolated inside the intended manifest folder.
Credit
Terragrunt would like to thank Francesco Sabiu (@fsabiu) for discovering and responsibly disclosing this vulnerability.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
go/github.com/gruntwork-io/terragruntto a version that resolves this vulnerability.Fixed in 1.0.4 - Upgrade
Upgrade
Terragruntto a version that resolves this vulnerability.Fixed in v1.0.4 - Compensating control
If you cannot upgrade immediately, only consume OpenTofu/Terraform modules from trusted, internally vetted sources or verified registries.
- Compensating control
If you cannot upgrade immediately, pin remote module versions to specific, known-safe Git commit SHAs instead of using mutable tags or branches.
- Compensating control
If you cannot upgrade immediately, strictly audit the source URLs of all remote modules used in your Terragrunt configurations.
Event History
Frequently Asked Questions
What is the severity of GHSA-8394-6f8r-whxg?
The severity of GHSA-8394-6f8r-whxg is rated at 45.
What is the vulnerability described in GHSA-8394-6f8r-whxg?
GHSA-8394-6f8r-whxg describes an arbitrary file deletion flaw in Terragrunt when downloading external modules.
How does GHSA-8394-6f8r-whxg affect the Terragrunt process?
GHSA-8394-6f8r-whxg can allow a malicious remote module to trick Terragrunt into deleting files anywhere on the local filesystem.
How can I mitigate the risks associated with GHSA-8394-6f8r-whxg?
To mitigate the risks of GHSA-8394-6f8r-whxg, ensure to validate and scrutinize external modules before using them.
How do I fix GHSA-8394-6f8r-whxg?
To fix GHSA-8394-6f8r-whxg, update Terragrunt to the latest version that addresses this vulnerability.