SlideShare a Scribd company logo
7
Most read
14
Most read
Terraform Unleashed: Crafting custom
Provider exploits for Ultimate control
Rupali Dash brings over 8 years of cybersecurity experience,
specializing in penetration testing and red teaming. Currently a Lead
Security Architect at Axl.net Security, she oversees cloud security and
penetration testing engagements. Her credentials include notable
certifications like OSCP, OSWE, AWS Security Specialist, and GCPN. She
has presented at prominent conferences like Black Hat Asia,
DevSecCon, and CoCon.
Alex Foley is a broadly experienced security professional with over 25 years of
experience in IT and cybersecurity. He is the founder and CEO of Axl.net Security.
He has operated and continues to operate as the vCISO of multiple startup
companies with the support of the team from Axl.net Security. Throughout his
career, he's had the opportunity to wear many hats and do "all the things" within
product development, operations, and security. This broad experience has
enabled Alex to bring this depth of understanding to the CISO roles. Alex's skill set
focuses on blue team operations, which complements Rupali's expertise in red
team activities.
Who Are We ??
Who Does The Talk Cater To
Pen testers and Red-teamers
who will be testing an cloud
infrastructure.
Security Architects managing
the security posture of the
cloud infrastructure.
Terraform Enterprise Deployment Architecture
Terraform Workflow
► - In-order to provision this code the user logs in to the terraform
enterprise first and provides the AWS Credentials of the account for
the resource provisioning .
► Upon Terraform Init the TFE Spins up the worker container in the TFE
AWS account and Downloads the required provides specified in the
provider block.
► During Terraform Plan, The Terraform API zips the IAC code and the
Provided authentication credentials along with the terraform binary
and stores it over the worker container.
► It also performs a state lock using dynamo DB for that specific
workspace so that no two TFE plan can run simultaneously for a
specific workspace and it ques the job.
► It also downloads the Sentinel policies associated with the
workspace on to the worker container.
► During the Terraform plan once the sentinel policies are validated
against the TFE plan out out, Terraform generates a newer set of
credentials using the provided AWS credentials in the terraform file
which will be used to provision the resource in the clients AWS
account.
► Once the Apply is completed the worker container stores the
generated terraform state file over the s3 bucket and destroyes the
container.
Terraform
Provider
►A terraform provider is a binary
written in go that interacts with
terraform binary over RPC &
enables interaction with the
provider API. This includes
Cloud providers and
Software-as-a-service providers.
The providers are specified in
the Terraform configuration
code. They tell Terraform which
services it needs to interact
with.
Key-RISK
Terraform binaries are
executables which will
be downloaded into
the emphiral container
during terraform init.
Terraform Provider runs
with the highest
privilege on the worker
container and hence
have access to all the
mounted file system as
well as the AWS STS
credentials. The TFE
worker container
needs to have the
read access to the s3
and RDS instance
where the TFE state file
gets stored as a part of
application.
In a scenario where
multiple providers are
invoked for a specific
Terraform Plan, Both
the providers will have
access to the TFE
environment variables
and the host file
system.
Attack-1: Custom provider with
filesystem access to gain access to
the host file system
● In Golang Import os/exec and import
syscall modules enables the binary to
interact with the host file system.
● Create the data source to read an
environment variable & register this
new data source in your provider.go
file.
● Use “go build” command to build the
provider.
Exploit ( System File Read)
Create a Terraform configuration file that uses the new data source to read the /etc/passwd file on the host.
Attack-2: Custom provider with Code Execution feature
Terraform-provider-cmdexec is a custom built provider
that provides command execution capability through
Terraform Configuration. Below is the example of the main.tf file
used to leverage the provider to execute the command.
https://github.com/rung/terraform-provider-cmdexec
https://alex.kaskaso.li/post/terraform-plan-rce
► Execute Commands on the Terraform
container
► Provision highly privileged roles / resources
by Bypassing sentinel policies to gain
persistence.
► Exfiltrate Vaulted secrets from the TFE
container.
► Manipulate state files resulting in deleting
resources in the existing cloud accounts.
► Gain access to PII data in Production
accounts.
► Supply chain threats to organizations using
the malicious providers.
Why the Terraform
Provider and not the
Provisioners ?
►Terraform Provisioner has
local_exec() and remote_exec()
capability which helps to execute
commands on the TFE infrastructure
as a part of terraform apply.
►Terraform Provisioners are called only
after a successful plan and prior to
the Terraform Apply. Hence usage of
sentinel policy can be leveraged to
block those attacks.
►Terraform Provider block executes
during the terraform plan and hence
It cannot be blocked/restricted
through Sentinel
Provider
Security Risks
►1: Malevolence of the Binary: This is to
ensure that the provider binary doesn’t
contain any malware , packers or custom
exploits.
►2: Impact on the TFE infrastructure: This will
provide insight on the different
functionalities and access level of the
provider in the TFE infrastructure.
►3: Out bound Network communication:
This will provide insight on the different
end points/APIs embedded into the
binary
Terraform Unleashed - Crafting Custom Provider Exploits for Ultimate Control
Terraform Unleashed - Crafting Custom Provider Exploits for Ultimate Control
Conclusions
● Provider Attack Types
○ Third Party Providers
○ Insider Threat
● Defense
○ Updated Training
○ Updated Detection Technology
○ Updated Processes
Questions?
►rdash@axl.net
►afoley@axl.net

