Dev.to AI πŸ€– Ai πŸ‘ 2 πŸ“– 2 min read

Pusher in an AI-built app: the app secret and the channels anyone can join

Live features like chat, notifications and presence feel hard, so people reach for a hosted service. Pusher is a common one. The setup code the AI writes has to deal with several values, and two of them must never be mix

Live features like chat, notifications and presence feel hard, so people reach for a hosted service. Pusher is a common one. The setup code the AI writes has to deal with several values, and two of them must never be mixed up.

The values in play

  • App key and cluster. These are public. The browser needs them to connect.
  • App secret. This signs requests and lets a server publish events and authorize private channels. It belongs on a server only.

A typical slip is putting the secret in a front-end file or in a variable that the build tool exposes to the browser. Another is skipping channel authorization, so every channel is public and anyone who knows the name can listen.

What to check

  1. Search your built JavaScript for the app secret. Open the live site, find the bundle files, and search for the app key. See what sits next to it. The secret should not be there.
  2. Check your env variable names. Variables with a public prefix in your framework ship to the browser. The secret must not use one.
  3. Use private or presence channels for private data. Public channels have no access check. Anything sent on one can be read by anyone who subscribes.
  4. Write a real auth endpoint. The endpoint that authorizes a private channel should check who the user is and whether they may join that channel. An endpoint that says yes to everyone defeats the point.
  5. Do not trust client events blindly. If you allow clients to send events, treat the content like any other user input.
  6. Rotate after a leak. Removing the secret from the code does not help once it was served. Regenerate it in the dashboard and update the server.

What an outside scan can tell you

I work on ProofForge. The free scan checks the public side of a URL you own or have permission to test: browser bundle, public files, headers and supported backend signals. It never signs in. It looks for private keys and tokens sitting in your JavaScript. It cannot judge your channel names or your auth endpoint logic, so that review is yours. A clean result means nothing was found in the public assets checked, not that the app is secure.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.