Skip to content
The RedTeam Monitor
Friday, October 23, 2026Your daily threat briefing255 reports
AWS SAM CLI Terraform Hook Flaw Lets Attackers Run Host Commands
Vulnerabilities

AWS SAM CLI Terraform Hook Flaw Lets Attackers Run Host Commands

A command injection flaw in the AWS SAM CLI Terraform hook allows execution of arbitrary commands on build hosts, fixed in version 1.166.2.

Key points

  • The vulnerability exists in AWS SAM CLI versions 1.63.0 through 1.166.1.
  • Attackers can execute commands as the build user by manipulating Terraform files.
  • AWS released version 1.166.2 to address the OS command injection issue.

Security researchers identified a flaw in the AWS SAM CLI that allows attackers to run operating system commands on the machine performing the build. The issue stems from how the Terraform hook handles resource addresses. An actor who can influence the Terraform configuration or plan file consumed by the build process can exploit this weakness. This grants them the ability to execute arbitrary commands as the user running the build operation on the host system.

In plain English

The AWS SAM CLI is an open-source tool used for building serverless applications. It includes a feature called the Terraform hook, which integrates with Terraform configurations during the build phase. When this hook runs, it generates a Makefile recipe. The problem occurs because the tool does not properly neutralize shell metacharacters when it interpolates a Terraform resource address into that recipe. This lack of sanitization creates an opening for command injection.

The background

AWS published a security bulletin for CVE-2026-115414 on 22 October 2026. The advisory classifies the issue as important and requiring attention. The vulnerability affects AWS SAM CLI versions starting from 1.63.0 up to and including 1.166.1. Shubham Raj of Cipher by Causal Security discovered the flaw and collaborated with AWS through the coordinated vulnerability disclosure process. This follows similar findings, such as the pypdftk OS command injection flaw RedTeam Monitor reported on 14 October 2026.

What changes now

AWS has addressed the issue in AWS SAM CLI version 1.166.2. The vendor recommends upgrading to this latest version immediately. Organizations should also ensure that any forked or derivative code incorporates these new fixes. Beyond updating the software, AWS advises teams to verify that Terraform configuration files and plan files consumed by the build process come only from trusted sources. Auditing third-party Terraform modules and shared repositories is also recommended to reduce exposure.

What made it possible

This vulnerability arises from improper input validation during data processing. When software accepts external input and incorporates it into system commands without adequate sanitization, it creates a path for command injection. Attackers exploit this by crafting input that includes shell metacharacters, which the system interprets as executable instructions rather than plain text. This technique typically serves as an initial access vector or a privilege escalation method, allowing adversaries to execute arbitrary code on the target host with the permissions of the application user.

What to do and how to stay safe: AWS

  • Upgrade AWS SAM CLI to version 1.166.2 or later to apply the vendor's fix for the command injection flaw.
  • Audit all Terraform configuration and plan files used in build pipelines to ensure they originate from trusted sources only.
  • Review third-party Terraform modules and shared repositories for any untrusted input that might reach the build process.
  • Monitor build logs for unexpected command executions or anomalies that could indicate exploitation attempts.

Step-by-step guide: Automatic Updates Mistakes That Leave Systems Exposed

General security guidance from the RedTeam Monitor newsroom. It is not confirmed advice from the organisations named in this story.

Frequently asked questions

Which versions of AWS SAM CLI are affected by CVE-2026-115414?

Versions 1.63.0 through 1.166.1 are impacted by this OS command injection vulnerability.

How can an attacker exploit this flaw?

An attacker must be able to influence the Terraform configuration or plan file consumed by the build to execute commands.

Is there a patch available for this issue?

Yes, AWS has released version 1.166.2 which addresses the vulnerability.

Sources

  1. AWS Security Bulletins
AWSSAM CLICVE-2026-115414OS Command InjectionTerraform

Related stories