Detection rules › Panther
Lambda Configuration Updated with Layers by User
Detects when Lambda function configuration is updated with layers by an IAM user, federated user, or AWS SSO user. Lambda layers can execute code before the main function, making them a stealthy persistence mechanism. This may indicate compromised credentials, a developer bypassing CI/CD guardrails, or insider threat activity.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Initial Access | T1078 Valid Accounts |
| Persistence | T1078 Valid Accounts |
| Privilege Escalation | T1078 Valid Accounts |
| Stealth | T1078 Valid Accounts |
Rule body yaml
AnalysisType: rule
Filename: aws_add_malicious_lambda_extension.py
RuleID: "AWS.Lambda.UpdateFunctionConfiguration"
DisplayName: "Lambda Configuration Updated with Layers by User"
Enabled: true
LogTypes:
- AWS.CloudTrail
Reports:
MITRE ATT&CK:
- TA0007:T1078
Severity: High
CreateAlert: true
Description: >
Detects when Lambda function configuration is updated with layers by an IAM user,
federated user, or AWS SSO user. Lambda layers can execute code before the main function,
making them a stealthy persistence mechanism. This may indicate compromised credentials,
a developer bypassing CI/CD guardrails, or insider threat activity.
Runbook: |
Verify the user identity and layer ARNs are authorized.
Check if layers are from trusted sources (same account, known publishers).
If unauthorized:
- Disable the user's access key or revoke the SSO session
- Revert Lambda configuration to previous version
- Investigate credential compromise
Reference: https://stratus-red-team.cloud/attack-techniques/AWS/aws.persistence.lambda-layer-extension/
Tests:
- Name: IAM User Updates Lambda Configuration with Layers
ExpectedResult: true
Log:
{
"eventVersion": "1.05",
"userIdentity": {
"type": "IAMUser",
"principalId": "AIDAI123456789EXAMPLE",
"arn": "arn:aws:iam::123456789012:user/john.developer",
"accountId": "123456789012",
"accessKeyId": "AKIAI123456789EXAMPLE",
"userName": "john.developer"
},
"eventTime": "2019-01-01T00:00:00Z",
"eventSource": "lambda.amazonaws.com",
"eventName": "UpdateFunctionConfiguration20150331v2",
"awsRegion": "us-west-2",
"sourceIPAddress": "203.0.113.50",
"userAgent": "aws-cli/2.13.5 Python/3.11.4",
"requestParameters": {
"functionName": "production-api"
},
"responseElements": {
"functionName": "production-api",
"layers": [
{
"arn": "arn:aws:lambda:us-west-2:123456789012:layer:malicious-layer:1"
}
]
},
"requestID": "1",
"eventID": "1",
"readOnly": false,
"eventType": "AwsApiCall",
"recipientAccountId": "123456789012",
"p_log_type": "AWS.CloudTrail"
}
- Name: AssumedRole Updates Lambda Configuration with Layers (Normal CI/CD)
ExpectedResult: false
Log:
{
"eventVersion": "1.05",
"userIdentity": {
"type": "AssumedRole",
"principalId": "tester",
"arn": "arn:aws:sts::123456789012:assumed-role/tester",
"accountId": "123456789012",
"accessKeyId": "1",
"sessionContext": {
"sessionIssuer": {
"type": "Role",
"principalId": "1111",
"arn": "arn:aws:iam::123456789012:role/tester",
"accountId": "123456789012",
"userName": "Tester"
},
"webIdFederationData": {},
"attributes": {
"mfaAuthenticated": "true",
"creationDate": "2019-01-01T00:00:00Z"
}
}
},
"eventTime": "2019-01-01T00:00:00Z",
"eventSource": "lambda.amazonaws.com",
"eventName": "UpdateFunctionConfiguration20150331v2",
"awsRegion": "us-west-2",
"sourceIPAddress": "111.111.111.111",
"userAgent": "console.amazonaws.com",
"requestParameters": {
"functionName": "my-lambda-function"
},
"responseElements": {
"layers": [
{
"arn": "arn:aws:lambda:us-west-2:123456789012:layer:my-layer:1"
}
]
},
"requestID": "1",
"eventID": "1",
"readOnly": false,
"eventType": "AwsApiCall",
"recipientAccountId": "123456789012",
"p_log_type": "AWS.CloudTrail"
}
- Name: SSO AssumedRole Updates Lambda Configuration with Layers
ExpectedResult: true
Log:
{
"eventVersion": "1.05",
"userIdentity": {
"type": "AssumedRole",
"principalId": "AROA123456789EXAMPLE:bob.ross",
"arn": "arn:aws:sts::123456789012:assumed-role/AWSReservedSSO_DevAdmin_abc123/bob.ross",
"accountId": "123456789012",
"accessKeyId": "ASIA123456789EXAMPLE",
"sessionContext": {
"sessionIssuer": {
"type": "Role",
"principalId": "AROA123456789EXAMPLE",
"arn": "arn:aws:iam::123456789012:role/aws-reserved/sso.amazonaws.com/AWSReservedSSO_DevAdmin_abc123",
"accountId": "123456789012",
"userName": "AWSReservedSSO_DevAdmin_abc123"
},
"webIdFederationData": {},
"attributes": {
"mfaAuthenticated": "false",
"creationDate": "2019-01-01T00:00:00Z"
}
}
},
"eventTime": "2019-01-01T00:00:00Z",
"eventSource": "lambda.amazonaws.com",
"eventName": "UpdateFunctionConfiguration20150331v2",
"awsRegion": "us-west-2",
"sourceIPAddress": "203.0.113.50",
"userAgent": "aws-cli/2.13.5 Python/3.11.4",
"requestParameters": {
"functionName": "production-api"
},
"responseElements": {
"functionName": "production-api",
"layers": [
{
"arn": "arn:aws:lambda:us-west-2:123456789012:layer:suspicious-layer:1"
}
]
},
"requestID": "1",
"eventID": "1",
"readOnly": false,
"eventType": "AwsApiCall",
"recipientAccountId": "123456789012",
"p_log_type": "AWS.CloudTrail"
}
- Name: FederatedUser Updates Lambda Configuration with Layers
ExpectedResult: true
Log:
{
"eventVersion": "1.05",
"userIdentity": {
"type": "FederatedUser",
"principalId": "123456789012:federated-user",
"arn": "arn:aws:sts::123456789012:federated-user/federated-user",
"accountId": "123456789012",
"accessKeyId": "ASIA123456789EXAMPLE"
},
"eventTime": "2019-01-01T00:00:00Z",
"eventSource": "lambda.amazonaws.com",
"eventName": "UpdateFunctionConfiguration20150331v2",
"awsRegion": "us-west-2",
"sourceIPAddress": "203.0.113.50",
"userAgent": "aws-cli/2.13.5 Python/3.11.4",
"requestParameters": {
"functionName": "production-api"
},
"responseElements": {
"functionName": "production-api",
"layers": [
{
"arn": "arn:aws:lambda:us-west-2:123456789012:layer:some-layer:1"
}
]
},
"requestID": "1",
"eventID": "1",
"readOnly": false,
"eventType": "AwsApiCall",
"recipientAccountId": "123456789012",
"p_log_type": "AWS.CloudTrail"
}
- Name: Lambda Update Function Configuration without Layers
ExpectedResult: false
Log:
{
"eventVersion": "1.05",
"userIdentity": {
"type": "AssumedRole",
"principalId": "tester",
"arn": "arn:aws:sts::123456789012:assumed-role/tester",
"accountId": "123456789012",
"accessKeyId": "1",
"sessionContext": {
"sessionIssuer": {
"type": "Role",
"principalId": "1111",
"arn": "arn:aws:iam::123456789012:role/tester",
"accountId": "123456789012",
"userName": "Tester"
},
"webIdFederationData": {},
"attributes": {
"mfaAuthenticated": "true",
"creationDate": "2019-01-01T00:00:00Z"
}
}
},
"eventTime": "2019-01-01T00:00:00Z",
"eventSource": "lambda.amazonaws.com",
"eventName": "UpdateFunctionConfiguration20150331v2",
"awsRegion": "us-west-2",
"sourceIPAddress": "111.111.111.111",
"userAgent": "console.amazonaws.com",
"requestParameters": {
"functionName": "my-lambda-function"
},
"responseElements": {},
"requestID": "1",
"eventID": "1",
"readOnly": false,
"eventType": "AwsApiCall",
"recipientAccountId": "123456789012",
"p_log_type": "AWS.CloudTrail"
}
Detection logic
Condition
not (errorCode is_not_null or errorMessage is_not_null)
eventSource eq "lambda.amazonaws.com"
eventName eq "UpdateFunctionConfiguration20150331v2"
responseElements.layers is_not_null
userIdentity.type in ["IAMUser", "FederatedUser"] or (userIdentity.type eq "AssumedRole" and userIdentity.sessionContext.sessionIssuer.userName starts_with "AWSReservedSSO_")
Exclusions
Top-level NOT(...) conjuncts: predicates this rule actively suppresses.
| Field | Kind | Excluded values |
|---|---|---|
errorCode | is_not_null | |
errorMessage | is_not_null |
Indicators
Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.
| Field | Kind | Values |
|---|---|---|
eventName | eq |
|
eventSource | eq |
|
responseElements.layers | is_not_null | |
userIdentity.sessionContext.sessionIssuer.userName | starts_with |
|
userIdentity.type | eq |
|
userIdentity.type | in |
|
Output fields
Fields the rule emits when it matches. Chronicle authors list these in the outcome block; they appear on the detection and $risk_score drives alerting. Sentinel / Defender XDR rules build them up through project / summarize / extend stages. Sentinel maps these into alert fields via entityMappings and customDetails; Defender XDR custom detections surface them as alert fields directly.
| Field | Source |
|---|---|
eventName | |
eventSource | |
awsRegion | |
recipientAccountId | |
sourceIPAddress | |
userAgent | |
userIdentity | |
actor_user | |
functionName | responseElements.functionName |