SNS Topic Message Publish by Rare User

Identifies when an SNS topic message is published by a rare user in AWS. Adversaries may publish messages to SNS topics for phishing campaigns, data exfiltration, or lateral movement within the AWS environment. SNS topics are used to send notifications and messages to subscribed endpoints such as applications, devices or email addresses, making them a valuable target for adversaries to distribute malicious content or exfiltrate sensitive data. This is a New Terms rule that only flags when this behavior is observed for the first time on a user in the last 14 days.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2025/01/07"
  3integration = ["aws"]
  4maturity = "production"
  5updated_date = "2025/01/07"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies when an SNS topic message is published by a rare user in AWS. Adversaries may publish messages to SNS topics
 11for phishing campaigns, data exfiltration, or lateral movement within the AWS environment. SNS topics are used to send
 12notifications and messages to subscribed endpoints such as applications, devices or email addresses, making them a
 13valuable target for adversaries to distribute malicious content or exfiltrate sensitive data. This is a [New
 14Terms](https://www.elastic.co/guide/en/security/current/rules-ui-create.html#create-new-terms-rule) rule that only flags
 15when this behavior is observed for the first time on a user in the last 14 days.
 16"""
 17false_positives = [
 18    """
 19    New users or roles may legitimately publish messages to SNS topics for authorized purposes. Ensure that the action
 20    is authorized before taking action.
 21    """,
 22]
 23from = "now-9m"
 24index = ["filebeat-*", "logs-aws.cloudtrail-*"]
 25language = "kuery"
 26license = "Elastic License v2"
 27name = "SNS Topic Message Publish by Rare User"
 28note = """## Triage and Analysis
 29
 30### Investigating SNS Topic Message Publish by Rare User
 31
 32This rule identifies when a message is published to an SNS topic by a user who has rarely or never published messages before. This activity could indicate adversarial actions, such as using SNS topics for phishing campaigns, data exfiltration, or lateral movement within an AWS environment.
 33
 34#### Possible Investigation Steps
 35
 36- **Identify the Actor and Resource**:
 37  - **User Identity and Role**: Examine the `aws.cloudtrail.user_identity.arn` to identify the user or role responsible for publishing the SNS message. Verify whether this actor is authorized to publish messages to SNS topics. This user is considered "rare" since they have not published messages to SNS topics in the last 14 days.
 38  - **Access Key Details**: Review the `aws.cloudtrail.user_identity.access_key_id` to determine if the access key used is valid or compromised.
 39  - **SNS Topic ARN**: Analyze `aws.cloudtrail.resources.arn` to confirm whether the SNS topic is critical, sensitive, or used for authorized purposes.
 40
 41- **Evaluate the Context of the SNS Message**:
 42  - **Published Message Details**: AWS redacts the message content in CloudTrail logs, but you can view the message ID, subject, and other metadata. Investigate the message details for any indicators of malicious content.
 43  - **Message Recipients**: Investigate the subscriptions associated with the SNS topic to identify if messages were sent to unauthorized or unexpected recipients.
 44
 45- **Analyze Source Information**:
 46  - **Source IP Address**: Examine the `source.ip` field to identify the origin of the activity. Unusual IP addresses or geolocations may indicate unauthorized access.
 47  - **User Agent**: Review `user_agent.original` to determine the tool or client used for publishing the SNS message. Automated tools or unexpected clients (e.g., `Boto3` from an unknown host) may signify misuse.
 48
 49- **Review Historical Activity**:
 50  - **Actor’s Past Behavior**: Identify whether the user has published messages to SNS topics before. Review similar past events for context.
 51  - **Frequency and Patterns**: Examine the time and frequency of messages published by the same user or to the same SNS topic to detect anomalies.
 52
 53- **Correlate with Other Events**:
 54  - **IAM or CloudTrail Events**: Look for events such as `AssumeRole`, `CreateAccessKey`, or other API actions associated with the same user ARN.
 55  - **Unusual IAM Role Activity**: Determine if the actor has assumed roles or performed administrative tasks atypical for their role.
 56
 57### False Positive Analysis
 58
 59- **Routine Operational Use**:
 60  - Confirm if the publishing activity aligns with standard operational tasks or automation scripts.
 61  - Validate whether new or rare users were recently granted permissions for publishing messages to SNS topics.
 62
 63- **Testing or Monitoring Scripts**:
 64  - Automated testing or monitoring tools may trigger this rule if configured to publish messages to SNS topics.
 65
 66### Response and Remediation
 67
 68- **Immediate Action**:
 69  - If unauthorized activity is confirmed, disable the access key or IAM role associated with the user.
 70  - Restrict or remove permissions from the SNS topic to prevent further misuse.
 71
 72- **Review Policies and Subscriptions**:
 73  - Audit the IAM policies tied to the user and SNS topic to ensure appropriate permissions.
 74  - Validate the subscriptions of the SNS topic to confirm all endpoints are authorized.
 75
 76- **Enhance Monitoring and Alerting**:
 77  - Set up additional logging or alerting for SNS publish actions, especially from rare or unknown users.
 78  - Monitor for similar actions across other SNS topics within the environment.
 79
 80- **Conduct a Root Cause Analysis**:
 81  - Investigate how the user or role gained access to publish messages to the SNS topic.
 82  - Determine if other AWS resources or services have been affected.
 83
 84### Additional Information
 85
 86For more information on SNS topic management and securing AWS resources, refer to:
 87- [AWS SNS Publish API Documentation](https://docs.aws.amazon.com/sns/latest/api/API_Publish.html)
 88- [AWS CloudTrail Documentation](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference.html)
 89"""
 90references = [
 91    "https://docs.aws.amazon.com/sns/latest/api/API_Publish.html",
 92    "https://hackingthe.cloud/aws/exploitation/Misconfigured_Resource-Based_Policies/exploting_public_resources_attack_playbook/",
 93]
 94risk_score = 47
 95rule_id = "2112ecce-cd34-11ef-873f-f661ea17fbcd"
 96severity = "medium"
 97tags = [
 98    "Domain: Cloud",
 99    "Data Source: AWS",
100    "Data Source: Amazon Web Services",
101    "Data Source: AWS SNS",
102    "Use Case: Threat Detection",
103    "Resources: Investigation Guide",
104    "Tactic: Lateral Movement",
105    "Tactic: Exfiltration",
106]
107timestamp_override = "event.ingested"
108type = "new_terms"
109
110query = '''
111event.dataset:"aws.cloudtrail"
112    and event.provider:"sns.amazonaws.com"
113    and event.action:"Publish"
114    and event.outcome:"success"
115'''
116
117[rule.investigation_fields]
118field_names = [
119   "@timestamp",
120   "user.name",
121   "aws.cloudtrail.user_identity.arn",
122   "aws.cloudtrail.user_identity.type",
123   "aws.cloudtrail.user_identity.access_key_id",
124   "user_agent.original",
125   "aws.cloudtrail.flattened.request_parameters.topicArn",
126   "event.action",
127   "event.outcome",
128   "cloud.region",
129   "source.ip",
130   "source.geo.city_name",
131   "source.geo.region_name",
132   "source.geo.country_name",
133   "aws.cloudtrail.request_id",
134   "aws.cloudtrail.resources.arn",
135   "aws.cloudtrail.event_category",
136   "aws.cloudtrail.response_elements.messageId"
137]
138
139[[rule.threat]]
140framework = "MITRE ATT&CK"
141[[rule.threat.technique]]
142id = "T1534"
143name = "Internal Spearphishing"
144reference = "https://attack.mitre.org/techniques/T1534/"
145
146
147[rule.threat.tactic]
148id = "TA0008"
149name = "Lateral Movement"
150reference = "https://attack.mitre.org/tactics/TA0008/"
151[[rule.threat]]
152framework = "MITRE ATT&CK"
153[[rule.threat.technique]]
154id = "T1567"
155name = "Exfiltration Over Web Service"
156reference = "https://attack.mitre.org/techniques/T1567/"
157
158
159[rule.threat.tactic]
160id = "TA0010"
161name = "Exfiltration"
162reference = "https://attack.mitre.org/tactics/TA0010/"
163
164[rule.new_terms]
165field = "new_terms_fields"
166value = ["aws.cloudtrail.user_identity.arn"]
167[[rule.new_terms.history_window_start]]
168field = "history_window_start"
169value = "now-14d"
...
toml

This rule identifies when a message is published to an SNS topic by a user who has rarely or never published messages before. This activity could indicate adversarial actions, such as using SNS topics for phishing campaigns, data exfiltration, or lateral movement within an AWS environment.

  • Identify the Actor and Resource:

    • User Identity and Role: Examine the aws.cloudtrail.user_identity.arn to identify the user or role responsible for publishing the SNS message. Verify whether this actor is authorized to publish messages to SNS topics. This user is considered "rare" since they have not published messages to SNS topics in the last 14 days.
    • Access Key Details: Review the aws.cloudtrail.user_identity.access_key_id to determine if the access key used is valid or compromised.
    • SNS Topic ARN: Analyze aws.cloudtrail.resources.arn to confirm whether the SNS topic is critical, sensitive, or used for authorized purposes.
  • Evaluate the Context of the SNS Message:

    • Published Message Details: AWS redacts the message content in CloudTrail logs, but you can view the message ID, subject, and other metadata. Investigate the message details for any indicators of malicious content.
    • Message Recipients: Investigate the subscriptions associated with the SNS topic to identify if messages were sent to unauthorized or unexpected recipients.
  • Analyze Source Information:

    • Source IP Address: Examine the source.ip field to identify the origin of the activity. Unusual IP addresses or geolocations may indicate unauthorized access.
    • User Agent: Review user_agent.original to determine the tool or client used for publishing the SNS message. Automated tools or unexpected clients (e.g., Boto3 from an unknown host) may signify misuse.
  • Review Historical Activity:

    • Actor’s Past Behavior: Identify whether the user has published messages to SNS topics before. Review similar past events for context.
    • Frequency and Patterns: Examine the time and frequency of messages published by the same user or to the same SNS topic to detect anomalies.
  • Correlate with Other Events:

    • IAM or CloudTrail Events: Look for events such as AssumeRole, CreateAccessKey, or other API actions associated with the same user ARN.
    • Unusual IAM Role Activity: Determine if the actor has assumed roles or performed administrative tasks atypical for their role.
  • Routine Operational Use:

    • Confirm if the publishing activity aligns with standard operational tasks or automation scripts.
    • Validate whether new or rare users were recently granted permissions for publishing messages to SNS topics.
  • Testing or Monitoring Scripts:

    • Automated testing or monitoring tools may trigger this rule if configured to publish messages to SNS topics.
  • Immediate Action:

    • If unauthorized activity is confirmed, disable the access key or IAM role associated with the user.
    • Restrict or remove permissions from the SNS topic to prevent further misuse.
  • Review Policies and Subscriptions:

    • Audit the IAM policies tied to the user and SNS topic to ensure appropriate permissions.
    • Validate the subscriptions of the SNS topic to confirm all endpoints are authorized.
  • Enhance Monitoring and Alerting:

    • Set up additional logging or alerting for SNS publish actions, especially from rare or unknown users.
    • Monitor for similar actions across other SNS topics within the environment.
  • Conduct a Root Cause Analysis:

    • Investigate how the user or role gained access to publish messages to the SNS topic.
    • Determine if other AWS resources or services have been affected.

For more information on SNS topic management and securing AWS resources, refer to:

References

Related rules

to-top