Skip to content
CloudOps
Newsletter Sign up
All prompts
AI for Slack Difficulty: Advanced ClaudeChatGPT

Slack OAuth Token Security & Rotation Prompt

Audit, secure, and rotate Slack OAuth tokens (bot, user, granular) across services — inventory, threat model, rotation cadence, secret manager integration, and dual-active migration.

Target user
Security + platform engineers managing Slack bot identities at scale
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior application security engineer who has hardened Slack OAuth token management across orgs with 30+ services posting to Slack, surviving Slack API changes and zero downtime rotations.

I will provide:
- Bot count + per-bot install scope (workspace / org-app)
- Token types in use (bot, user, granular bot tokens)
- Secret manager (Vault, AWS SM, GCP SM, 1Password)
- Recent incidents involving leaked or revoked tokens
- Compliance regime

Your job:

1. **Token type primer**:
   - **Bot token (`xoxb-`)** — for app actions; bound to bot user + workspace
   - **User token (`xoxp-`)** — acts as a specific user; avoid for service work
   - **Granular bot tokens** — newer scoping model with smaller per-scope tokens
   - **App-level token (`xapp-`)** — for Socket Mode connections
   - **Refresh tokens** — only when rotation is enabled at app install

2. **Threat model**:
   - **What an attacker can do with a bot token**: post to any channel the bot's installed in, read messages in those channels (if scoped), upload files, install dependencies
   - **What they cannot do**: workspace admin actions, install other apps, change billing
   - **Leak vectors**: committed to git, in CI logs, in error stack traces, in screenshots, in old backups, on departed-employee laptops, in API client telemetry

3. **Inventory & discovery**:
   - Slack admin API: list installed apps + their tokens
   - Search secret managers
   - Grep git history for `xoxb-`, `xoxp-`, `xapp-`
   - Audit CI variable lists
   - Search Sentry / log aggregator for leaked tokens

4. **Categorization**:
   - By criticality of destination channels
   - By install scope (workspace-wide vs limited channels)
   - By age of last rotation
   - By owner team
   - By usage frequency (dead bots are still risk)

5. **Token rotation enablement**:
   - For apps: enable Token Rotation in the app config
   - Apps then receive refresh tokens; access tokens expire in ~12h
   - Significantly reduces impact window of a leaked access token
   - Requires app code to handle refresh

6. **Rotation cadence**:
   - **Apps with rotation enabled** — automatic; verify the refresh works monthly
   - **Apps without rotation** — manual every 90 days; rotate on suspicion or owner departure
   - **High-sensitivity** (post to executive channels, sensitive content) — every 30 days regardless

7. **Zero-downtime rotation**:
   - Slack allows rotating a bot token by re-installing the app
   - During install, the OLD token continues to work briefly
   - Coordinate: secret manager update → service config reload → verify with synthetic post → revoke old via Slack admin
   - Document the per-app sequence

8. **Secret manager integration**:
   - Single source of truth — never embed tokens in env files
   - Per-environment secrets (dev / staging / prod each with separate Slack apps and tokens)
   - Rotation hooks: secret manager rotation invokes the Slack re-install endpoint, updates the secret, signals the consumer to reload

9. **Detection of compromise**:
   - Volume anomalies (10x normal post rate)
   - Off-hours posts
   - Posts to unusual channels (bot suddenly posts to #exec)
   - Slack admin notifications for token use from new IPs

10. **Decommission of dead bots**:
   - Quarterly review of unused bots
   - Notify owner with "this is being removed in 14d unless objection"
   - Revoke via Slack admin
   - Remove from secret manager
   - Record reason in audit log

Output as: (a) token inventory script outline, (b) threat model summary, (c) rotation enablement guide per app, (d) zero-downtime rotation runbook, (e) secret manager integration spec, (f) anomaly detection rules, (g) decommission process, (h) compliance evidence checklist.

Bias toward: enable token rotation everywhere it's supported, automation over manual, observable token use.
Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 600+ DevOps AI prompts
  • One practical workflow email per week