SNS topic policy has a wildcard or missing principal

Define the principals and actions in an SNS topic policy and review service-integration conditions to restrict unwanted publishing and access.

Description

In an SNS topic policy, Principal: "*" in an Effect: Allow statement leaves the principal unrestricted. Effective access still depends on the action, topic, conditions and other policies. Omitting Principal from the statement neither grants public access nor defines a restriction.

Potential impact

If unintended principals, including other accounts, can use sns:Publish, their messages may trigger false alerts, processing errors or additional costs for subscribers.

Remediation

  1. Specify the required account, role or service in Principal. Allow only the necessary actions on the exact topic ARN.
  2. For service integrations, check the operators and values for supported aws:SourceArn or aws:SourceAccount conditions. In supported service-to-service requests, aws:SourceAccount identifies the source resource’s owner. aws:ResourceAccount identifies the destination resource’s owner. Neither identifies an ordinary caller’s account.
  3. Remove unnecessary grants and check the associated Topics. Test that required publishers and services succeed and unapproved requests are denied.

Topic policy configuration examples

Both excerpts omit the required Topics property. The ARN arn:aws:sns:MyTopic also lacks a Region and account ID. Supply the complete topic ARN and Topics before deployment.

Publishing grant to a wildcard principal

yaml
AWSTemplateFormatVersion: '2010-09-09'
Description: ''
Resources:
  snsPolicy:
    Type: AWS::SNS::TopicPolicy
    Properties:
      PolicyDocument:
        Statement:
          - Sid: MyTopicPolicy
            Effect: Allow
            Principal: "*"
            Action:
              - sns:Publish
            Resource: arn:aws:sns:MyTopic

The first statement sets no limit on the publisher and includes no conditions.

Incomplete principal specification

yaml
AWSTemplateFormatVersion: '2010-09-09'
Description: ''
Resources:
  snsPolicy:
    Type: AWS::SNS::TopicPolicy
    Properties:
      PolicyDocument:
        Statement:
          - Sid: MyTopicPolicy
            Effect: Allow
            Principal: "otherPrincipal"
            Action:
              - sns:Publish
            Resource: arn:aws:sns:MyTopic

In the second statement, replace otherPrincipal with a valid principal for the publishing account, role or service.

References