PC-009HIGHSecrets & API Keys

Slack or Discord Incoming Webhook URL Exposed

Catches hardcoded Slack incoming webhook URLs (hooks.slack.com/services/...) and Discord webhook endpoints (discord.com/api/webhooks/...) committed in code or alert scripts.

Rule Slug
slack-discord-webhook-url
Affected Files
*
Detection Method
Deterministic Regex
Live Rule Tester100% Browser-Local
HIGH: Detected 1 violation
Line 2:https://hooks.slack.com/s••••••••••••••BcDeFgHiJkL(entropy: 5.15)

Vulnerable Pattern vs. Hardened Fix

Vulnerable Pattern
// utils/notify.ts
const SLACK_WEBHOOK = 'https://hooks.slack.com/services/T04ABC12345/B05DEF67890/xYz987654321aBcDeFgHiJkL';

export async function notifyDeploy(msg: string) {
  await fetch(SLACK_WEBHOOK, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ text: msg }),
  });
}
Recommended Fix
// utils/notify.ts
export async function notifyDeploy(msg: string) {
  const webhookUrl = process.env.SLACK_ALERT_WEBHOOK_URL;
  if (!webhookUrl) return;

  await fetch(webhookUrl, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ text: msg }),
  });
}

Why This Fails in Production

Incoming webhook URLs for Slack and Discord embed authentication directly inside the URL path token, meaning no additional header, cookie, or OAuth handshake is required to post messages into your team’s private channels. Anyone who extracts an exposed webhook URL from a repository, CI workflow, or frontend bundle can issue a single curl POST request and immediately broadcast arbitrary content directly into your engineering, incident-response, or customer-support channels.

Attackers exploit leaked team webhooks primarily for high-trust internal phishing and alert fatigue. Because employees implicitly trust automated bot alerts appearing inside #deployments, #ops-alerts, or #general, a spoofed message posing as a "Security Action Required: Re-authenticate VPN" or "Urgent Invoice Approval" link achieves dramatically higher click-through rates than external email phishing. On Discord community servers, leaked webhooks allow spammers to flood announcements channels with crypto scams or malicious downloads while impersonating official moderators.

In operational monitoring pipelines, attackers can also flood an exposed webhook with synthetic error alerts to bury real intrusion notifications during an active attack, or probe whether the webhook remains active as a signal that other secrets in the same repository are live production credentials.

Webhook URLs must be treated as sensitive bearer tokens: store them strictly in environment variables or CI secret stores, rotate them immediately if committed, and never invoke them from client-side browser code.

Remediation Steps

  1. 1Delete and regenerate the exposed webhook immediately inside your Slack App configuration (Incoming Webhooks) or Discord Channel Settings -> Integrations -> Webhooks.
  2. 2Alert your team if suspicious messages or phishing links appeared in the target channel during the exposure window.
  3. 3Move the webhook URL into a server-side environment variable such as process.env.SLACK_ALERT_WEBHOOK_URL.
  4. 4Use a backend endpoint to sanitize and rate-limit alert payloads before forwarding them to Slack or Discord.

Frequently Asked Questions

Can someone read channel history with a leaked Slack or Discord incoming webhook?
No. Incoming webhooks are write-only for posting messages to their bound channel, though they enable high-trust internal phishing, spam floods, and alert spoofing against your team or community.
Does Slack automatically revoke leaked webhooks?
Slack participates in GitHub secret scanning for public repositories and may automatically deactivate leaked hooks, breaking your production alerting silently until replaced.
Is it safe to post contact form submissions directly to a Discord webhook from client-side JavaScript?
Never. Exposing a Discord webhook URL in frontend JS lets any visitor spam your server or abuse the webhook freely. Always submit forms to your own backend endpoint first.

Related Secrets & API Keys Rules

Scan local project folder →