More Related Content

PPTX
Hashicorp-Certified-Terraform-Associate-v3-edited.pptx
PDF
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
PDF
Terraform-2.pdf
PDF
Terraform modules and some of best-practices - March 2019
PDF
leboncoin DataEngineering / Terraform - beginner to advanced
PDF
Terraform AWS modules and some best-practices - May 2019
PPTX
Hashicorp-Certified-Terraform-Associate_V1
PDF
Terraform AWS modules and some best practices - September 2019
Hashicorp-Certified-Terraform-Associate-v3-edited.pptx
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Terraform-2.pdf
Terraform modules and some of best-practices - March 2019
leboncoin DataEngineering / Terraform - beginner to advanced
Terraform AWS modules and some best-practices - May 2019
Hashicorp-Certified-Terraform-Associate_V1
Terraform AWS modules and some best practices - September 2019

Similar to Terraform Unleashed - Crafting Custom Provider Exploits for Ultimate Control (20)

PPTX
Infrastructure as Code with Terraform.pptx
PDF
OSDC 2019 | Terraform best practices with examples and arguments by Anton Bab...
PDF
DevOps Braga #9: Introdução ao Terraform
PPTX
Terraform - The Road to Self-Service
PDF
Infrastructure as Code with Terraform
PDF
Terraform: Check Your Source
PDF
Terraform modules and best-practices - September 2018
PDF
Managing AWS Using Terraform AWS Atlanta 2018-07-18
PDF
APIsecure 2023 - How to abuse Terraform to elevate access, Mike McCabe
PDF
Managing AWS Using Terraform AWS Chicago-Suburbs 2018-01-18
PDF
Microservices with Terraform, Docker and the Cloud. JavaOne 2017 2017-10-02
PDF
Manage any AWS resources with Terraform 0.12 - April 2020
PPTX
Iniciando com Terraform
PPTX
Terraform - Shared Definitions and Variable Inheritance
PDF
Terraform at Scale - All Day DevOps 2017
PPTX
"Continuously delivering infrastructure using Terraform and Packer" training ...
PPTX
Terraform Abstractions for Safety and Power
PDF
Microservices with Terraform, Docker and the Cloud. Chicago Coders Conference...
PPTX
Terraform infrastructure as code for mere mortals
PPTX
Reusable, composable, battle-tested Terraform modules
Infrastructure as Code with Terraform.pptx
OSDC 2019 | Terraform best practices with examples and arguments by Anton Bab...
DevOps Braga #9: Introdução ao Terraform
Terraform - The Road to Self-Service
Infrastructure as Code with Terraform
Terraform: Check Your Source
Terraform modules and best-practices - September 2018
Managing AWS Using Terraform AWS Atlanta 2018-07-18
APIsecure 2023 - How to abuse Terraform to elevate access, Mike McCabe
Managing AWS Using Terraform AWS Chicago-Suburbs 2018-01-18
Microservices with Terraform, Docker and the Cloud. JavaOne 2017 2017-10-02
Manage any AWS resources with Terraform 0.12 - April 2020
Iniciando com Terraform
Terraform - Shared Definitions and Variable Inheritance
Terraform at Scale - All Day DevOps 2017
"Continuously delivering infrastructure using Terraform and Packer" training ...
Terraform Abstractions for Safety and Power
Microservices with Terraform, Docker and the Cloud. Chicago Coders Conference...
Terraform infrastructure as code for mere mortals
Reusable, composable, battle-tested Terraform modules
Ad

