Command and Scripting Interpreter: Cloud API

Other sub-techniques of Command and Scripting Interpreter (1)
ID Name
T1059.009 Cloud API

Adversaries may abuse cloud APIs to execute malicious commands. APIs available in cloud environments provide various functionalities and are a feature-rich method for programmatic access to nearly all aspects of a tenant. These APIs may be utilized through various methods such as command line interpreters (CLIs), in-browser Cloud Shells, PowerShell [MITRE] modules like Azure for PowerShell, or software developer kits (SDKs) available for languages such as Python [MITRE] .

Cloud API functionality may allow for administrative access across all major services in a tenant such as compute, storage, identity and access management (IAM), networking, and security policies.

With proper permissions (often via use of credentials such as Application Access Token [MITRE] and Web Session Cookie [MITRE] ), adversaries may abuse cloud APIs to invoke various functions that execute malicious actions. For example, CLI and PowerShell functionality may be accessed through binaries installed on cloud-hosted or on-premises hosts or accessed through a browser-based cloud shell offered by many cloud platforms (such as AWS, Azure, and GCP). These cloud shells are often a packaged unified environment to use CLI and/or scripting modules hosted as a container in the cloud environment.

AWS Specific Content


A prerequisite for this technique is that a threat actor has already gained control of an AWS identity with the permissions to perform the actions in the AWS CloudTrail Event Name(s) section.

With access to an AWS identity that has the appropriate permissions, threat actors may abuse cloud APIs to execute unauthorized commands, such as AWS CloudShell. AWS CloudShell, allows users to manage and interact with AWS resources directly from a browser when accessing the AWS Management Console. Actions performed using CloudShell are still restricted by the permissions granted to the identity that is used to invoke the CloudShell environment.

Detection

AWS Specific Content


When this technique is used by the threat actor, actions taken by the threat actor using the credentials obtained will be logged in CloudTrail. You can use the Event History page in the AWS CloudTrail console to view the last 90 days of management events in an AWS Region for the events listed in the AWS CloudTrail Event Name(s) section, such as cloudshell:CreateEnvironment or cloudshell:CreateSession.

A separate CloudTrail trail will give you an ongoing record of events in your AWS account past 90 days and can be configured to log events in multiple regions. You can also review events using the console as well as the AWS CLI.

It is also possible to create a CloudWatch metric filter to watch for when specific AWS API calls are used and perform notification actions if logged, and additionally configure CloudWatch to automatically perform an action in response to an alarm.


Mitigation

AWS Specific Content


You can make sure that principals are scoped with the least-privileged permissions necessary to perform duties, limiting the ability to perform unauthorized actions in an AWS account when not required. One possible method of applying the principle of least-privileged permissions is to use Service Control Policies to restrict the maximum available permissions for the IAM users and IAM roles within your AWS Organizations accounts (note - you should test SCPs in a development environment before deploying them in production).

You can also use IAM Access Analyzer to regularly review and verify access and manage permissions across your AWS environment, which will highlight AWS identities with excessive permissions and the actions performed by those identities.


References

AWS Specific Information


AWS Services:
  • AWS CloudShell
AWS CloudTrail Event Names:
  • cloudshell:CreateEnvironment
  • cloudshell:CreateSession

Technique Information

ID: T1059.009
Aliases: T1059.009
Sub-technique of: T1059
Tactics:
  • Execution
Platforms:
  • IaaS
  • Azure AD
  • Office 365
  • SaaS
  • Google Workspace
  • Amazon Web Services (AWS)
Created: 12 Sep 2024
Last Modified: 30 May 2025