Analytic rule catalog
AWSCloudTrail - EC2 Startup Shell Script Changed
Back
| Id | f8577e4d-8481-437b-a94e-06f615985668 |
| Rulename | AWSCloudTrail - EC2 Startup Shell Script Changed |
| Description | Identifies changes to the EC2 startup script. The shell script will be executed as root/SYSTEM every time the specific instances are booted up. ref : https://github.com/RhinoSecurityLabs/pacu/blob/master/pacu/modules/ec2__startup_shell_script/main.py |
| Severity | Medium |
| Tactics | Execution |
| Techniques | T1059 |
| Required data connectors | AWS |
| Kind | Scheduled |
| Query frequency | 15m |
| Query period | 15m |
| Trigger threshold | 0 |
| Trigger operator | gt |
| Source Uri | https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Amazon%20Web%20Services/Analytic%20Rules/AWS_EC2StartupShellScriptChanged.yaml |
| Version | 1.0.1 |
| Arm template | f8577e4d-8481-437b-a94e-06f615985668.json |
AWSCloudTrail
| where EventName in~ ("ModifyInstanceAttribute", "CreateLaunchTemplate")
| extend RequestParametersJson = parse_json(RequestParameters)
| where tostring(RequestParametersJson.userData) != ""
| extend userData_ = tostring(RequestParametersJson.userData)
| extend instanceId_ = tostring(RequestParametersJson.instanceId)
| project-away SourceSystem, Category, Type, TenantId, EventVersion, SessionIssuerAccountId
| extend UserName = substring(UserIdentityPrincipalid, indexof_regex(UserIdentityPrincipalid, ":") + 1)
| extend Name = split(UserName,'@')[0],UpnSuffix = split(UserName,'@')[1]
| project TimeGenerated, EventName, UserName, Name, UpnSuffix, instanceId_, AWSRegion, SourceIpAddress, EventSource, UserIdentityArn, EventTypeName
entityMappings:
- entityType: Account
fieldMappings:
- columnName: Name
identifier: Name
- columnName: UpnSuffix
identifier: UPNSuffix
- entityType: IP
fieldMappings:
- columnName: SourceIpAddress
identifier: Address
query: |
AWSCloudTrail
| where EventName in~ ("ModifyInstanceAttribute", "CreateLaunchTemplate")
| extend RequestParametersJson = parse_json(RequestParameters)
| where tostring(RequestParametersJson.userData) != ""
| extend userData_ = tostring(RequestParametersJson.userData)
| extend instanceId_ = tostring(RequestParametersJson.instanceId)
| project-away SourceSystem, Category, Type, TenantId, EventVersion, SessionIssuerAccountId
| extend UserName = substring(UserIdentityPrincipalid, indexof_regex(UserIdentityPrincipalid, ":") + 1)
| extend Name = split(UserName,'@')[0],UpnSuffix = split(UserName,'@')[1]
| project TimeGenerated, EventName, UserName, Name, UpnSuffix, instanceId_, AWSRegion, SourceIpAddress, EventSource, UserIdentityArn, EventTypeName
id: f8577e4d-8481-437b-a94e-06f615985668
queryFrequency: 15m
alertDetailsOverride:
alertDisplayNameFormat: EC2 startup script changed on {{instanceId_}} by {{UserName}}
alertDescriptionFormat: EC2 startup script changed on {{instanceId_}} by {{UserName}} in {{AWSRegion}}.
status: Available
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Amazon%20Web%20Services/Analytic%20Rules/AWS_EC2StartupShellScriptChanged.yaml
version: 1.0.1
severity: Medium
relevantTechniques:
- T1059
name: AWSCloudTrail - EC2 Startup Shell Script Changed
kind: Scheduled
tactics:
- Execution
requiredDataConnectors:
- dataTypes:
- AWSCloudTrail
connectorId: AWS
description: |
Identifies changes to the EC2 startup script. The shell script will be executed as root/SYSTEM every time the specific instances are booted up. ref : https://github.com/RhinoSecurityLabs/pacu/blob/master/pacu/modules/ec2__startup_shell_script/main.py
customDetails:
AWSRegion: AWSRegion
EventSource: EventSource
EventName: EventName
InstanceId: instanceId_
EventType: EventTypeName
triggerOperator: gt
triggerThreshold: 0
queryPeriod: 15m
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"workspace": {
"type": "String"
}
},
"resources": [
{
"apiVersion": "2024-01-01-preview",
"id": "[concat(resourceId('Microsoft.OperationalInsights/workspaces/providers', parameters('workspace'), 'Microsoft.SecurityInsights'),'/alertRules/f8577e4d-8481-437b-a94e-06f615985668')]",
"kind": "Scheduled",
"name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/f8577e4d-8481-437b-a94e-06f615985668')]",
"properties": {
"alertDetailsOverride": {
"alertDescriptionFormat": "EC2 startup script changed on {{instanceId_}} by {{UserName}} in {{AWSRegion}}.",
"alertDisplayNameFormat": "EC2 startup script changed on {{instanceId_}} by {{UserName}}"
},
"alertRuleTemplateName": "f8577e4d-8481-437b-a94e-06f615985668",
"customDetails": {
"AWSRegion": "AWSRegion",
"EventName": "EventName",
"EventSource": "EventSource",
"EventType": "EventTypeName",
"InstanceId": "instanceId_"
},
"description": "Identifies changes to the EC2 startup script. The shell script will be executed as root/SYSTEM every time the specific instances are booted up. ref : https://github.com/RhinoSecurityLabs/pacu/blob/master/pacu/modules/ec2__startup_shell_script/main.py\n",
"displayName": "AWSCloudTrail - EC2 Startup Shell Script Changed",
"enabled": true,
"entityMappings": [
{
"entityType": "Account",
"fieldMappings": [
{
"columnName": "Name",
"identifier": "Name"
},
{
"columnName": "UpnSuffix",
"identifier": "UPNSuffix"
}
]
},
{
"entityType": "IP",
"fieldMappings": [
{
"columnName": "SourceIpAddress",
"identifier": "Address"
}
]
}
],
"OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Amazon%20Web%20Services/Analytic%20Rules/AWS_EC2StartupShellScriptChanged.yaml",
"query": "AWSCloudTrail\n| where EventName in~ (\"ModifyInstanceAttribute\", \"CreateLaunchTemplate\")\n| extend RequestParametersJson = parse_json(RequestParameters)\n| where tostring(RequestParametersJson.userData) != \"\"\n| extend userData_ = tostring(RequestParametersJson.userData)\n| extend instanceId_ = tostring(RequestParametersJson.instanceId)\n| project-away SourceSystem, Category, Type, TenantId, EventVersion, SessionIssuerAccountId\n| extend UserName = substring(UserIdentityPrincipalid, indexof_regex(UserIdentityPrincipalid, \":\") + 1)\n| extend Name = split(UserName,'@')[0],UpnSuffix = split(UserName,'@')[1]\n| project TimeGenerated, EventName, UserName, Name, UpnSuffix, instanceId_, AWSRegion, SourceIpAddress, EventSource, UserIdentityArn, EventTypeName\n",
"queryFrequency": "PT15M",
"queryPeriod": "PT15M",
"severity": "Medium",
"status": "Available",
"subTechniques": [],
"suppressionDuration": "PT1H",
"suppressionEnabled": false,
"tactics": [
"Execution"
],
"techniques": [
"T1059"
],
"templateVersion": "1.0.1",
"triggerOperator": "GreaterThan",
"triggerThreshold": 0
},
"type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
}
]
}