AWS SAM CLI: OS command injection in Terraform hook
Summary
AWS SAM CLI versions 1.63.0 up to 1.166.1 contain an OS command injection in the Terraform hook (sam build --hook-name terraform). A Terraform resource address is inserted without full neutralization into a generated Makefile recipe. An attacker who can influence the Terraform configuration or plan file processed by a build can run arbitrary commands as the build user on the build host, without AWS credentials. The flaw affects local build processes and is not exposed directly to the internet.
Affected
- AWS SAM CLI (aws-sam-cli, PyPI) 1.63.0 up to and including 1.166.1
- Forks and derivative code that contain the affected Terraform hook code
Fixed in
AWS SAM CLI 1.166.2 or later.
Workaround
- Use Terraform configuration and plan files for sam build --hook-name terraform only from trusted sources.
- Audit third-party Terraform modules and shared repositories that supply input to the build.
- No vendor-documented setting to disable the hook is known. Unknown.
Exploitation
- No exploitation is known according to the vendor, the CISA SSVC assessment (Exploitation: none, Automatable: no) and VulDB.
- No public proof of concept found.
- As far as known, not listed in the CISA KEV catalog.
Our recommendation
- Check whether SAM CLI is installed on developer machines, build servers and CI/CD runners, and which version is used.
- Upgrade to 1.166.2 or later, including forks and distribution packages.
- Check whether sam build --hook-name terraform is used; if so, restrict who may change Terraform code and plan files and review third-party modules.
- If untrusted input may have been built, rotate CI/CD secrets on the affected runners.
Public exploits
PoC-in-GitHub, Metasploit and Exploit-DB list nothing for this CVE.
Research sources
- AWS Security Bulletin 2026-145-AWS aws.amazon.com
- GitHub Security Advisory GHSA-44mq-wjrh-vpj6 github.com
- GitHub Release v1.166.2 github.com
- VulDB entry 425366 vuldb.com
- Hol.org CVE summary hol.org
- NixOS nixpkgs tracker issue 577768 github.com
Researched and written up in English and German by an AI (Claude by Anthropic) based on NVD, CISA, EPSS and the sources listed. The vendor information is authoritative. Researched on 1 Nov 2026, 12:08.
Original description (NVD)
OS command injection in the Terraform hook in AWS SAM CLI before 1.166.2 might allow an actor who can influence the Terraform configuration or plan file consumed by a build to execute arbitrary commands as the build user on the host running the build via a crafted Terraform resource address. To remediate this issue, users should upgrade to version 1.166.2 or later.
Sources
The tracker combines official, freely usable data sources – updated continuously:
- NVD (NIST) – CVEs, rating (CVSS), affected products
- CISA KEV – vulnerabilities confirmed by CISA as actively exploited
- CISA Vulnrichment – CISA assessment (SSVC) in the official CVE record
- FIRST EPSS – probability of exploitation
- Microsoft MSRC – Patch Tuesday: vulnerabilities, severity, updates
- PoC-in-GitHub – public proof-of-concept repositories
- Metasploit (Rapid7) – modules of the Metasploit Framework
- Exploit-DB (OffSec) – archive of public exploits (links only)
- Patch days: official vendor pages (linked per vendor) (Vendor patch days)
This product uses data from the NVD API but is not endorsed or certified by the NVD. EPSS data © FIRST.org.
Affected? We can help.
We check whether your systems are affected, install updates and close the gap – continuously with the System Health Checker if you wish.
