Detection rules › Panther

Lambda Configuration Updated with Layers by User

Severity
high
Log types
AWS.CloudTrail
Reference
https://stratus-red-team.cloud/attack-techniques/AWS/aws.persistence.lambda-layer-extension/
Source
github.com/panther-labs/panther-analysis

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

TacticTechniques
Initial AccessT1078 Valid Accounts
PersistenceT1078 Valid Accounts
Privilege EscalationT1078 Valid Accounts
StealthT1078 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.

FieldKindExcluded values
errorCodeis_not_null(no value, null check)
errorMessageis_not_null(no value, null check)

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.

FieldKindValues
eventNameeq
  • UpdateFunctionConfiguration20150331v2
eventSourceeq
  • lambda.amazonaws.com
responseElements.layersis_not_null
  • (no value, null check)
userIdentity.sessionContext.sessionIssuer.userNamestarts_with
  • AWSReservedSSO_
userIdentity.typeeq
  • AssumedRole
userIdentity.typein
  • FederatedUser
  • IAMUser

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.

FieldSource
eventName
eventSource
awsRegion
recipientAccountId
sourceIPAddress
userAgent
userIdentity
actor_user
functionNameresponseElements.functionName