More from Cloud Village (18)

PPTX
Unexpected Leaks in AWS Transit Gateways
PDF
The Rise of the Planet of the Agents: LLM-based AI Agents and Cloud Security ...
PDF
Creating Azure Policy Compliant Backdoor
PPTX
Kicking in the Door to the Cloud: Exploiting Cloud Provider Vulnerabilities f...
PDF
Cloud Tripwires: fighting stealth with stealth
PPTX
Connecting the Dots - Mastering Alert Correlation for Proactive Defense in th...
PDF
Runtime Reachability: Prioritizing Vulnerabilities with eBPF & Continuous Pro...
PPTX
Revealing Choke Points - Practical Tactics for Boosting Cloud Security
PDF
Finding Holes in Conditional Access Policies
PPTX
One Click, Six Services - Abusing The Dangerous Multi-service Orchestration P...
PPTX
Workshop: Hands-On Container Image Security Mastering Sigstore for Unbreachab...
PDF
DC 32: Epyon - Attacking DevOps environments
PDF
Exploit K8S via Misconfiguration .YAML in CSP environments
PDF
Cloud Offensive Breach and Risk Assessment (COBRA)
PDF
One Port to Serve Them All - Google GCP Cloud Shell Abuse
PDF
The Oracle Awakens: Demystifying Privilege Escalation in the cloud
PDF
Catch them all! Detection engineering and purple teaming in the cloud
PDF
Gone in 60 Seconds… How Azure AD/Entra ID Tenants are Compromise
Unexpected Leaks in AWS Transit Gateways
The Rise of the Planet of the Agents: LLM-based AI Agents and Cloud Security ...
Creating Azure Policy Compliant Backdoor
Kicking in the Door to the Cloud: Exploiting Cloud Provider Vulnerabilities f...
Cloud Tripwires: fighting stealth with stealth
Connecting the Dots - Mastering Alert Correlation for Proactive Defense in th...
Runtime Reachability: Prioritizing Vulnerabilities with eBPF & Continuous Pro...
Revealing Choke Points - Practical Tactics for Boosting Cloud Security
Finding Holes in Conditional Access Policies
One Click, Six Services - Abusing The Dangerous Multi-service Orchestration P...
Workshop: Hands-On Container Image Security Mastering Sigstore for Unbreachab...
DC 32: Epyon - Attacking DevOps environments
Exploit K8S via Misconfiguration .YAML in CSP environments
Cloud Offensive Breach and Risk Assessment (COBRA)
One Port to Serve Them All - Google GCP Cloud Shell Abuse
The Oracle Awakens: Demystifying Privilege Escalation in the cloud
Catch them all! Detection engineering and purple teaming in the cloud
Gone in 60 Seconds… How Azure AD/Entra ID Tenants are Compromise
Ad

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Cloud computing and distributed systems.
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Spectroscopy.pptx food analysis technology
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
cuic standard and advanced reporting.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
Electronic commerce courselecture one. Pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Programs and apps: productivity, graphics, security and other tools
Unlocking AI with Model Context Protocol (MCP)
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Empathic Computing: Creating Shared Understanding
Digital-Transformation-Roadmap-for-Companies.pptx
NewMind AI Weekly Chronicles - August'25-Week II
Reach Out and Touch Someone: Haptics and Empathic Computing
Cloud computing and distributed systems.
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Review of recent advances in non-invasive hemoglobin estimation
Spectral efficient network and resource selection model in 5G networks
Spectroscopy.pptx food analysis technology
A comparative analysis of optical character recognition models for extracting...
cuic standard and advanced reporting.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm

