Beginner Friendly
![]()
Abuse SSTI and IAP Tunneling to Increase Access
Abuse SSTI and IAP Tunneling to Increase Access is a premium Pwned Labs lab where you exploit server-side template injection in a public web application for code execution, tunnel into private resources through Google Cloud Identity-Aware Proxy, access a Cloud SQL database, loot Cloud Storage, and abuse Cloud Run and Cloud Build.
Server-side template injection opens the door and Identity-Aware Proxy tunneling widens it. Chain SSTI to code execution and tunnel through GCP IAP to reach Cloud SQL and beyond.
Overview
Server-side template injection opens the door and Identity-Aware Proxy tunneling widens it. In this lab you will chain SSTI to code execution and tunnel through GCP IAP to reach Cloud SQL and beyond.
Scenario
You are on a red team engagement against Mega Big Tech, whose applications run on Google Cloud. A public web application is in scope. Show how a template injection flaw can lead to deeper network access.
Lab prerequisites
- Familiarity with the Linux command line
- Familiarity with Google Cloud and web application attacks
Learning outcomes
- Exploit server-side template injection (SSTI) for code execution
- Tunnel into private resources through GCP Identity-Aware Proxy (IAP)
- Access a Cloud SQL database
- Loot Google Cloud Storage
- Abuse Cloud Run and Cloud Build
Real-world context
Template injection flaws routinely lead to full remote code execution. Identity-Aware Proxy is designed to protect internal services, but misconfiguration can turn it into a tunnel for attackers.
KEY TAKEAWAY
Server-side template injection turns user input into code that the server runs. In Google Cloud that foothold is a starting point: Identity-Aware Proxy TCP forwarding lets an authorized identity reach VM instances that have no external IP address, so the identities allowed to use it decide which private resources an attacker can reach.
What this lab covers
Pwned Labs provisions a live Google Cloud environment for this lab, so you work the full attack chain against real infrastructure rather than a simulation.
The scenario is a red team engagement against Mega Big Tech, whose applications run on Google Cloud, with a public web application in scope. You exploit server-side template injection in that application to gain code execution.
The lab then moves deeper into the network. You tunnel into private resources through Identity-Aware Proxy, access a Cloud SQL database, loot Google Cloud Storage, and abuse Cloud Run and Cloud Build.
It is rated beginner. The listed prerequisites are familiarity with the Linux command line, with Google Cloud and with web application attacks.
How template injection leads to deeper access
Server-side template injection happens when an application builds a template from user input instead of passing that input to the template as data. Template engines evaluate expressions when they render, so input that is treated as template syntax runs on the server, and in many engines that evaluation can reach the underlying language and from there operating system commands.
Once commands run on a Google Cloud workload, the workload's identity is within reach. Cloud Run services and Compute Engine instances obtain access tokens for their service accounts from the metadata server, so code running in the workload can act with that service account's permissions.
Identity-Aware Proxy TCP forwarding lets an authorized identity open an encrypted tunnel to TCP ports on VM instances that have no external IP address or that do not permit direct access from the internet. Access depends on the IAP-secured Tunnel User role and on a firewall rule that admits the IAP address range, so an attacker who holds an identity with tunnel access can reach private services that were never exposed to the internet.
Cloud Build and Cloud Run are attractive next steps because both run work as a service account. Depending on the organization's settings, Cloud Build runs builds as the Compute Engine default service account or the legacy Cloud Build service account, and Cloud Run uses the Compute Engine default service account as a service's identity unless another one is configured. Google notes that default service accounts may have permissions that are broader than the workload needs.
How to detect this in your own environment
At the application, watch for template syntax in request parameters and for template engine errors in the logs. A web process that starts a shell or other unexpected child processes is a stronger signal, because it does not depend on recognizing the input.
Treat tunnel access as privileged. Changes to who holds the IAP-secured Tunnel User role are IAM policy changes, which are written to Admin Activity audit logs. Where firewall or VPC flow logging is enabled, connections that arrive from the IAP range 35.235.240.0/20 on ports that are not normally administered that way are worth investigating.
Cloud Build build creation is recorded in Admin Activity audit logs, so builds started by an identity that does not normally create them, or outside the usual pipeline, stand out. Service account tokens used from outside the workload they belong to are a sign of theft regardless of how it happened.
How to prevent it
Do not build templates from user input. Pass user data to templates as variables, and where users have to supply templates, use a logic-less or sandboxed engine while treating the sandbox as a mitigation rather than a guarantee.
Grant the IAP-secured Tunnel User role only to the people who administer specific instances, at the instance level rather than across the project where possible, and limit the firewall rule for the IAP range to the instances and ports that need it.
Give Cloud Run services and Cloud Build their own narrowly scoped service accounts instead of the defaults, and restrict who can create builds or deploy services, since either action can run code as a service account.
Keep Cloud SQL and other private services reachable only from the networks that need them, and do not treat a private IP address as a substitute for authentication.
Real-world context
Template injection flaws can lead directly to remote code execution, which makes them a high-impact class of web vulnerability. Identity-Aware Proxy is designed to protect internal services, but a misconfiguration, such as tunnel access granted too broadly, can turn it into a route for attackers into the private network.
The cloud consequence is what raises the severity. A code execution flaw in an application hosted on Google Cloud can lead to the workload's service account, and from there to the databases, storage and build systems behind the application.
The pattern maps to MITRE ATT&CK T1190 Exploit Public-Facing Application, T1572 Protocol Tunneling and T1530 Data from Cloud Storage.
Applying this at work
- Search your applications for any place where user input becomes part of a template rather than a variable passed to it.
- Review who holds the IAP-secured Tunnel User role, and narrow project-wide grants to specific instances.
- Check that firewall rules for the IAP range 35.235.240.0/20 cover only the instances and ports that need tunnel access.
- Replace default service accounts on Cloud Run services and Cloud Build with narrowly scoped ones.
- Alert on Cloud Build builds created by identities that do not normally create them.
Frequently asked questions
What is server-side template injection?
A vulnerability where user input is interpreted as template syntax by a server-side template engine instead of being treated as data. Because template engines evaluate expressions, the flaw can often be escalated from reading data to running code on the server.
What is IAP TCP forwarding?
A Google Cloud Identity-Aware Proxy feature that lets authorized identities open an encrypted tunnel to TCP ports, such as SSH and RDP, on VM instances that have no external IP address. It is controlled by the IAP-secured Tunnel User role and by a firewall rule that admits the IAP address range.
Why are Cloud Build and Cloud Run useful to an attacker?
Both run work as a service account. An attacker who can create builds or deploy services may be able to run code with that service account's permissions, and default service accounts may hold broader permissions than the workload needs.
Do I need my own Google Cloud account to practice this?
No. The lab runs in a live Google Cloud environment that Pwned Labs provisions for you, so there is nothing to set up and no risk to your own project.
Which Pwned Labs certification covers Google Cloud attack paths?
The Pwned Labs Google Cloud Red Team Professional (GCRTP) certification covers attacks on Google Cloud and Google Workspace, and its bootcamp includes service account impersonation and Cloud Build token theft. It is assessed with a 24-hour, hands-on exam in a live Google Cloud environment.
About Pwned Labs
Pwned Labs is a hands-on cloud and AI offensive security training platform. It runs real-world attack labs and bootcamps for AWS, Azure, GCP, Kubernetes and AI systems, including the ACRTP, MCRTP, GCRTP, KRTP and AISRTP certifications. Free labs are at pwnedlabs.io/explore.
Cloud Security Training To Protect Your Business
Pwned Labs for Business gives your team access to dedicated business content, including labs and cyber ranges.
We also offer in-person or remote workshops, and our cloud penetration services are helping businesses become more secure!