A PubNub key is the identifier that connects an application to a PubNub keyset, the real-time messaging service. The subscribe key is designed to be embedded in client apps, so it is often public by design. The publish key is different: it can send messages into your channels, and it is the one that needs protection. Whether a leak matters depends on which key leaked and what the keyset is allowed to do, so the first step is to identify the key type and its permissions in the admin portal.
Check your GitHub account for leaked secrets — free
- Provider
- PubNub
- Severity
- Medium
- Impact
- SaaS account access and billing
- Checked live by LeakWatch
- No
What a PubNub Key looks like
PubNub subscribe keys begin with sub-c-, followed by a UUID-style value made of letters, digits and hyphens in the familiar 8-4-4-4-12 layout:
sub-c-… PubNub subscribe key (masked)
Publish keys begin with pub-c- and have a similar layout. This rule finds subscribe keys only, so a publish key may be missed by it. A key on its own does not say what it can do. The permissions come from the keyset and from the access rules attached to it, which is why two apps with the same kind of key can have very different exposure.
How PubNub Keys get leaked
- Client applications. A subscribe key shipped in a mobile or web app. That is expected, but it does mean the key is public and should be restricted.
- Configuration files. A settings file for a real-time feature committed with both the subscribe and publish keys.
- Server code. A publish key hard-coded in a backend that sends messages, then copied into a public example.
- Support threads. A snippet pasted in a forum while debugging a connection error.
- Shared dashboards. A keyset shown in a screenshot or a slide deck that was shared outside the team.
What to do in the first hour
- Identify the key. Check the admin portal to see which keyset the value belongs to, and whether it is a subscribe or publish key. A subscribe key in a public app is expected, so the response may be modest.
- Restrict or replace the keyset. Open the account settings for your PubNub account, and change the access rules, or create a new keyset and move the application to it. Do this before you change the code, so the old key stops being useful.
- Check channel activity. Review the messages and presence data for the period since the exposure. Look for messages you did not send, especially in channels that drive notifications or commands.
- Check access rules. If you use access management, confirm that the rules limit what each client can read and write, and tighten them where they are loose.
- Look at other secrets in the same configuration, such as push notification keys. See I accidentally pushed an API key to GitHub for the order of steps.
- Clean the code. Keep publish keys on the server, read them from the environment, and remove the value from current files.
Not sure what else leaked? Run a free scan.
Revoke it at PubNub
Keys belong to keysets, which are managed in the PubNub admin portal. Open account settings, select the keyset, and review the keys and access rules. We could not confirm, from the sources we checked, the exact steps to replace a subscribe key in place, so the safer route is often to create a new keyset, move your applications to it and then retire the old one. Check the current documentation before you do this, because the steps depend on how the keyset is set up.
How LeakWatch detects it
The rule is called PubNub Publish/Subscribe Key. It looks for the prefix sub-c- followed by a UUID-style value with the standard group lengths, with word boundaries on both sides. Publish keys with the pub-c- prefix are not matched by this rule, and a value that is not in the standard layout is not reported. The severity is medium, with the impact class for SaaS tools. This type is not checked live: LeakWatch does not try the key against PubNub.
LeakWatch detects this format but does not check it live: it can tell you the key is exposed, not whether it still works. Assume it does until you have revoked it.
FAQ
Is a subscribe key a secret?
Usually not in the sense that a password is. It is designed for client apps, so its exposure is expected. The real protection comes from access rules, which limit what a key can do.
Is a publish key a secret?
Yes. A publish key can send messages into your channels, so treat it like any other credential and keep it on the server.
Will my app break if I move to a new keyset?
Yes, until every client points to the new keyset. Plan the move, deploy it, and confirm that messages are sent and received before you retire the old keyset.