AWS Detection Catalogue
This page list common AWS API calls (cloudtrail) and tries to map (loosely) them to MITRE ATTACK framework. If you are hunting or handling incidents, these can be your starting points. These list are collected from various article listed below.
Initial Access
Key Cloudtrail
ConsoleLogin- Interactive AWS console accessPasswordRecoveryRequested- Password reset attemptsAssumeRoleWithWebIdentity- Federated authentication abuseGetSessionToken- Temporary credential requests
Detection Examples
SELECT eventTime, sourceIPAddress, userIdentity.userName, errorCode, errorMessage
FROM cloudtrail_logs
WHERE eventName = 'ConsoleLogin'
AND errorCode IN ('SigninFailure', 'Failed authentication')
AND eventTime > NOW() - INTERVAL '1 hour'
GROUP BY sourceIPAddress
HAVING COUNT(*) > 5;
Execution
Key Cloudtrail
StartInstance/StartInstances- EC2 instance executionInvoke- Lambda function executionSendCommand- Systems Manager command executionRunInstances- New EC2 instance creation
Detection Examples
-- Monitor SSM command execution
SELECT eventTime, userIdentity.userName, requestParameters.instanceIds,
requestParameters.parameters.commands
FROM cloudtrail_logs
WHERE eventName = 'SendCommand'
AND requestParameters.parameters.commands LIKE '%curl%'
AND requestParameters.parameters.commands LIKE '%bash%';
Enumeration/ Discovery
Key Cloudtrail
- ec2:DescribeInstances
- Describes the specified instances or all instances "What type of EC2 infrastructure is present in this account?" one of the way to do it: account id from ec2
- s3:ListObjects - Ransomware in AWS S3 SSE-C#Explaining the S3 SSE-C Ransomware Approach
- [ ] research and complete this block
- `ListSSHPublicKeys
SimulatePrincipalPolicy: The AWS Policy Simulator allows users to test an existing policy recorded in the policySourceArn field against a set of actions recorded in the actionNames field. This helps answer the question can I perform action X with policy Y.ListUsers- IAM user enumerationListRoles- IAM role enumerationListIdentities- SES identity listingListAccessKeys- Access key discoveryListServiceQuotas- Service limit discoveryListInstanceProfiles- EC2 service role discoveryListBuckets- S3 bucket enumerationListGroups- IAM group discoveryGetSendQuota- SES sending limitsGetCallerIdentity- Current identity verificationDescribeInstances- EC2 instance discoveryGetBucketAcl- S3 permissions discoveryGetBucketVersioning- S3 versioning statusGetAccountAuthorizationDetails- Comprehensive account enumeration- From - Following attackers’ (Cloud)trail in AWS Methodology and findings in the wild Datadog Security Labs
| Enumeration API call | Comment | Attacker's question being answered |
|---|---|---|
sts:GetCallerIdentity |
Returns the identity of the authenticated user | "What are the credentials I compromised?" |
ses:GetAccount |
Returns information about the SES account, including sending limits and past usage | "What's the volume of emails I can send through this account?" |
ses:GetSendQuota |
Returns SES sending limits | "What's the volume of emails I can send through this account?" |
ses:ListIdentities |
Lists verified SES senders | "Who can I impersonate?" |
sns:GetSMSAttributes |
Returns SMS sending settings | "What's the SMS monthly spend limit?" |
iam:ListUsers |
Returns IAM users in the account | "How many people are using this account?" |
ec2:DescribeRegions |
Describes the Regions that are enabled for your account, or all Regions. | "What regions are enabled that infrastructure could be set up in?" |
ec2:DescribeInstances |
Describes the specified instances or all instances | "What type of EC2 infrastructure is present in this account?" |
ec2:DescribeVpcs |
Describes one or more of your VPCs | "How is the network infrastructure set up in this account?" |
lightsail:GetRegions |
Returns a list of all valid regions for Amazon Lightsail | "What regions are enabled that infrastructure could be set up in?" |
lightsail:GetInstances |
Returns information about all Amazon Lightsail instances | "What type of Lightsail infrastructure is present in this account?" |
route53:ListDomains |
Returns domain names registered in the account | "What's the name and domain names of the organization I have compromised?" |
route53:GetHostedZoneCount |
Returns the number of hosted zones in the account | "How large is this company?" |
s3:ListBuckets |
Returns S3 buckets | "Is there sensitive data available?" |
servicequotas:ListServiceQuotas |
Returns service quotas in use for a specific service (e.g. EC2) | "How many resources can I spin up in that account?" |
Detection Examples
- from Incident Response in AWS - Chris Farris
index=cloudtrail eventName=GetCallerIdentity OR ListBuckets OR DescribeInstances | iplocation sourceIPAddress | table userIdentity.arn, sourceIPAddress, City, Country | sort -City, Country
-- Identify reconnaissance activity
WITH discovery_events AS (
SELECT eventTime, userIdentity.userName, sourceIPAddress, eventName
FROM cloudtrail_logs
WHERE eventName IN ('ListUsers', 'ListRoles', 'ListBuckets', 'DescribeInstances', 'GetCallerIdentity')
AND eventTime > NOW() - INTERVAL '1 hour'
)
SELECT userName, sourceIPAddress,
COUNT(DISTINCT eventName) as unique_discovery_actions,
COUNT(*) as total_discovery_calls
FROM discovery_events
GROUP BY userName, sourceIPAddress
HAVING COUNT(DISTINCT eventName) > 5
ORDER BY unique_discovery_actions DESC;
Persistence
Key Cloudtrail
CreateAccessKey- New programmatic access credentialsCreateUser- New IAM user creationCreateNetworkAclEntry- Network-level persistenceCreateRoute- Routing table modificationsCreateLoginProfile- Console access setupAuthorizeSecurityGroupEgress/AuthorizeSecurityGroupIngress- Firewall rule changesCreateVirtualMFADevice- MFA device setupCreateConnection- Database/service connections- creation of a EC2 key pair, is known technique - Following attackers’ (Cloud)trail in AWS Methodology and findings in the wild Datadog Security Labs
- Creating root user - Following attackers’ (Cloud)trail in AWS Methodology and findings in the wild Datadog Security Labs
create security group- Following attackers’ (Cloud)trail in AWS Methodology and findings in the wild Datadog Security LabsCreateUserfrom - The curious case of DangerDev@protonmail.meCreateLoginProfilecall which is used to give a user the ability to login through the AWS management console from The curious case of DangerDev@protonmail.me- Allow user to AssumeRole to a role that is privileged and preferably come from AWS default role. For example cat flap that allow user to AssumeRole for a
AWSControlTowerExecutionrole.
Detection Examples
from Incident Response in AWS - Chris Farris
index=cloudtrail
eventName="CreateUser"
| iplocation sourceIPAddress
| search Country!="United States"
| table userIdentity.arn, sourceIPAddress,
City, Country
-- Monitor user creation and access key generation
SELECT eventTime, userIdentity.userName, requestParameters.userName as new_user,
responseElements.accessKey.accessKeyId
FROM cloudtrail_logs
WHERE eventName IN ('CreateUser', 'CreateAccessKey', 'CreateLoginProfile')
AND userIdentity.type = 'IAMUser'
ORDER BY eventTime DESC;
Privilege Escalation
Key Cloudtrail
- The
AdministratorAccesspolicy was attached to the newly created account withAttachUserPolicythat provides full access to AWS services and resources. AssumeRoleusing external account from The curious case of DangerDev@protonmail.me. Attacker create malicious role, malicious role allows AssumeRole form external account.CreateGroup- Administrative group creationCreateRole- IAM role creationUpdateAccessKey- Access key status changesPutGroupPolicy- Inline group policy assignmentPutRolePolicy- Inline role policy assignmentPutUserPolicy- Inline user policy assignmentAttachUserPolicy- Managed policy attachment to usersAttachRolePolicy- Managed policy attachment to rolesAddRoleToInstanceProfile- EC2 service role assignmentAddUserToGroup- Group membership changes-
PutAccountDetailsread more: wiz
Amazon Simple Email Service (SES) is AWS’s cloud-based bulk email platform. By default, accounts operate in a restricted “sandbox” mode, where emails can only be sent to verified addresses and volumes are capped to 200 messages per day, at a maximum rate of one message per second. An account can be moved into the unrestricted “production” mode, in which emails can be sent to arbitrary recipients and the quota is raised, typically to 50,000 emails per day. The transition requires submitting account details for AWS review through the
PutAccountDetailsAPI, and customers who need even higher volumes can request additional capacity through a support ticket.CreateCasewas also used:But the attacker wasn’t content with the default 50,000-emails-per-day quota. They tried to open a support ticket programmatically through the
CreateCaseAPI, asking AWS to further raise their limits (ATT&CK: T1098), an attempt that failed due to insufficient permissions -
Root access
read more: Hands-On Security Tips For Centralize Root Access In AWS
- Monitor for New Permissions: Keep an eye out for any addition of permissions like
sts:AssumeRootto identities in your organization account. Any identity with this permission will be capable of assuming root access, which can pose a significant security risk. - Attack Scenario — Re-Enabling Root Login: Imagine a scenario where an attacker knows the root password of a member account, but root login for that account has been disabled. If the attacker has already compromised a principal in the organization’s AWS account that can assume root access (admittedly, an unusual situation), they might try to re-enable root login by using
AssumeRootwith theIAMCreateRootUserPasswordpolicy. They could then create a root login profile by assuming root privileges. - Watch for Suspicious Actions: A compromised identity with permission to assume root access could create significant risks for member accounts by executing suspicious actions, such as
aws iam create-login-profile. To mitigate this risk, monitor anyAssumeRootactions with theIAMCreateRootUserPasswordpolicy and closely watch for any rootCreateLoginProfileactions within member accounts. Such actions are highly unusual and should always be investigated. - Frequent
**AssumeRoot**Logs: If you notice frequentAssumeRootactions in your logs, don't be alarmed right away. These actions are likely generated by CSPM tools that are verifying root configuration across all member accounts. - [ ] research more on these detection opportunity of root access
- Monitor for New Permissions: Keep an eye out for any addition of permissions like
Detection Examples
-- Monitor privilege escalation activities
SELECT eventTime, userIdentity.userName, eventName,
requestParameters.groupName, requestParameters.roleName,
requestParameters.policyDocument, requestParameters.policyArn
FROM cloudtrail_logs
WHERE eventName IN ('PutUserPolicy', 'PutRolePolicy', 'PutGroupPolicy', 'AttachUserPolicy', 'AttachRolePolicy', 'AddUserToGroup')
AND (requestParameters.policyDocument LIKE '%"*"%'
OR requestParameters.policyArn LIKE '%AdministratorAccess%'
OR requestParameters.policyArn LIKE '%PowerUserAccess%'
OR requestParameters.groupName LIKE '%Admin%'
OR requestParameters.groupName LIKE '%Power%');
Defense Evasion
Key Cloudtrail
StopLogging- CloudTrail logging disruptionDeleteTrail- Audit trail removalUpdateTrail- Audit configuration changesPutEventSelectors- Logging scope modificationDeleteFlowLogs- VPC flow log removalDeleteDetector- GuardDuty detector deletionDeleteMembers- Security service membership removalDeleteSnapshot- Evidence destructionDeactivateMFADevice- MFA bypassDeleteCertificate- SSL certificate removal- Removing IAM users with
DeleteUser - Cleaning up policies with
DetachUserPolicyandDeleteUserPolicy - Deactivating long term access keys with
UpdateAccessKey - Cleaning up long term access keys with
DeleteAccessKey - Inspecting GuardDuty findings with
ListFindingsandGetFindingsthis is unique because Amazon Relational Database Service (RDS) console is used RDSDBinstance to access GuardDuty - For GuardDuty
DeleteDetectorUpdateDetectorCreateIPSetare nice events to look at. The first two have explicit names but the last one can be trickier and forgotten. This event allows monitoring when someone is updating the list of the GuardDuty trusted IP addresses. An attacker can use this to whitelist its C2’s IP addresses to avoid detection
Detection Examples
-- Monitor security control tampering
SELECT eventTime, userIdentity.userName, eventName, requestParameters.name,
requestParameters.detectorId, requestParameters.trailName
FROM cloudtrail_logs
WHERE eventName IN ('StopLogging', 'DeleteTrail', 'DeleteDetector', 'DeleteFlowLogs')
AND userIdentity.type != 'AWSService'
ORDER BY eventTime DESC;
index=cloudtrail
eventName=StopLogging OR DeleteTrail OR PutEventSelectors OR DeleteDetector
| iplocation sourceIPAddress
| table userIdentity.arn, sourceIPAddress, City, Country
Credential Access
Key Cloudtrail
GetSecretValue - Secrets Manager access
PutSecretValue - Secrets modification
CreateSecret - New secret creation
DeleteSecret - Secret removal
GetPasswordData - EC2 Windows password retrieval
RequestCertificate - SSL certificate requests
UpdateAssumeRolePolicy - Trust relationship changes
Detection Examples
-- Monitor credential access patterns
SELECT eventTime, userIdentity.userName, requestParameters.secretId,
requestParameters.instanceId, sourceIPAddress
FROM cloudtrail_logs
WHERE eventName IN ('GetSecretValue', 'PutSecretValue', 'CreateSecret', 'DeleteSecret', 'GetPasswordData')
AND eventTime > NOW() - INTERVAL '24 hours'
GROUP BY userIdentity.userName, sourceIPAddress
HAVING COUNT(*) > 10;
Impact
Key Cloudtrail
s3:PutObjects3:GetObject- s3 cp /
CopyObject
Creates a copy of an object that is already stored in Amazon S3. this is used in where ransomware operator encrypt S3 using own key (SSE-C). You can copy individual objects between general purpose buckets, between directory buckets, and between general purpose buckets and directory buckets. Both the Region that you want to copy the object from and the Region that you want to copy the object to must be enabled for your account.
--command used
aws s3 cp s3://<bucket_with_data>/<file_name> s3://<bucket_with_data>/<file_name> \
--sse-c AES256 \
--sse-c-key <customer_provided_key_here>
PutBucketVersioning- S3 versioning manipulationDeleteObject- S3 object deletionRunInstances- Resource creation for impactDeleteAccountPublicAccessBlock- S3 public access enablingDeleteDBInstance- Database deletionModifyDBInstance- Database modifications3:DeleteObjectVersions3:PutLifecycleConfigurationransomware operator used to auto delete after a certain time
Detection Examples
-- Monitor high-impact activities
SELECT eventTime, userIdentity.userName, eventName,
requestParameters.instanceType, requestParameters.minCount,
requestParameters.versioningConfiguration, requestParameters.bucketName,
requestParameters.dbInstanceIdentifier
FROM cloudtrail_logs
WHERE (eventName = 'RunInstances' AND requestParameters.instanceType IN ('c5.xlarge', 'c5.2xlarge', 'c5.4xlarge'))
OR (eventName = 'PutBucketVersioning' AND requestParameters.versioningConfiguration LIKE '%Suspended%')
OR eventName = 'DeleteAccountPublicAccessBlock'
OR eventName = 'DeleteObject'
OR eventName = 'DeleteDBInstance'
ORDER BY eventTime DESC;
Lateral Movement
Key Cloudtrail
- sts:AssumeRole (Cloud to Cloud) -- Role assumption for lateral access
- ssm:StartSession (Cloud to Ground)
- ssm:SendCommand (Cloud to Ground)
- ec2-instance-connect:SendSSHPublicKey (Cloud to Ground)
- ec2:AuthorizeSecurityGroupIngress (Cloud to Ground, or Ground to Ground)
- VPC Flow Logs (Ground to Ground)
SwitchRole- Console role switching
Detection Examples
-- Monitor cross-account access
SELECT eventTime, userIdentity.arn, requestParameters.roleArn,
requestParameters.roleSessionName, sourceIPAddress
FROM cloudtrail_logs
WHERE eventName = 'AssumeRole'
AND requestParameters.roleArn NOT LIKE '%:123456789012:%' -- Your account ID
ORDER BY eventTime DESC;
Exfiltration
Key Cloudtrail
GetObject- S3 object retrievalCopyObject- S3 object copyingCreateSnapshot- EBS snapshot creationModifySnapshotAttributes- Snapshot sharing configurationModifyImageAttribute- AMI sharing setupSharedSnapshotCopyInitiated- Cross-region snapshot copyingSharedSnapshotVolumeCreated- Snapshot volume creationModifyDBSnapshotAttribute- RDS snapshot sharingCreateDBSnapshot- Database snapshot creationPutBucketPolicy- S3 bucket policy modificationPutBucketAcl- S3 bucket ACL changes
Detection Examples
-- Monitor data exfiltration activities
SELECT eventTime, userIdentity.userName, eventName,
requestParameters.snapshotId, requestParameters.imageId,
requestParameters.userIds, requestParameters.valuesToAdd,
requestParameters.bucketName, requestParameters.key
FROM cloudtrail_logs
WHERE (eventName IN ('ModifySnapshotAttribute', 'ModifyImageAttribute', 'ModifyDBSnapshotAttribute')
AND (requestParameters.userIds IS NOT NULL OR requestParameters.valuesToAdd IS NOT NULL))
OR (eventName = 'GetObject' AND sourceIPAddress NOT LIKE '10.%' AND sourceIPAddress NOT LIKE '172.%' AND sourceIPAddress NOT LIKE '192.168.%')
ORDER BY eventTime DESC;
Other
Anomalies
Error message from anomaly IP
Incident Response in AWS - Chris Farris
index=cloudtrail errorMessage=* | iplocation sourceIPAddress | stats count by City, Country | sort -City, Country
Sensitive IAM actions
why worry on a whole lot api calls, these are the most sensitive according to sensitive iam - CredentialExposure - DataAccess - PrivEsc - ResourceExposure
References
- cloud-security
- sensitive iam
- cloudtrail cheatsheet
- The curious case of DangerDev@protonmail.me
- Following attackers’ (Cloud)trail in AWS Methodology and findings in the wild Datadog Security Labs
- Hands-On Security Tips For Centralize Root Access In AWS
- AWS Detection Engineering
- Chris Farris's AWS IR
- Ransomware in Amazon S3: SSE-C