Protect your app from hackers

Four things to do today, and one prompt that walks you through all of them.
Start here: copy this prompt
Paste it into Claude Code or Codex. It walks you through all four steps: it fixes what it can in your code and tells you exactly where to click for the rest.
Help me protect my app from hackers. Go through these four steps one at a time. After each step, tell me what you found or changed, and wait for me to say "done" before the next one. First, look at my code and list which services I use: AI providers (OpenAI, Anthropic or others), payments (Stripe or others), and where the app is hosted (Railway, Vercel, Render or others). Use that list in every step. Step 1: Spending limits For each AI provider I use, give me the exact place to set a monthly spending limit, and suggest an amount from what my app really uses. - OpenAI: project Limits page. Tell me to turn on "Enforce a hard limit", or the budget only watches and doesn't stop requests. - Anthropic: Console, Workspaces, Spend limits. Step 2: Usage alerts For each AI provider, tell me where to add an email alert at 50 to 80% of the limit. Step 3: Leaked keys 1. Find any keys, tokens or passwords written in the code (e.g. "sk-", "sk-ant-", "sk_live_"). 2. Search the whole git history too. Removed keys stay in old commits. 3. Make sure .env files are in .gitignore and were never committed. 4. Move every secret into environment variables. Only show me the first few characters of each. 5. List every key that was ever exposed. For each one, tell me to revoke it on the provider's API keys page, make a new one, update it on my host and redeploy. Deleting it from the code is not enough. Step 4: Two-factor login For my host, GitHub and my payments provider, tell me where to turn on two-factor login. Tell me to use an authenticator app or passkey instead of text messages, and to save the backup codes. At the end, give me a short checklist of what's done and what's left. Docs: - OpenAI limits and alerts: https://help.openai.com/en/articles/9186755-managing-projects-in-the-api-platform - Anthropic spend limits: https://platform.claude.com/docs/en/manage-claude/workspaces - Removing keys from git history: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository - GitHub two-factor: https://docs.github.com/en/authentication/securing-your-account-with-two-factor-authentication-2fa - Stripe two-step verification: https://support.stripe.com/questions/enable-two-step-verification Don't change anything in the app except moving secrets into environment variables.
Or do it by hand
Set a spending limit on your API keys
A stolen key hits your limit, not your card.
- OpenAI: project Limits, set a budget, turn on Enforce a hard limit. Without it, nothing stops.
- Anthropic: Console, Workspaces, Spend limits.
Turn on usage alerts
Get an email when spend looks wrong, not when the bill comes. Set it at 50 to 80% of your limit.
- OpenAI: same Limits page, add a spend alert.
- Anthropic: same spend settings, add alerts.
If a key leaks, cancel it
Deleting it from your code isn't enough: it keeps working until you cancel it. LiteLLM erased a leaked key from GitHub in May; hackers used it in October.
- Revoke the key on the provider's API keys page.
- Make a new one and keep it in environment variables.
- Update it on your host and redeploy.
- Check usage for requests you didn't make.
Turn on two-factor login
A stolen password alone can't get in. Use an authenticator app or passkey, and save the backup codes.
- Hosting: Railway, Vercel or Render, in account settings.
- GitHub: Settings, Password and authentication.
- Stripe: Dashboard, Personal details.
Resources
Spending limits and alerts
Leaked keys
Settings move around. If one isn't where it says, check the provider's own page.
Last checked: October 2026
Hi, I'm Rahul. I'm documenting what I learn while building products.