How the attack works
SNS topics and SQS queues carry the events that applications act on: order messages, alarms, the notifications that trigger functions and pipelines. Each topic and each queue has a resource-based access policy. For a topic, AddPermission adds a statement that grants named AWS accounts the listed actions, and SetTopicAttributes with the attribute Policy replaces the whole policy, which by default lets only the topic owner publish or subscribe. For a queue, AddPermission generates a statement for the named accounts, and SetQueueAttributes uploads a policy. AWS notes for both services that whoever should not change these permissions must be denied the add, remove and set calls.
An attacker who has reached an account uses this in two directions. Read access, through Subscribe on a topic or ReceiveMessage on a queue, delivers a copy of the data that flows through, for as long as the statement stays, without any further use of the compromised identity. Write access, through Publish or SendMessage, lets an outside account inject messages that the consumers of the topic or queue treat as genuine, which can start functions, deployments or payments that listen there.
AWS lists AddPermission and SetTopicAttributes among the SNS control plane operations that are logged as CloudTrail management events, and AddPermission and SetQueueAttributes among those of SQS. The messages themselves are data events, which CloudTrail does not log by default. AWS's example records show other operations, so the rules read the attribute fields on the basis of the API references and say so. No incident report was used for this page: it follows what AWS documents about these policies.
What an attacker needs
- Credentials for a principal allowed sns:AddPermission or sns:SetTopicAttributes on the topic, or sqs:AddPermission or sqs:SetQueueAttributes on the queue.
- An account or principal of the attacker's own to name in the policy.
Impact
Lasting read access to the messages of a topic or queue from outside the account, or the ability to publish messages into it. The first exposes whatever the messages contain. The second lets the attacker trigger the systems that consume the messages. Both keep working after the compromised credential is revoked.
Detection rules
SNS Topic Permission Added or Topic Policy Set
Detects changes to the access policy of an Amazon SNS topic: AddPermission calls, which add a statement that grants named AWS accounts the listed actions, and SetTopicAttributes calls that set the attribute Policy, which replaces the policy of the topic. AWS lists both operations among the SNS control plane operations that are logged as CloudTrail management events. The attribute is read from requestParameters.attributeName, which follows the AttributeName request parameter of the SNS API reference: AWS's example records show other operations, so confirm the field in your own events. The rule matches every policy change, including those of normal deployments. Read the accounts or the policy text of the request and check whether an account outside your organization was granted Publish or Subscribe. It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.
title: SNS Topic Permission Added or Topic Policy Set
id: 557882c0-c371-4045-bdf8-3baf06ad7033
status: experimental
description: >-
Detects changes to the access policy of an Amazon SNS topic: AddPermission
calls, which add a statement that grants named AWS accounts the listed
actions, and SetTopicAttributes calls that set the attribute Policy, which
replaces the policy of the topic. AWS lists both operations among the SNS
control plane operations that are logged as CloudTrail management events.
The attribute is read from requestParameters.attributeName, which follows
the AttributeName request parameter of the SNS API reference: AWS's
example records show other operations, so confirm the field in your own
events. The rule matches every policy change, including those of normal
deployments. Read the accounts or the policy text of the request and check
whether an account outside your organization was granted Publish or
Subscribe.
It also matches attempts that failed (errorCode present): check errorCode,
because an unauthorized attempt is worth seeing.
references:
- https://docs.aws.amazon.com/sns/latest/dg/logging-using-cloudtrail.html
- https://docs.aws.amazon.com/sns/latest/api/API_AddPermission.html
- https://docs.aws.amazon.com/sns/latest/api/API_SetTopicAttributes.html
- https://attack.mitre.org/techniques/T1098/003/
author: Forestall
date: 2026-11-18
tags:
- attack.persistence
- attack.privilege-escalation
- attack.t1098.003
logsource:
product: aws
service: cloudtrail
detection:
selection_permission:
eventSource: sns.amazonaws.com
eventName: AddPermission
selection_policy:
eventSource: sns.amazonaws.com
eventName: SetTopicAttributes
requestParameters.attributeName: Policy
condition: 1 of selection_*
falsepositives:
- Infrastructure-as-code pipelines and AWS services that set a topic policy when they create or connect a topic, for example for event notifications. Add the deployment roles to a filter_* selection on userIdentity.arn and keep alerting on changes made by people or unknown roles.
level: low
False positives
- Infrastructure-as-code pipelines and AWS services that set a topic policy when they create or connect a topic, for example for event notifications. Add the deployment roles to a filter_* selection on userIdentity.arn and keep alerting on changes made by people or unknown roles.
SQS Queue Permission Added or Queue Policy Set
Detects changes to the access policy of an Amazon SQS queue: AddPermission calls, which AWS describes as adding a permission to a queue for a specific principal so that access to the queue can be shared, and SetQueueAttributes calls that carry a Policy attribute, which upload a policy for the queue. AWS lists both operations among the SQS control plane operations that are logged as CloudTrail management events. The policy attribute is read from requestParameters.attributes.Policy, which follows the Attributes request parameter of the SQS API reference: AWS's example record shows another operation, so confirm the field in your own events. The rule matches every policy change, including those of normal deployments. Read the accounts or the policy text of the request and check whether an account outside your organization was granted SendMessage or ReceiveMessage. It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.
title: SQS Queue Permission Added or Queue Policy Set
id: 3662fcf4-e519-42a3-93ea-0dc9e5c34e9e
status: experimental
description: >-
Detects changes to the access policy of an Amazon SQS queue: AddPermission
calls, which AWS describes as adding a permission to a queue for a
specific principal so that access to the queue can be shared, and
SetQueueAttributes calls that carry a Policy attribute, which upload a
policy for the queue. AWS lists both operations among the SQS control
plane operations that are logged as CloudTrail management events. The
policy attribute is read from requestParameters.attributes.Policy, which
follows the Attributes request parameter of the SQS API reference: AWS's
example record shows another operation, so confirm the field in your own
events. The rule matches every policy change, including those of normal
deployments. Read the accounts or the policy text of the request and check
whether an account outside your organization was granted SendMessage or
ReceiveMessage.
It also matches attempts that failed (errorCode present): check errorCode,
because an unauthorized attempt is worth seeing.
references:
- https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/logging-using-cloudtrail.html
- https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_AddPermission.html
- https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SetQueueAttributes.html
- https://attack.mitre.org/techniques/T1098/003/
author: Forestall
date: 2026-11-18
tags:
- attack.persistence
- attack.privilege-escalation
- attack.t1098.003
logsource:
product: aws
service: cloudtrail
detection:
selection_permission:
eventSource: sqs.amazonaws.com
eventName: AddPermission
selection_policy:
eventSource: sqs.amazonaws.com
eventName: SetQueueAttributes
requestParameters.attributes.Policy|exists: true
condition: 1 of selection_*
falsepositives:
- Infrastructure-as-code pipelines and AWS services that set a queue policy when they create a queue or connect it to a topic or a bucket. Add the deployment roles to a filter_* selection on userIdentity.arn and keep alerting on changes made by people or unknown roles.
level: low
False positives
- Infrastructure-as-code pipelines and AWS services that set a queue policy when they create a queue or connect it to a topic or a bucket. Add the deployment roles to a filter_* selection on userIdentity.arn and keep alerting on changes made by people or unknown roles.
Detection logic
Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.
Topic or queue policy names an account that is not yours
Cross-account messaging inside one organization is ordinary. The change that matters grants an account nobody in the organization owns, and only your own account list can tell the two apart.
- Collect
AddPermissionevents fromsns.amazonaws.comandsqs.amazonaws.comand read the account IDs of the request (the AWSAccountId and AWSAccountIds parameters of the APIs). - Collect
SetTopicAttributesevents whose attribute name is Policy andSetQueueAttributesevents that carry a Policy attribute, and take the account IDs from the principals of the policy text. - Compare every account ID with the accounts of your organization and alert on one that is not on the list.
EventsAddPermissionSetTopicAttributesSetQueueAttributes
LimitsIt needs a current account list and a way to read principals from a policy document. The request fields follow the API references, and AWS publishes no example record for these calls, so confirm them in your own events first.
Triage
- Identify the caller (userIdentity.arn), the source IP address and the user agent. Is it the deployment pipeline of the application that owns the topic or queue?
- Read the topic ARN or queue URL of the request, and the accounts or the policy text it carries. Which accounts and which actions were granted?
- Check whether the named accounts belong to your organization, and whether the statement carries a condition.
- Find out what flows through the topic or queue and which systems consume it, to judge what read or write access is worth.
- Look for new subscriptions on the topic after the change.
Response
Once the attack is confirmed:
- Remove the statement or put the last deployed policy back on the topic or queue.
- Remove subscriptions on the topic that nobody in the organization created.
- Treat the messages that passed through since the change as exposed, and review what the consumers did with messages that arrived in that time.
- Contain the principal that changed the policy, and review everything else it did.
Mitigation
- Allow sns:AddPermission, sns:SetTopicAttributes, sqs:AddPermission and sqs:SetQueueAttributes only to deployment roles, and deny them elsewhere, as AWS advises for principals that should not change these permissions.
- Write topic and queue policies that name specific accounts or services, and narrow them with conditions on the source account, the source ARN or the organization.
- Review the policies of topics and queues with IAM Access Analyzer, which reports resources that are shared outside the account or the organization.
- Have consumers validate the content of messages and not rely on the queue or topic as proof of origin.
Frequently asked questions
Does CloudTrail show who read or published messages afterwards?
Not by default. `Publish`, `SendMessage` and `ReceiveMessage` are data events, which CloudTrail does not log unless data event logging is configured for the topic or queue. The policy change is a management event and is logged by default, which makes it the reliable signal.
Why is there no rule for a wildcard principal, as on other pages?
Statements with a wildcard principal are common in topic and queue policies, where a condition such as `aws:SourceArn` or `aws:SourceAccount` narrows them to one sender. A rule on the wildcard alone would fire on many ordinary deployments. Read the Principal and the Condition of the new policy during triage.
Which of the two calls is more dangerous?
Setting the whole policy. `AddPermission` can only name AWS accounts and a list of actions, and for SQS AWS notes that it does not support adding a non-account principal. `SetTopicAttributes` and `SetQueueAttributes` take any policy document, including one without conditions.
Has this been seen in attacks?
No public incident report describes this at the audit event level, and none was used for this page. It follows what AWS documents about topic and queue policies, and it belongs to the same family as the bucket, key, function and repository policies that have pages of their own.
References
- MITRE ATT&CK T1098.003: Account Manipulation: Additional Cloud Roles
- Logging AWS SNS API calls using AWS CloudTrail
- Amazon SNS API Reference: AddPermission
- Amazon SNS API Reference: SetTopicAttributes
- Logging Amazon Simple Queue Service API calls using AWS CloudTrail
- Amazon SQS API Reference: AddPermission
- Amazon SQS API Reference: SetQueueAttributes