# Least privilege for Pub/Sub means Publisher on a topic and Subscriber on a subscription, not Editor

Facts read 16 Nov 2026. Page reviewed 16 Nov 2026.

Pub/Sub roles can be granted on individual topics and subscriptions. Google's documentation, read 16 Nov 2026, lists Publisher, Subscriber, Editor and Admin, says custom roles help enforce least privilege, and shows cross-project access using the Subscriber role on one subscription instead of a project-wide grant.

## Pub/Sub roles attach to topics, subscriptions, snapshots and schemas

Google's documentation says Pub/Sub supports basic, predefined and custom roles, and that custom roles help enforce the principle of least privilege. The predefined roles can be granted on resources as small as a single topic or subscription.

Pub/Sub Publisher (roles/pubsub.publisher) publishes messages to a topic. Pub/Sub Subscriber (roles/pubsub.subscriber) consumes messages from a subscription and attaches subscriptions to a topic. Pub/Sub Editor (roles/pubsub.editor) modifies topics and subscriptions and can publish and consume. Pub/Sub Admin (roles/pubsub.admin) has full access to topics and subscriptions.

The identities that call this service (people, services, workloads, third parties) are covered in the [Google Cloud service identities guide](/guides/google-cloud-service-identities/) and the [workload identities guide](/guides/google-cloud-workload-identities/).

## Roles to avoid, with the documented reason

Editor and Admin combine producing, consuming and changing.

- Pub/Sub Editor: Google's description is access to modify topics and subscriptions as well as to publish and consume. A producer needs only publish.
- Pub/Sub Admin: full access to topics and subscriptions, including the ability to change who can use them.
- Project-level grants: a project-level Publisher covers every topic. Grant on the topic instead.
- Public or broad principals: the documentation shows bindings to allUsers and domain principals as examples, which are the shape of grant to avoid for message data.

## A minimal binding for a producer and a consumer

Google's documentation describes a cross-project case: to let a service account in project A receive messages from a subscription in project B, grant it Pub/Sub Subscriber on project B or, more narrowly, on the subscription.

| Task | Role | Resource | Detail in Google's documentation |
| --- | --- | --- | --- |
| Publish to a topic | roles/pubsub.publisher | The topic | Includes pubsub.topics.publish |
| Receive from a subscription | roles/pubsub.subscriber | The subscription | Consume messages; attach subscriptions to a topic |
| Create a subscription on another project's topic | roles/pubsub.editor, or a custom role | Project A and the topic | Needs pubsub.subscriptions.create and pubsub.topics.attachSubscription |

## Custom roles and per-resource grants narrow access

The cross-project example needs two permissions, pubsub.subscriptions.create on project A and pubsub.topics.attachSubscription on the topic in project B. The Editor role holds both, but a custom role with only those two is narrower, and Google presents custom roles as the least privilege tool.

Google notes that Pub/Sub may fall back on cached IAM policies to keep latency low, so changes take a short time to apply. Plan revocations with that delay in mind.

## Checking what is used

The IAM recommender compares a principal's roles with its used permissions over the last 90 days, per Google's documentation. Check principals that hold Editor or Admin and find those that only publish or only consume.

Then list the IAM policy of each topic and subscription and remove principals that no longer take part in the flow.

Google's documentation also lists the permissions that each API method on topics and subscriptions needs. Use that table to build a custom role for each producer and consumer from the methods they call, rather than starting from Editor and removing permissions. Start with the methods in your code: publish for a producer, and pull or acknowledge for a consumer.

## Related pages

- [Least privilege for Amazon S3](/services/aws-s3/)
- [Least privilege for AWS Lambda](/services/aws-lambda/)
- [Least privilege for Amazon EC2](/services/aws-ec2/)
- [All of them](/services/)

## Sources

- Pub/Sub access control: https://cloud.google.com/pubsub/docs/access-control (read 16 Nov 2026)
- IAM roles overview: https://cloud.google.com/iam/docs/roles-overview (read 16 Nov 2026)
- Role recommendations overview: https://cloud.google.com/iam/docs/recommender-overview (read 16 Nov 2026)

Last reviewed 16 Nov 2026. Canonical: https://leastprivilegeprinciple.com/services/gcp-pubsub/
