skip to content
Back to
Home Bounties Research Advisories CodeQL Wall of Fame Get Involved Events
June 16, 2023

GHSL-2023-104: Actions command injection in the CI workflow of hashicorp/terraform-cdk

Jorge Rosillo

Coordinated Disclosure Timeline


The hashicorp/terraform-cdk repository is vulnerable to a command injection in Actions, allowing an attacker to take over the contents of the repository and leak secrets.


CDK for Terraform

Tested Version



Actions command injection in pr-copyright.yml (GHSL-2023-104)

The pr-copyright.yml workflow is triggered on pull_request_target (i.e., when a Pull Request against the base repository is created or updated), which also covers the case when a Pull Request originates from a fork.

Taking the above into account, this workflow runs the following step with data controlled by said fork (${{ github.event.pull_request.head.ref }} – the name of the fork’s branch), allowing an attacker to take over the GitHub Runner and run custom commands (potentially stealing secrets and altering the repository).

- name: Push changes
  if: steps.get_changes.outputs.changed != 0
  run: |-
    git add .
    git commit -s -m "chore: add required copyright headers"
    git push origin HEAD:${{ github.event.pull_request.head.ref }}

This issue was found by the Expression injection in Actions CodeQL query.

Proof of Concept

  1. Fork the hashicorp/terraform-cdk repository, whose name we will refer as username/terraform-cdk-fork.
  2. Create a branch in username/terraform-cdk-fork with the name main;echo${IFS}"hello";#.
  3. Push changes to the former branch.
  4. Create a pull request from username/terraform-cdk-fork:main;echo${IFS}"hello";# to hashicorp/terraform-cdk:master.
  5. Check the workflow runs for the new Actions run that will execute the command echo "hello".


This issue may lead to stealing workflow secrets and modification of the repository.



This issue was discovered and reported by GHSL team member @jorgectf (Jorge Rosillo).


You can contact the GHSL team at, please include a reference to GHSL-2023-104 in any communication regarding this issue.