In Cloud We Trust: Modifying Cloud Service Providers (CSP) Agents for C2
Yeonwoo Park, Sunggwan Choi
Talk details
This research examines how the remote access, monitoring, and CI/CD services that Cloud Service Providers offer, along with open-source agents they provide, can be modified for stage 0 and persistence payloads. Specifically, we analyzed the operations, architecture, and the source code of open-source agents related to SSM, CI/CD pipelines, and OSConfig provided by AWS, Azure, and GCP. Based on the analysis, we explain how to modify the source code of open-source agents to repurpose them for red team attacks.
Cloud Service Providers (CSPs) offer remote access and monitoring services for on-premises and multi-cloud systems to facilitate operations. Specific examples include the AWS Systems Manager, the Azure CI/CD Pipelines, and the GCP OSConfig. The agents used in these services are often open-sourced and are built on long-trusted codebases and communicate with trusted CSP endpoints. In addition, these agents often provide functionalities frequently used by C2 agents, such as interactive shells, file transfer, port forwarding, and tunneling. These characteristics allow attackers to evade detection and maintain a stable connection by leveraging trusted channels.
To provide practical and technical proof of concept, this research developed three tools, one for each CSP (AWS, Azure, GCP) that repurposed these trusted opensource agents into red team payloads:
1. EvilSSM: Modifies the source code of the AWS SSM Agent to create a single portable binary that can run even with low privileges, enabling command execution, interactive sessions, and port forwarding through the AWS SSM service
2. EvilAzp & EvilAzp-Agent: Modifies the source code of the Azure Pipelines Agent to execute commands as a single binary; incorporates code from MS Dev Tunnels and Azure Relay Bridge and packages them as plugins
3. EvilOSConfig: Modifies the GCP OS Config Agent to execute remote commands via GCP OS Policy and optional Pub/Sub-based tasking.
This session will cover the engineering patterns, demo videos, and defensive implications for each project. Following the presentation, EvilSSM, EvilAzp/Agent, and EvilOSConfig will all be released as open source on GitHub.
Outline:
1. Introduction: Cloud Services, Agents, and Trade-offs
- Brief overview of targeted cloud services, opensource agent architecture, and execution methods
- Previous Research - Abusing CSP Agents, and their limitations
- Differences between LOLRMM (Living off the Land - Remote Management and Monitoring) and LOTS (Living Off Trusted Sites)
- Pros and cons of using CSP Agents vs. Traditional commercial/opensource C2 Agents
- Potential Use Cases: Stage 0 and Persistence
2. AWS: EvilSSM
- Description, structure, execution method, and artifacts
- Code Modification - Simplification: removing user-privilege checks, service creation, path dependencies, etc.
- Code Modification - Single Binary: Reducing the number of required binaries through source code modification
- Utilization as Stage 0 via RunCommand, Session Manager, RDP, and Port Forwarding
- Demo Video (1–2 minutes): Running EvilSSM -> Executing commands using SSM and a helper Python script, port forwarding, pseudo-SOCKS, etc.
3. Azure: EvilAzp & EvilAzp-Agent
- Description, structure, and execution method of the Azure CI/CD Pipeline Agent
- Code modification - Single binary and baked configuration
- Code modification - Incorporating Dev Tunnels & Azure Relay Bridge code as plugins
- Demo video (1–2 minutes): Execute EvilAzp -> Execute commands, port forwarding via Dev Tunnels/Azure Relay Bridge
4. GCP: EvilOSConfig
- Description, structure, execution method, and command execution method of OSConfig
- Code modification - Registration: Structure of the Metadata Server and GCE identity proxying to bypass it
- Code modification - Command execution: Command execution based on OS Policy and returning command output
- Code modification - Pub/Sub: Slightly faster command execution via Google Publisher/Subscriber
- Demo Video (1–2 minutes): Command execution via EvilOSConfig
5. Defender Perspective
- Challenges
- Behavior: Relationships between endpoints and network endpoints
- IoCs: host artifacts such as directories, files, logs, and code signing