Terraform Unleashed - Crafting Custom Provider Exploits for Ultimate Control

  • 1. Terraform Unleashed: Crafting custom Provider exploits for Ultimate control
  • 2. Rupali Dash brings over 8 years of cybersecurity experience, specializing in penetration testing and red teaming. Currently a Lead Security Architect at Axl.net Security, she oversees cloud security and penetration testing engagements. Her credentials include notable certifications like OSCP, OSWE, AWS Security Specialist, and GCPN. She has presented at prominent conferences like Black Hat Asia, DevSecCon, and CoCon. Alex Foley is a broadly experienced security professional with over 25 years of experience in IT and cybersecurity. He is the founder and CEO of Axl.net Security. He has operated and continues to operate as the vCISO of multiple startup companies with the support of the team from Axl.net Security. Throughout his career, he's had the opportunity to wear many hats and do "all the things" within product development, operations, and security. This broad experience has enabled Alex to bring this depth of understanding to the CISO roles. Alex's skill set focuses on blue team operations, which complements Rupali's expertise in red team activities. Who Are We ??
  • 3. Who Does The Talk Cater To Pen testers and Red-teamers who will be testing an cloud infrastructure. Security Architects managing the security posture of the cloud infrastructure.
  • 6. ► - In-order to provision this code the user logs in to the terraform enterprise first and provides the AWS Credentials of the account for the resource provisioning . ► Upon Terraform Init the TFE Spins up the worker container in the TFE AWS account and Downloads the required provides specified in the provider block. ► During Terraform Plan, The Terraform API zips the IAC code and the Provided authentication credentials along with the terraform binary and stores it over the worker container. ► It also performs a state lock using dynamo DB for that specific workspace so that no two TFE plan can run simultaneously for a specific workspace and it ques the job. ► It also downloads the Sentinel policies associated with the workspace on to the worker container. ► During the Terraform plan once the sentinel policies are validated against the TFE plan out out, Terraform generates a newer set of credentials using the provided AWS credentials in the terraform file which will be used to provision the resource in the clients AWS account. ► Once the Apply is completed the worker container stores the generated terraform state file over the s3 bucket and destroyes the container.
  • 7. Terraform Provider ►A terraform provider is a binary written in go that interacts with terraform binary over RPC & enables interaction with the provider API. This includes Cloud providers and Software-as-a-service providers. The providers are specified in the Terraform configuration code. They tell Terraform which services it needs to interact with.
  • 8. Key-RISK Terraform binaries are executables which will be downloaded into the emphiral container during terraform init. Terraform Provider runs with the highest privilege on the worker container and hence have access to all the mounted file system as well as the AWS STS credentials. The TFE worker container needs to have the read access to the s3 and RDS instance where the TFE state file gets stored as a part of application. In a scenario where multiple providers are invoked for a specific Terraform Plan, Both the providers will have access to the TFE environment variables and the host file system.
  • 9. Attack-1: Custom provider with filesystem access to gain access to the host file system ● In Golang Import os/exec and import syscall modules enables the binary to interact with the host file system. ● Create the data source to read an environment variable & register this new data source in your provider.go file. ● Use “go build” command to build the provider.
  • 10. Exploit ( System File Read) Create a Terraform configuration file that uses the new data source to read the /etc/passwd file on the host.
  • 11. Attack-2: Custom provider with Code Execution feature Terraform-provider-cmdexec is a custom built provider that provides command execution capability through Terraform Configuration. Below is the example of the main.tf file used to leverage the provider to execute the command. https://github.com/rung/terraform-provider-cmdexec https://alex.kaskaso.li/post/terraform-plan-rce
  • 12. ► Execute Commands on the Terraform container ► Provision highly privileged roles / resources by Bypassing sentinel policies to gain persistence. ► Exfiltrate Vaulted secrets from the TFE container. ► Manipulate state files resulting in deleting resources in the existing cloud accounts. ► Gain access to PII data in Production accounts. ► Supply chain threats to organizations using the malicious providers.
  • 13. Why the Terraform Provider and not the Provisioners ? ►Terraform Provisioner has local_exec() and remote_exec() capability which helps to execute commands on the TFE infrastructure as a part of terraform apply. ►Terraform Provisioners are called only after a successful plan and prior to the Terraform Apply. Hence usage of sentinel policy can be leveraged to block those attacks. ►Terraform Provider block executes during the terraform plan and hence It cannot be blocked/restricted through Sentinel
  • 14. Provider Security Risks ►1: Malevolence of the Binary: This is to ensure that the provider binary doesn’t contain any malware , packers or custom exploits. ►2: Impact on the TFE infrastructure: This will provide insight on the different functionalities and access level of the provider in the TFE infrastructure. ►3: Out bound Network communication: This will provide insight on the different end points/APIs embedded into the binary
  • 17. Conclusions ● Provider Attack Types ○ Third Party Providers ○ Insider Threat ● Defense ○ Updated Training ○ Updated Detection Technology ○ Updated Processes