[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7524A8F6GS6XYNSDRM6ZW8M":3,"skill-same:01M7524A8F6GS6XYNSDRM6ZW8M":49},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":31,"ownerHtmlUrl":32,"ownerBlogUrl":31,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M7524A8F6GS6XYNSDRM6ZW8M","vercel-firewall-and-botid",null,"Harden a Vercel app at the platform edge - the Vercel WAF (custom rules, IP blocking, managed rulesets like OWASP CRS + bot_protection + ai_bots, rate limiting), Attack Challenge Mode, system bypass rules, automatic DDoS mitigation, and BotID bot verification on sensitive routes. Use when someone says \"protect my Vercel app\", \"add a WAF rule\", \"rate limit my API\", \"block this IP \u002F country \u002F user-agent\", \"I'm getting DDoSed\", \"stop bots \u002F scrapers \u002F AI crawlers\", \"turn on Attack Mode\", \"verify human vs bot on checkout\u002Fsignup\u002Flogin\", or \"set up BotID\". Do NOT use for app-level auth\u002Fsession logic - that is application code; do NOT use for env vars or secrets - use vercel-env-management; do NOT use for the deploy\u002Fpromote\u002Frollback flow - use vercel-deploy-pipeline.","SkillMedev\u002Fskills","SkillMedev","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F298078254?v=4","01M74ZSGTQ918CB0VXW4EG3RMX","SkillMe","01M74ZSGVBT497NA95CBT8JTY4",25,"MIT","https:\u002F\u002Fgithub.com\u002FSkillMedev\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fvercel-firewall-and-botid\u002FSKILL.md",[],[],"2026-11-11 18:27:18",false,"---\nname: vercel-firewall-and-botid\ndescription: Harden a Vercel app at the platform edge - the Vercel WAF (custom rules, IP blocking, managed rulesets like OWASP CRS + bot_protection + ai_bots, rate limiting), Attack Challenge Mode, system bypass rules, automatic DDoS mitigation, and BotID bot verification on sensitive routes. Use when someone says \"protect my Vercel app\", \"add a WAF rule\", \"rate limit my API\", \"block this IP \u002F country \u002F user-agent\", \"I'm getting DDoSed\", \"stop bots \u002F scrapers \u002F AI crawlers\", \"turn on Attack Mode\", \"verify human vs bot on checkout\u002Fsignup\u002Flogin\", or \"set up BotID\". Do NOT use for app-level auth\u002Fsession logic - that is application code; do NOT use for env vars or secrets - use vercel-env-management; do NOT use for the deploy\u002Fpromote\u002Frollback flow - use vercel-deploy-pipeline.\nmetadata:\n  title: \"Vercel Firewall and BotID\"\n---\n\n# Vercel Firewall and BotID\n\nThis is the security stage of the ship-a-Next.js-app-on-Vercel workflow. You make\nthe app hard to attack at the edge - before a single request reaches a Function -\nand you make abuse-prone routes prove the caller is human. Two systems do this,\nand they are not interchangeable:\n\n- The **Vercel WAF \u002F Firewall** filters traffic by request shape (IP, path,\n  geo, user-agent, headers, JA4) and by rate. It runs on the Edge Network in\n  front of every deployment, included on all plans, and you pay nothing extra to\n  deny a request before it bills compute. Configure it once per project.\n- **BotID** is invisible, per-route bot verification you call from server code on\n  the specific endpoints that get abused (checkout, signup, login, \"add to cart\",\n  LLM-backed routes). It is a JS challenge plus deep analysis, and it does not\n  show a CAPTCHA to humans.\n\nUse both, in that order: the WAF is the blanket, BotID is the lock on the doors\nthat matter. This skill is opinionated and sequenced; it is deliberately **not** a\nrestatement of the official `vercel firewall` CLI plugin - it tells you what to\nturn on, in what order, and what NOT to do.\n\nTrigger eagerly on: \"protect my Vercel app\", \"add a WAF rule\", \"rate limit\",\n\"block an IP \u002F country \u002F bot\", \"I'm under attack\" \u002F \"DDoS\", \"stop scrapers or AI\ncrawlers\", \"Attack Mode\", or \"verify human on `\u003Croute>`\" \u002F \"set up BotID\".\n\nWhere it fits in the pack: you should already have a green deploy\n(`vercel-deploy-pipeline`) and managed secrets (`vercel-env-management`). Hand\nback to `next-on-vercel-perf` if a firewall rule changes cache behavior, and to\n`vercel-edge-and-isr` if you start gating ISR\u002Fstatic routes. LLM endpoints fronted\nby `vercel-ai-gateway` are exactly the ones that deserve BotID.\n\n## Mental model: five layers, outermost first\n\nA request hits these in order. Stop abuse at the outermost layer that can see it -\nthe further out, the cheaper.\n\n1. **Automatic DDoS mitigation** - always on, nothing to configure. Vercel's Edge\n   Network absorbs and mitigates volumetric L3\u002FL4 and many L7 floods globally. You\n   do not turn this on; you escalate past it with the layers below when an attack\n   is application-shaped.\n2. **Managed rulesets** - Vercel-maintained rule bundles you toggle: the **OWASP\n   Core Rule Set** (`owasp`) for SQLi\u002FXSS\u002Ftraversal patterns, **bot_protection**\n   for known bad bots, **ai_bots** for AI scrapers\u002Fcrawlers, and traffic-source\n   rules. Each is set to an action: `log`, `challenge`, or `deny`.\n3. **Custom rules** - your own conditions (path, IP, geo, user-agent, header,\n   query, JA4) → an action. This is most of the day-to-day work.\n4. **Rate limiting** - per-key request budgets, either as a custom-rule action or\n   precisely in code via `@vercel\u002Ffirewall`.\n5. **BotID** - in-Function verification of the actual caller on named routes.\n\nAttack Challenge Mode is a global override that sits on top of all of these: when\non, every visitor gets a managed challenge at the edge.\n\n## Operating procedure\n\nRun in order. Do not jump to BotID before the WAF baseline is set - most abuse\nnever needs application code to stop.\n\n### Step 1 - Establish the WAF baseline (managed rulesets)\n\nTurn on the Vercel-managed rulesets before writing any custom rule. In the\ndashboard (Project → Firewall) or via SDK, enable and set actions:\n\n- **OWASP CRS** (`owasp`): start at `log` and soak for 3-7 days of representative\n  traffic (long enough to cover a weekly cycle of real usage) to learn its false\n  positives, then move to `deny`. Going straight to `deny` on a busy app risks\n  blocking legitimate requests you have not profiled.\n- **bot_protection**: `challenge` or `deny` for known malicious bots.\n- **ai_bots**: decide deliberately - `deny` if you do not want LLM crawlers\n  training on or scraping your content; `log` if you are fine with it.\n\nManaged rulesets are toggles with one of three actions each: `log` (observe),\n`challenge` (managed edge challenge), `deny` (block). See\n`references\u002Fmanaged-rulesets`.\n\n### Step 2 - Write custom rules for your known-bad traffic\n\nA custom rule is **condition(s) → action**. Conditions combine request\nattributes; actions are `deny`, `challenge`, `bypass` (skip system\nmitigations), `rate_limit`, or `redirect`. Author from real signal - your logs,\nnot hypotheticals.\n\nOrder matters: rules evaluate first-to-last and the first match wins, so put\n**bypass\u002Fallow rules for trusted traffic ABOVE deny rules**, and specific before\nbroad. A common ordering mistake is a broad geo-deny above a bypass for your own\noffice IP - the deny fires first and locks you out.\n\nStage, review, publish (changes are draft until published):\n\n```bash\n# block a user-agent substring\nvercel firewall rules add \"Block scraper UA\" \\\n  --condition '{\"type\":\"user_agent\",\"op\":\"sub\",\"value\":\"crawler\"}' \\\n  --action deny --yes\n\nvercel firewall diff           # review staged draft\nvercel firewall publish --yes  # promote to production\n```\n\nDiscard a bad draft with `vercel firewall discard --yes`. See\n`references\u002Fcustom-rules`.\n\n### Step 3 - Block individual IPs (the fast lever)\n\nIP blocks are separate from custom rules and are the quickest response to a single\nabusive source. They publish like rules:\n\n```bash\nvercel firewall ip-blocks block 1.2.3.4 --yes\nvercel firewall ip-blocks block 1.2.3.4 --hostname app.example.com --yes  # scoped\nvercel firewall ip-blocks unblock 1.2.3.4 --yes\nvercel firewall ip-blocks list\n```\n\nReach for IP blocks for a handful of bad actors. For a *pattern* of bad actors\n(an ASN, a country, a UA family), write a custom rule instead - IP blocks do not\nscale to a botnet.\n\n### Step 4 - Rate limit abuse-prone paths\n\nTwo ways, and they are complementary:\n\n**(a) WAF rate-limit rule** - declarative, at the edge, no code. Good for blanket\npath protection:\n\n```bash\nvercel firewall rules add \"Rate limit API\" \\\n  --condition '{\"type\":\"path\",\"op\":\"pre\",\"value\":\"\u002Fapi\"}' \\\n  --action rate_limit \\\n  --rate-limit-window 60 \\\n  --rate-limit-requests 100 \\\n  --rate-limit-keys ip \\\n  --rate-limit-action deny --yes\n```\n\n**(b) `@vercel\u002Ffirewall` in code** - when the limit must key on something only your\napp knows (an org id, an authenticated user, a tenant), call `checkRateLimit`\ninside the handler:\n\n```ts\nimport { checkRateLimit } from '@vercel\u002Ffirewall'\n\nexport async function POST(request: Request) {\n  const { rateLimited } = await checkRateLimit('update-object', {\n    request,\n    rateLimitKey: auth.orgId, \u002F\u002F key on the org, not the raw IP\n  })\n  if (rateLimited) {\n    return new Response(JSON.stringify({ error: 'Rate limit exceeded' }), {\n      status: 429,\n      headers: { 'Content-Type': 'application\u002Fjson' },\n    })\n  }\n  \u002F\u002F ... handler\n}\n```\n\nRule of thumb: key on IP for anonymous routes, on a stable identity (user\u002Forg) for\nauthenticated ones - IP keys punish whole offices and mobile carriers sharing a\nNAT. Starting budgets that hold up in practice: ~100 requests\u002F60s per IP for a\ngeneral anonymous API, ~10 requests\u002F60s per IP on login and password-reset (brute\nforce has no legitimate reason to exceed that), and single-digit requests per\nminute per user on expensive mutating routes like checkout or LLM calls. Set the\nbudget from your p99 legitimate usage plus headroom, then tighten from the logs.\nSee `references\u002Frate-limiting`.\n\n### Step 5 - Add a system bypass for trusted callers\n\nSome legitimate traffic must skip system-level mitigations - a verified mobile app,\na partner integration, an internal monitor. Create a bypass rule (action\n`bypass` with `bypassSystem: true`) and place it ABOVE your deny rules so it wins\nthe first-match evaluation. Scope it as tightly as possible (a specific UA regex,\na header secret, an IP allowlist) - a loose bypass is a hole punched straight\nthrough your firewall. See `references\u002Fsystem-bypass`.\n\n### Step 6 - Keep Attack Challenge Mode ready (use it, then turn it off)\n\nWhen you are actively under an L7 attack the WAF rules are not catching, flip\nAttack Challenge Mode: every visitor gets a managed challenge at the edge, which\nsheds automated load while letting humans through.\n\n```bash\nvercel firewall attack-mode enable --yes               # default ~1 hour\nvercel firewall attack-mode enable --duration 24h --yes\nvercel firewall attack-mode disable --yes\n```\n\nIt is a blunt instrument - it adds friction for *every* human too. Treat it as a\nfire extinguisher: enable for the duration of the incident, write a precise custom\nrule for the attack signature while it is on, then disable Attack Mode and let the\nrule carry the load. Do not leave it on indefinitely.\n\n### Step 7 - Lock the critical routes with BotID\n\nThe WAF cannot tell a sophisticated headless browser from a human. BotID can.\nProtect the specific routes where a bot causes real damage - checkout, signup,\nlogin, coupon\u002Fcredit redemption, \"contact sales\", and LLM-backed endpoints.\n\n1. Install and wire the config wrapper:\n\n```bash\nnpm i botid\n```\n\n```ts\n\u002F\u002F next.config.ts\nimport { withBotId } from 'botid\u002Fnext\u002Fconfig'\nconst nextConfig = { \u002F* your config *\u002F }\nexport default withBotId(nextConfig)\n```\n\n2. Declare protected routes on the client so BotID attaches its classification\n   headers (App Router: in the root layout `\u003Chead>`):\n\n```tsx\nimport { BotIdClient } from 'botid\u002Fclient'\n\nconst protectedRoutes = [{ path: '\u002Fapi\u002Fcheckout', method: 'POST' }]\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n  return (\n    \u003Chtml lang=\"en\">\n      \u003Chead>\n        \u003CBotIdClient protect={protectedRoutes} \u002F>\n      \u003C\u002Fhead>\n      \u003Cbody>{children}\u003C\u002Fbody>\n    \u003C\u002Fhtml>\n  )\n}\n```\n\n3. Verify server-side in the handler and reject bots:\n\n```ts\nimport { checkBotId } from 'botid\u002Fserver'\nimport { NextResponse } from 'next\u002Fserver'\n\nexport async function POST(request: Request) {\n  const verification = await checkBotId()\n  if (verification.isBot) {\n    return NextResponse.json({ error: 'Access denied' }, { status: 403 })\n  }\n  \u002F\u002F ... protected logic\n}\n```\n\nThe client `protect` list and the server `checkBotId()` call must cover the same\nroute and (if used) the same `checkLevel` - a mismatch blocks real users or lets\nbots through. Use `checkLevel: 'deepAnalysis'` for the highest-value routes and\n`'basic'` for lighter ones. See `references\u002Fbotid`.\n\n### Step 8 - Verify, then audit\n\nRun the checklist tool below to confirm coverage, then watch the Firewall\nobservability tab through the soak window (3-7 days): rulesets at `log` reveal\nwhat `deny` would have blocked, and BotID's dashboard shows the human\u002Fbot split\nper protected route. Promote `log` → `deny` only after the log is clean - as a\nworking bar, a false-positive rate visibly above ~0.1% of legitimate traffic in\nthe log means the rule needs narrowing before it denies.\n\n## Quality bar\n\nA finished hardening pass is A+ only when all hold:\n\n- Managed OWASP, bot_protection, and ai_bots are each explicitly set to a chosen\n  action - none left at the default by omission, and the choice is justified.\n- Every custom `deny`\u002F`challenge` rule was profiled at `log` first, OR there is a\n  stated reason it is safe to deny immediately (e.g. a known attack IP).\n- Bypass\u002Fallow rules sit ABOVE deny rules; rule order has been read top-to-bottom\n  and the author's own access path is not accidentally denied.\n- Rate limits key on a stable identity for authenticated routes and on IP only for\n  anonymous ones - no IP-keyed limit on a route behind a shared NAT.\n- Every route that mutates money, accounts, or credits is BotID-protected, with the\n  client `protect` list and server `checkBotId` `checkLevel` matching exactly.\n- Attack Challenge Mode is OFF in steady state; if on, an incident is open and a\n  specific rule is being written to replace it.\n- All firewall changes were reviewed with `vercel firewall diff` before\n  `publish` - nothing shipped straight from a draft unread.\n\n## Do NOT\n\n- Do NOT set OWASP CRS straight to `deny` on a live app without a `log` soak -\n  you will block legitimate requests that merely look like an attack pattern.\n- Do NOT order a broad geo\u002FUA deny above your own bypass\u002Fallow rule - first match\n  wins and you will lock yourself (or partners) out.\n- Do NOT rate-limit authenticated routes by IP - corporate\u002Fmobile NAT means one\n  abuser rate-limits an entire building. Key on user\u002Forg via `@vercel\u002Ffirewall`.\n- Do NOT leave Attack Challenge Mode on as a \"default secure\" posture - it taxes\n  every human visitor and tanks conversion; it is an incident tool only.\n- Do NOT rely on BotID for authorization. `isBot` answers \"human or bot\", not \"is\n  this user allowed\" - keep your auth checks. BotID complements, never replaces,\n  app-level authz.\n- Do NOT scope a system-bypass rule loosely (e.g. bypass on a common UA substring)\n  - that is a tunnel through your own firewall for anyone who spoofs it.\n- Do NOT put secrets or block-list values in `next.config` \u002F `vercel.ts`; rule\n  config lives in the firewall, and secrets belong in `vercel-env-management`.\n- Do NOT hand-edit a managed ruleset rule-by-rule expecting it to persist - managed\n  rulesets are Vercel-maintained toggles; encode YOUR exceptions as custom rules.\n\n## Checklist tool\n\nSelf-contained Node script - no dependencies, no network. It scores a project's\nedge-security posture from a small config object you fill in, and prints the gaps\nin priority order. Save as `firewall_audit.mjs` and run `node firewall_audit.mjs`.\n\n```javascript\n\u002F\u002F Vercel edge-security audit. Edit the posture object, then: node firewall_audit.mjs\n\u002F\u002F Describe what is ACTUALLY configured on the project, honestly.\nconst posture = {\n  managed: {\n    owasp: 'log',          \u002F\u002F 'off' | 'log' | 'challenge' | 'deny'\n    botProtection: 'deny', \u002F\u002F 'off' | 'log' | 'challenge' | 'deny'\n    aiBots: 'off',         \u002F\u002F 'off' | 'log' | 'challenge' | 'deny'\n  },\n  rateLimitedApiPaths: true,    \u002F\u002F is \u002Fapi (or hot paths) rate limited at all?\n  authRoutesKeyedByIdentity: false, \u002F\u002F auth'd rate limits key on user\u002Forg (not IP)?\n  bypassAboveDeny: true,        \u002F\u002F do allow\u002Fbypass rules sit above deny rules?\n  attackModeOn: false,          \u002F\u002F is Attack Challenge Mode enabled right now?\n  incidentOpen: false,          \u002F\u002F is there an active attack right now?\n  \u002F\u002F Routes that mutate money\u002Faccounts\u002Fcredits, and whether BotID guards each.\n  criticalRoutes: [\n    { path: '\u002Fapi\u002Fcheckout', botid: true },\n    { path: '\u002Fapi\u002Fsignup',   botid: false },\n    { path: '\u002Fapi\u002Fredeem',   botid: false },\n  ],\n}\n\nconst findings = []\nconst add = (sev, msg) => findings.push({ sev, msg })\nconst RANK = { CRITICAL: 0, HIGH: 1, MEDIUM: 2, LOW: 3 }\n\n\u002F\u002F Managed rulesets\nif (posture.managed.owasp === 'off')\n  add('HIGH', 'OWASP CRS is off - enable it (start at log, then deny after a soak).')\nif (posture.managed.owasp === 'log')\n  add('MEDIUM', 'OWASP CRS is at log - graduate to deny once the log is clean.')\nif (posture.managed.botProtection === 'off')\n  add('HIGH', 'bot_protection is off - set it to challenge or deny.')\nif (posture.managed.aiBots === 'off')\n  add('LOW', 'ai_bots is off - decide deliberately: deny to keep AI crawlers out, or log if intentional.')\n\n\u002F\u002F Rate limiting\nif (!posture.rateLimitedApiPaths)\n  add('HIGH', 'No rate limit on API paths - add a WAF rate_limit rule on \u002Fapi.')\nif (posture.rateLimitedApiPaths && !posture.authRoutesKeyedByIdentity)\n  add('MEDIUM', 'Authenticated routes appear IP-keyed - key on user\u002Forg via @vercel\u002Ffirewall so shared NAT is not punished.')\n\n\u002F\u002F Rule ordering\nif (!posture.bypassAboveDeny)\n  add('CRITICAL', 'Bypass\u002Fallow rules are NOT above deny rules - first match wins; you may be locking out trusted traffic (or yourself).')\n\n\u002F\u002F Attack mode hygiene\nif (posture.attackModeOn && !posture.incidentOpen)\n  add('HIGH', 'Attack Challenge Mode is ON with no open incident - it taxes every human; disable it and rely on rules.')\nif (posture.incidentOpen && !posture.attackModeOn)\n  add('HIGH', 'Active incident but Attack Mode is off - enable it for the incident window while you write a targeted rule.')\n\n\u002F\u002F BotID coverage on critical routes\nfor (const r of posture.criticalRoutes) {\n  if (!r.botid) add('CRITICAL', `Critical route ${r.path} has no BotID - wire checkBotId() (client protect + server check).`)\n}\n\nfindings.sort((a, b) => RANK[a.sev] - RANK[b.sev])\nconst covered = posture.criticalRoutes.filter((r) => r.botid).length\nconsole.log('Edge-security audit')\nconsole.log('Critical routes with BotID: ' + covered + '\u002F' + posture.criticalRoutes.length)\nconsole.log('Findings: ' + findings.length)\nif (findings.length === 0) {\n  console.log('  Clean - baseline, rate limits, ordering, and BotID all check out.')\n} else {\n  for (const f of findings) console.log('  [' + f.sev + '] ' + f.msg)\n}\nconst blocked = findings.some((f) => f.sev === 'CRITICAL')\nconsole.log('\\nVerdict: ' + (blocked ? 'NOT SHIP-READY - resolve CRITICAL findings first.' : 'Ship-ready; address remaining findings on a soak.'))\n```\n\n### Worked example output\n\nWith the posture above the script prints:\n\n```\nEdge-security audit\nCritical routes with BotID: 1\u002F3\nFindings: 5\n  [CRITICAL] Critical route \u002Fapi\u002Fsignup has no BotID - wire checkBotId() (client protect + server check).\n  [CRITICAL] Critical route \u002Fapi\u002Fredeem has no BotID - wire checkBotId() (client protect + server check).\n  [MEDIUM] OWASP CRS is at log - graduate to deny once the log is clean.\n  [MEDIUM] Authenticated routes appear IP-keyed - key on user\u002Forg via @vercel\u002Ffirewall so shared NAT is not punished.\n  [LOW] ai_bots is off - decide deliberately: deny to keep AI crawlers out, or log if intentional.\n\nVerdict: NOT SHIP-READY - resolve CRITICAL findings first.\n```\n\nRead it: the WAF baseline is mostly in place, but two money\u002Faccount routes\n(`\u002Fapi\u002Fsignup`, `\u002Fapi\u002Fredeem`) have no BotID, which is the real exposure - a\nheadless browser sails past the WAF and hammers signup. Fix those first, then\ngraduate OWASP from `log` to `deny` and re-key the authenticated rate limits.\nRe-run after each change.\n\n## Template: edge-security plan\n\nCopy this, fill the FILL fields, and keep it next to the project as the record of\nwhat is protected and why.\n\n```\nEDGE SECURITY PLAN. [FILL: project] on Vercel. [FILL: date]\n\nMANAGED RULESETS (action + why)\n  OWASP CRS:        [FILL: log|challenge|deny]  - [FILL: reason]\n  bot_protection:   [FILL: challenge|deny]      - [FILL: reason]\n  ai_bots:          [FILL: log|deny]            - [FILL: keep out \u002F allow]\n\nCUSTOM RULES (top-to-bottom = evaluation order; allow\u002Fbypass ABOVE deny)\n  1. [FILL: allow\u002Fbypass]  condition: [FILL]  action: bypass\n  2. [FILL]                condition: [FILL]  action: [deny|challenge|rate_limit]\n  (add rows; first match wins)\n\nIP BLOCKS\n  [FILL: ip \u002F \"none\"]                            - [FILL: reason]\n\nRATE LIMITS\n  Anonymous (\u002F[FILL] paths):  [FILL] req \u002F [FILL]s, key=ip, on-exceed=deny\n  Authenticated:              [FILL] req \u002F [FILL]s, key=[user|org] via @vercel\u002Ffirewall\n\nSYSTEM BYPASS\n  [FILL: who \u002F \"none\"]   scope: [FILL: tight condition]\n\nATTACK MODE\n  Steady state: OFF.  Runbook: enable --duration [FILL] during an incident,\n  write a targeted rule, then disable.\n\nBOTID-PROTECTED ROUTES (client protect + server checkBotId match)\n  [FILL: \u002Fapi\u002Fcheckout]   checkLevel: [deepAnalysis|basic]\n  [FILL: \u002Fapi\u002Fsignup]     checkLevel: [deepAnalysis|basic]\n  (every route that moves money \u002F accounts \u002F credits)\n\nREVIEW: all changes via 'vercel firewall diff' before 'publish'. Soak log-mode\nrulesets [FILL] days before promoting to deny.\n```\n\n## references\u002Fmanaged-rulesets\n\nManaged rulesets are Vercel-maintained bundles you toggle per project, each with a\nsingle action: `log`, `challenge`, or `deny`. The ones that matter:\n\n- **owasp** - the OWASP Core Rule Set: signatures for SQL injection, XSS, path\n  traversal, and other common web attacks. The standard first line. Soak at `log`\n  to learn its false positives against your real traffic, then promote to `deny`.\n- **bot_protection** - known malicious\u002Fabusive bots. `challenge` or `deny`.\n- **ai_bots** - AI scrapers and training crawlers. A content\u002Fpolicy decision:\n  `deny` to keep them out, `log` if you intend to be indexed by them.\n- **traffic-source \u002F vercel rulesets** - additional Vercel-maintained categories;\n  enable per your risk tolerance.\n\nSet actions in the dashboard (Project → Firewall) or via the SDK\n(`vercel.security.updateFirewallConfig` with `action: 'managedRules.update'`, the\nruleset id, and `{ active, action }`). Managed rules are toggles - encode your own\nexceptions as custom rules (next section) rather than expecting to edit the bundle.\n\n## references\u002Fcustom-rules\n\nA custom rule = one or more **conditions** combined into condition groups, mapped\nto an **action**. Condition `type`s include `path`, `ip`, geo, `user_agent`,\n`header`, `query`, and JA4 fingerprint; `op` is the match operator (`pre` prefix,\n`sub` substring, `re` regex, `inc` includes, `eq`, etc.). Actions: `deny`,\n`challenge`, `bypass`, `rate_limit`, `redirect`.\n\nAuthor from real signal in the Firewall observability tab, not guesses. Three\nthings to get right every time:\n\n1. **Order.** Rules evaluate first-to-last; the first match wins. Allow\u002Fbypass\n   rules for trusted traffic go ABOVE deny rules. Specific before broad.\n2. **Stage then publish.** Every change is a draft until published. Review with\n   `vercel firewall diff`, then `vercel firewall publish --yes`; abandon a bad\n   draft with `vercel firewall discard --yes`. Reorder with\n   `vercel firewall rules reorder \u003Cname-or-id>`.\n3. **Profile before denying.** A new broad rule starts at `challenge` or `log`,\n   not `deny`, until you have watched it against live traffic.\n\nCLI mirror of the dashboard: `vercel firewall rules add|list|inspect|enable|\ndisable|remove|reorder`, `vercel firewall overview`. The same config is available\nvia `@vercel\u002Fsdk` (`vercel.security.updateFirewallConfig`,\n`action: 'rules.insert'`) for programmatic\u002FIaC management.\n\n## references\u002Frate-limiting\n\nTwo surfaces, pick by what the key needs to be:\n\n- **WAF rate-limit rule** (declarative, edge): a custom rule with action\n  `rate_limit`, a window, a request count, keys (e.g. `ip`), and an on-exceed\n  action (`deny` or `challenge`). Best for blanket path protection where IP is a\n  fine key - anonymous `\u002Fapi` traffic, login brute-force defense by IP.\n- **`@vercel\u002Ffirewall` `checkRateLimit`** (in code): call it inside the handler\n  with a named limit and a `rateLimitKey` you compute - `auth.orgId`,\n  `session.userId`, a tenant id. You can also pair it with a dashboard rule\n  condition so the limit only applies under specific request shapes. Returns\n  `{ rateLimited }`; respond `429` when true.\n\nKeying guidance: anonymous → IP. Authenticated\u002Ftenant → stable identity. Never\nIP-key an authenticated route - a single building or mobile carrier behind one NAT\nwill trip the limit for everyone. Choose windows by route cost: tight on\nexpensive\u002Fmutating endpoints (checkout, LLM calls), loose on cheap reads.\n\n## references\u002Fsystem-bypass\n\nA bypass rule lets specific trusted traffic skip system-level mitigations -\nuseful for a verified mobile app, a partner integration, or an internal uptime\nmonitor that would otherwise trip a managed rule. It is a custom rule whose action\nis `bypass` with `bypassSystem: true` (via SDK,\n`action.mitigate = { action: 'bypass', bypassSystem: true }`).\n\nTwo non-negotiables:\n\n1. **Place it above deny rules** so first-match evaluation reaches it.\n2. **Scope it tightly** - a header secret, a narrow UA regex, a small IP\n   allowlist. A bypass on a common substring is a tunnel through your firewall that\n   any attacker can walk through by spoofing the match. The narrower, the safer.\n\n## references\u002Fbotid\n\nBotID is invisible bot verification you call per route. It runs a\nclient-side JS challenge plus server-side deep analysis and returns a verdict -\nno CAPTCHA shown to humans. It catches sophisticated automation (headless\nbrowsers, scripted clients) that the WAF cannot fingerprint by request shape\nalone. It is a complement to the WAF, not a replacement, and it is **not**\nauthorization.\n\nWiring (Next.js App Router):\n\n1. `npm i botid`, then wrap config with `withBotId` in `next.config` so the\n   proxy rewrites are installed.\n2. Declare protected routes client-side with `\u003CBotIdClient protect={[...]} \u002F>` in\n   the root layout `\u003Chead>` (Nuxt: `initBotId` in a plugin; SvelteKit and other\n   frameworks have equivalents). This attaches the classification headers.\n3. In the handler call `await checkBotId()` and reject when `verification.isBot`\n   (respond `403`). For Server Actions, throw on `isBot`.\n\nTuning and gotchas:\n\n- **`checkLevel`**: `'deepAnalysis'` for the highest-value routes, `'basic'` for\n  lighter ones. The client `advancedOptions.checkLevel` and the server\n  `checkBotId({ advancedOptions: { checkLevel } })` MUST match per route - a\n  mismatch blocks real users or lets bots through.\n- **Verified bots**: `checkBotId()` also returns `isVerifiedBot`,\n  `verifiedBotName`, and `verifiedBotCategory`, so you can allow, say,\n  `chatgpt-operator` while denying the rest.\n- **Separate frontend\u002Fbackend domains**: pass\n  `advancedOptions.extraAllowedHosts` on the server so cross-domain requests are\n  accepted.\n- **Local dev**: simulate verdicts with\n  `checkBotId({ developmentOptions: { bypass: 'BAD-BOT' } })` (default\n  `'HUMAN'`) to exercise the bot branch without deploying.\n\nProtect the routes where a bot causes real loss - checkout, signup, login,\ncredit\u002Fcoupon redemption, and LLM-backed endpoints (the ones `vercel-ai-gateway`\nfronts are prime targets, since each automated call costs real inference money).\nLeave read-only\u002Fpublic routes alone; BotID adds a round trip you do not want on\nevery page.\n","# Vercel Firewall and BotID\n\nThis is the security stage of the ship-a-Next.js-app-on-Vercel workflow. You make\nthe app hard to attack at the edge - before a single request reaches a Function -\nand you make abuse-prone routes prove the caller is human. Two systems do this,\nand they are not interchangeable:\n\n- The **Vercel WAF \u002F Firewall** filters traffic by request shape (IP, path,\n  geo, user-agent, headers, JA4) and by rate. It runs on the Edge Network in\n  front of every deployment, included on all plans, and you pay nothing extra to\n  deny a request before it bills compute. Configure it once per project.\n- **BotID** is invisible, per-route bot verification you call from server code on\n  the specific endpoints that get abused (checkout, signup, login, \"add to cart\",\n  LLM-backed routes). It is a JS challenge plus deep analysis, and it does not\n  show a CAPTCHA to humans.\n\nUse both, in that order: the WAF is the blanket, BotID is the lock on the doors\nthat matter. This skill is opinionated and sequenced; it is deliberately **not** a\nrestatement of the official `vercel firewall` CLI plugin - it tells you what to\nturn on, in what order, and what NOT to do.\n\nTrigger eagerly on: \"protect my Vercel app\", \"add a WAF rule\", \"rate limit\",\n\"block an IP \u002F country \u002F bot\", \"I'm under attack\" \u002F \"DDoS\", \"stop scrapers or AI\ncrawlers\", \"Attack Mode\", or \"verify human on `\u003Croute>`\" \u002F \"set up BotID\".\n\nWhere it fits in the pack: you should already have a green deploy\n(`vercel-deploy-pipeline`) and managed secrets (`vercel-env-management`). Hand\nback to `next-on-vercel-perf` if a firewall rule changes cache behavior, and to\n`vercel-edge-and-isr` if you start gating ISR\u002Fstatic routes. LLM endpoints fronted\nby `vercel-ai-gateway` are exactly the ones that deserve BotID.\n\n## Mental model: five layers, outermost first\n\nA request hits these in order. Stop abuse at the outermost layer that can see it -\nthe further out, the cheaper.\n\n1. **Automatic DDoS mitigation** - always on, nothing to configure. Vercel's Edge\n   Network absorbs and mitigates volumetric L3\u002FL4 and many L7 floods globally. You\n   do not turn this on; you escalate past it with the layers below when an attack\n   is application-shaped.\n2. **Managed rulesets** - Vercel-maintained rule bundles you toggle: the **OWASP\n   Core Rule Set** (`owasp`) for SQLi\u002FXSS\u002Ftraversal patterns, **bot_protection**\n   for known bad bots, **ai_bots** for AI scrapers\u002Fcrawlers, and traffic-source\n   rules. Each is set to an action: `log`, `challenge`, or `deny`.\n3. **Custom rules** - your own conditions (path, IP, geo, user-agent, header,\n   query, JA4) → an action. This is most of the day-to-day work.\n4. **Rate limiting** - per-key request budgets, either as a custom-rule action or\n   precisely in code via `@vercel\u002Ffirewall`.\n5. **BotID** - in-Function verification of the actual caller on named routes.\n\nAttack Challenge Mode is a global override that sits on top of all of these: when\non, every visitor gets a managed challenge at the edge.\n\n## Operating procedure\n\nRun in order. Do not jump to BotID before the WAF baseline is set - most abuse\nnever needs application code to stop.\n\n### Step 1 - Establish the WAF baseline (managed rulesets)\n\nTurn on the Vercel-managed rulesets before writing any custom rule. In the\ndashboard (Project → Firewall) or via SDK, enable and set actions:\n\n- **OWASP CRS** (`owasp`): start at `log` and soak for 3-7 days of representative\n  traffic (long enough to cover a weekly cycle of real usage) to learn its false\n  positives, then move to `deny`. Going straight to `deny` on a busy app risks\n  blocking legitimate requests you have not profiled.\n- **bot_protection**: `challenge` or `deny` for known malicious bots.\n- **ai_bots**: decide deliberately - `deny` if you do not want LLM crawlers\n  training on or scraping your content; `log` if you are fine with it.\n\nManaged rulesets are toggles with one of three actions each: `log` (observe),\n`challenge` (managed edge challenge), `deny` (block). See\n`references\u002Fmanaged-rulesets`.\n\n### Step 2 - Write custom rules for your known-bad traffic\n\nA custom rule is **condition(s) → action**. Conditions combine request\nattributes; actions are `deny`, `challenge`, `bypass` (skip system\nmitigations), `rate_limit`, or `redirect`. Author from real signal - your logs,\nnot hypotheticals.\n\nOrder matters: rules evaluate first-to-last and the first match wins, so put\n**bypass\u002Fallow rules for trusted traffic ABOVE deny rules**, and specific before\nbroad. A common ordering mistake is a broad geo-deny above a bypass for your own\noffice IP - the deny fires first and locks you out.\n\nStage, review, publish (changes are draft until published):\n\n```bash\n# block a user-agent substring\nvercel firewall rules add \"Block scraper UA\" \\\n  --condition '{\"type\":\"user_agent\",\"op\":\"sub\",\"value\":\"crawler\"}' \\\n  --action deny --yes\n\nvercel firewall diff           # review staged draft\nvercel firewall publish --yes  # promote to production\n```\n\nDiscard a bad draft with `vercel firewall discard --yes`. See\n`references\u002Fcustom-rules`.\n\n### Step 3 - Block individual IPs (the fast lever)\n\nIP blocks are separate from custom rules and are the quickest response to a single\nabusive source. They publish like rules:\n\n```bash\nvercel firewall ip-blocks block 1.2.3.4 --yes\nvercel firewall ip-blocks block 1.2.3.4 --hostname app.example.com --yes  # scoped\nvercel firewall ip-blocks unblock 1.2.3.4 --yes\nvercel firewall ip-blocks list\n```\n\nReach for IP blocks for a handful of bad actors. For a *pattern* of bad actors\n(an ASN, a country, a UA family), write a custom rule instead - IP blocks do not\nscale to a botnet.\n\n### Step 4 - Rate limit abuse-prone paths\n\nTwo ways, and they are complementary:\n\n**(a) WAF rate-limit rule** - declarative, at the edge, no code. Good for blanket\npath protection:\n\n```bash\nvercel firewall rules add \"Rate limit API\" \\\n  --condition '{\"type\":\"path\",\"op\":\"pre\",\"value\":\"\u002Fapi\"}' \\\n  --action rate_limit \\\n  --rate-limit-window 60 \\\n  --rate-limit-requests 100 \\\n  --rate-limit-keys ip \\\n  --rate-limit-action deny --yes\n```\n\n**(b) `@vercel\u002Ffirewall` in code** - when the limit must key on something only your\napp knows (an org id, an authenticated user, a tenant), call `checkRateLimit`\ninside the handler:\n\n```ts\nimport { checkRateLimit } from '@vercel\u002Ffirewall'\n\nexport async function POST(request: Request) {\n  const { rateLimited } = await checkRateLimit('update-object', {\n    request,\n    rateLimitKey: auth.orgId, \u002F\u002F key on the org, not the raw IP\n  })\n  if (rateLimited) {\n    return new Response(JSON.stringify({ error: 'Rate limit exceeded' }), {\n      status: 429,\n      headers: { 'Content-Type': 'application\u002Fjson' },\n    })\n  }\n  \u002F\u002F ... handler\n}\n```\n\nRule of thumb: key on IP for anonymous routes, on a stable identity (user\u002Forg) for\nauthenticated ones - IP keys punish whole offices and mobile carriers sharing a\nNAT. Starting budgets that hold up in practice: ~100 requests\u002F60s per IP for a\ngeneral anonymous API, ~10 requests\u002F60s per IP on login and password-reset (brute\nforce has no legitimate reason to exceed that), and single-digit requests per\nminute per user on expensive mutating routes like checkout or LLM calls. Set the\nbudget from your p99 legitimate usage plus headroom, then tighten from the logs.\nSee `references\u002Frate-limiting`.\n\n### Step 5 - Add a system bypass for trusted callers\n\nSome legitimate traffic must skip system-level mitigations - a verified mobile app,\na partner integration, an internal monitor. Create a bypass rule (action\n`bypass` with `bypassSystem: true`) and place it ABOVE your deny rules so it wins\nthe first-match evaluation. Scope it as tightly as possible (a specific UA regex,\na header secret, an IP allowlist) - a loose bypass is a hole punched straight\nthrough your firewall. See `references\u002Fsystem-bypass`.\n\n### Step 6 - Keep Attack Challenge Mode ready (use it, then turn it off)\n\nWhen you are actively under an L7 attack the WAF rules are not catching, flip\nAttack Challenge Mode: every visitor gets a managed challenge at the edge, which\nsheds automated load while letting humans through.\n\n```bash\nvercel firewall attack-mode enable --yes               # default ~1 hour\nvercel firewall attack-mode enable --duration 24h --yes\nvercel firewall attack-mode disable --yes\n```\n\nIt is a blunt instrument - it adds friction for *every* human too. Treat it as a\nfire extinguisher: enable for the duration of the incident, write a precise custom\nrule for the attack signature while it is on, then disable Attack Mode and let the\nrule carry the load. Do not leave it on indefinitely.\n\n### Step 7 - Lock the critical routes with BotID\n\nThe WAF cannot tell a sophisticated headless browser from a human. BotID can.\nProtect the specific routes where a bot causes real damage - checkout, signup,\nlogin, coupon\u002Fcredit redemption, \"contact sales\", and LLM-backed endpoints.\n\n1. Install and wire the config wrapper:\n\n```bash\nnpm i botid\n```\n\n```ts\n\u002F\u002F next.config.ts\nimport { withBotId } from 'botid\u002Fnext\u002Fconfig'\nconst nextConfig = { \u002F* your config *\u002F }\nexport default withBotId(nextConfig)\n```\n\n2. Declare protected routes on the client so BotID attaches its classification\n   headers (App Router: in the root layout `\u003Chead>`):\n\n```tsx\nimport { BotIdClient } from 'botid\u002Fclient'\n\nconst protectedRoutes = [{ path: '\u002Fapi\u002Fcheckout', method: 'POST' }]\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n  return (\n    \u003Chtml lang=\"en\">\n      \u003Chead>\n        \u003CBotIdClient protect={protectedRoutes} \u002F>\n      \u003C\u002Fhead>\n      \u003Cbody>{children}\u003C\u002Fbody>\n    \u003C\u002Fhtml>\n  )\n}\n```\n\n3. Verify server-side in the handler and reject bots:\n\n```ts\nimport { checkBotId } from 'botid\u002Fserver'\nimport { NextResponse } from 'next\u002Fserver'\n\nexport async function POST(request: Request) {\n  const verification = await checkBotId()\n  if (verification.isBot) {\n    return NextResponse.json({ error: 'Access denied' }, { status: 403 })\n  }\n  \u002F\u002F ... protected logic\n}\n```\n\nThe client `protect` list and the server `checkBotId()` call must cover the same\nroute and (if used) the same `checkLevel` - a mismatch blocks real users or lets\nbots through. Use `checkLevel: 'deepAnalysis'` for the highest-value routes and\n`'basic'` for lighter ones. See `references\u002Fbotid`.\n\n### Step 8 - Verify, then audit\n\nRun the checklist tool below to confirm coverage, then watch the Firewall\nobservability tab through the soak window (3-7 days): rulesets at `log` reveal\nwhat `deny` would have blocked, and BotID's dashboard shows the human\u002Fbot split\nper protected route. Promote `log` → `deny` only after the log is clean - as a\nworking bar, a false-positive rate visibly above ~0.1% of legitimate traffic in\nthe log means the rule needs narrowing before it denies.\n\n## Quality bar\n\nA finished hardening pass is A+ only when all hold:\n\n- Managed OWASP, bot_protection, and ai_bots are each explicitly set to a chosen\n  action - none left at the default by omission, and the choice is justified.\n- Every custom `deny`\u002F`challenge` rule was profiled at `log` first, OR there is a\n  stated reason it is safe to deny immediately (e.g. a known attack IP).\n- Bypass\u002Fallow rules sit ABOVE deny rules; rule order has been read top-to-bottom\n  and the author's own access path is not accidentally denied.\n- Rate limits key on a stable identity for authenticated routes and on IP only for\n  anonymous ones - no IP-keyed limit on a route behind a shared NAT.\n- Every route that mutates money, accounts, or credits is BotID-protected, with the\n  client `protect` list and server `checkBotId` `checkLevel` matching exactly.\n- Attack Challenge Mode is OFF in steady state; if on, an incident is open and a\n  specific rule is being written to replace it.\n- All firewall changes were reviewed with `vercel firewall diff` before\n  `publish` - nothing shipped straight from a draft unread.\n\n## Do NOT\n\n- Do NOT set OWASP CRS straight to `deny` on a live app without a `log` soak -\n  you will block legitimate requests that merely look like an attack pattern.\n- Do NOT order a broad geo\u002FUA deny above your own bypass\u002Fallow rule - first match\n  wins and you will lock yourself (or partners) out.\n- Do NOT rate-limit authenticated routes by IP - corporate\u002Fmobile NAT means one\n  abuser rate-limits an entire building. Key on user\u002Forg via `@vercel\u002Ffirewall`.\n- Do NOT leave Attack Challenge Mode on as a \"default secure\" posture - it taxes\n  every human visitor and tanks conversion; it is an incident tool only.\n- Do NOT rely on BotID for authorization. `isBot` answers \"human or bot\", not \"is\n  this user allowed\" - keep your auth checks. BotID complements, never replaces,\n  app-level authz.\n- Do NOT scope a system-bypass rule loosely (e.g. bypass on a common UA substring)\n  - that is a tunnel through your own firewall for anyone who spoofs it.\n- Do NOT put secrets or block-list values in `next.config` \u002F `vercel.ts`; rule\n  config lives in the firewall, and secrets belong in `vercel-env-management`.\n- Do NOT hand-edit a managed ruleset rule-by-rule expecting it to persist - managed\n  rulesets are Vercel-maintained toggles; encode YOUR exceptions as custom rules.\n\n## Checklist tool\n\nSelf-contained Node script - no dependencies, no network. It scores a project's\nedge-security posture from a small config object you fill in, and prints the gaps\nin priority order. Save as `firewall_audit.mjs` and run `node firewall_audit.mjs`.\n\n```javascript\n\u002F\u002F Vercel edge-security audit. Edit the posture object, then: node firewall_audit.mjs\n\u002F\u002F Describe what is ACTUALLY configured on the project, honestly.\nconst posture = {\n  managed: {\n    owasp: 'log',          \u002F\u002F 'off' | 'log' | 'challenge' | 'deny'\n    botProtection: 'deny', \u002F\u002F 'off' | 'log' | 'challenge' | 'deny'\n    aiBots: 'off',         \u002F\u002F 'off' | 'log' | 'challenge' | 'deny'\n  },\n  rateLimitedApiPaths: true,    \u002F\u002F is \u002Fapi (or hot paths) rate limited at all?\n  authRoutesKeyedByIdentity: false, \u002F\u002F auth'd rate limits key on user\u002Forg (not IP)?\n  bypassAboveDeny: true,        \u002F\u002F do allow\u002Fbypass rules sit above deny rules?\n  attackModeOn: false,          \u002F\u002F is Attack Challenge Mode enabled right now?\n  incidentOpen: false,          \u002F\u002F is there an active attack right now?\n  \u002F\u002F Routes that mutate money\u002Faccounts\u002Fcredits, and whether BotID guards each.\n  criticalRoutes: [\n    { path: '\u002Fapi\u002Fcheckout', botid: true },\n    { path: '\u002Fapi\u002Fsignup',   botid: false },\n    { path: '\u002Fapi\u002Fredeem',   botid: false },\n  ],\n}\n\nconst findings = []\nconst add = (sev, msg) => findings.push({ sev, msg })\nconst RANK = { CRITICAL: 0, HIGH: 1, MEDIUM: 2, LOW: 3 }\n\n\u002F\u002F Managed rulesets\nif (posture.managed.owasp === 'off')\n  add('HIGH', 'OWASP CRS is off - enable it (start at log, then deny after a soak).')\nif (posture.managed.owasp === 'log')\n  add('MEDIUM', 'OWASP CRS is at log - graduate to deny once the log is clean.')\nif (posture.managed.botProtection === 'off')\n  add('HIGH', 'bot_protection is off - set it to challenge or deny.')\nif (posture.managed.aiBots === 'off')\n  add('LOW', 'ai_bots is off - decide deliberately: deny to keep AI crawlers out, or log if intentional.')\n\n\u002F\u002F Rate limiting\nif (!posture.rateLimitedApiPaths)\n  add('HIGH', 'No rate limit on API paths - add a WAF rate_limit rule on \u002Fapi.')\nif (posture.rateLimitedApiPaths && !posture.authRoutesKeyedByIdentity)\n  add('MEDIUM', 'Authenticated routes appear IP-keyed - key on user\u002Forg via @vercel\u002Ffirewall so shared NAT is not punished.')\n\n\u002F\u002F Rule ordering\nif (!posture.bypassAboveDeny)\n  add('CRITICAL', 'Bypass\u002Fallow rules are NOT above deny rules - first match wins; you may be locking out trusted traffic (or yourself).')\n\n\u002F\u002F Attack mode hygiene\nif (posture.attackModeOn && !posture.incidentOpen)\n  add('HIGH', 'Attack Challenge Mode is ON with no open incident - it taxes every human; disable it and rely on rules.')\nif (posture.incidentOpen && !posture.attackModeOn)\n  add('HIGH', 'Active incident but Attack Mode is off - enable it for the incident window while you write a targeted rule.')\n\n\u002F\u002F BotID coverage on critical routes\nfor (const r of posture.criticalRoutes) {\n  if (!r.botid) add('CRITICAL', `Critical route ${r.path} has no BotID - wire checkBotId() (client protect + server check).`)\n}\n\nfindings.sort((a, b) => RANK[a.sev] - RANK[b.sev])\nconst covered = posture.criticalRoutes.filter((r) => r.botid).length\nconsole.log('Edge-security audit')\nconsole.log('Critical routes with BotID: ' + covered + '\u002F' + posture.criticalRoutes.length)\nconsole.log('Findings: ' + findings.length)\nif (findings.length === 0) {\n  console.log('  Clean - baseline, rate limits, ordering, and BotID all check out.')\n} else {\n  for (const f of findings) console.log('  [' + f.sev + '] ' + f.msg)\n}\nconst blocked = findings.some((f) => f.sev === 'CRITICAL')\nconsole.log('\\nVerdict: ' + (blocked ? 'NOT SHIP-READY - resolve CRITICAL findings first.' : 'Ship-ready; address remaining findings on a soak.'))\n```\n\n### Worked example output\n\nWith the posture above the script prints:\n\n```\nEdge-security audit\nCritical routes with BotID: 1\u002F3\nFindings: 5\n  [CRITICAL] Critical route \u002Fapi\u002Fsignup has no BotID - wire checkBotId() (client protect + server check).\n  [CRITICAL] Critical route \u002Fapi\u002Fredeem has no BotID - wire checkBotId() (client protect + server check).\n  [MEDIUM] OWASP CRS is at log - graduate to deny once the log is clean.\n  [MEDIUM] Authenticated routes appear IP-keyed - key on user\u002Forg via @vercel\u002Ffirewall so shared NAT is not punished.\n  [LOW] ai_bots is off - decide deliberately: deny to keep AI crawlers out, or log if intentional.\n\nVerdict: NOT SHIP-READY - resolve CRITICAL findings first.\n```\n\nRead it: the WAF baseline is mostly in place, but two money\u002Faccount routes\n(`\u002Fapi\u002Fsignup`, `\u002Fapi\u002Fredeem`) have no BotID, which is the real exposure - a\nheadless browser sails past the WAF and hammers signup. Fix those first, then\ngraduate OWASP from `log` to `deny` and re-key the authenticated rate limits.\nRe-run after each change.\n\n## Template: edge-security plan\n\nCopy this, fill the FILL fields, and keep it next to the project as the record of\nwhat is protected and why.\n\n```\nEDGE SECURITY PLAN. [FILL: project] on Vercel. [FILL: date]\n\nMANAGED RULESETS (action + why)\n  OWASP CRS:        [FILL: log|challenge|deny]  - [FILL: reason]\n  bot_protection:   [FILL: challenge|deny]      - [FILL: reason]\n  ai_bots:          [FILL: log|deny]            - [FILL: keep out \u002F allow]\n\nCUSTOM RULES (top-to-bottom = evaluation order; allow\u002Fbypass ABOVE deny)\n  1. [FILL: allow\u002Fbypass]  condition: [FILL]  action: bypass\n  2. [FILL]                condition: [FILL]  action: [deny|challenge|rate_limit]\n  (add rows; first match wins)\n\nIP BLOCKS\n  [FILL: ip \u002F \"none\"]                            - [FILL: reason]\n\nRATE LIMITS\n  Anonymous (\u002F[FILL] paths):  [FILL] req \u002F [FILL]s, key=ip, on-exceed=deny\n  Authenticated:              [FILL] req \u002F [FILL]s, key=[user|org] via @vercel\u002Ffirewall\n\nSYSTEM BYPASS\n  [FILL: who \u002F \"none\"]   scope: [FILL: tight condition]\n\nATTACK MODE\n  Steady state: OFF.  Runbook: enable --duration [FILL] during an incident,\n  write a targeted rule, then disable.\n\nBOTID-PROTECTED ROUTES (client protect + server checkBotId match)\n  [FILL: \u002Fapi\u002Fcheckout]   checkLevel: [deepAnalysis|basic]\n  [FILL: \u002Fapi\u002Fsignup]     checkLevel: [deepAnalysis|basic]\n  (every route that moves money \u002F accounts \u002F credits)\n\nREVIEW: all changes via 'vercel firewall diff' before 'publish'. Soak log-mode\nrulesets [FILL] days before promoting to deny.\n```\n\n## references\u002Fmanaged-rulesets\n\nManaged rulesets are Vercel-maintained bundles you toggle per project, each with a\nsingle action: `log`, `challenge`, or `deny`. The ones that matter:\n\n- **owasp** - the OWASP Core Rule Set: signatures for SQL injection, XSS, path\n  traversal, and other common web attacks. The standard first line. Soak at `log`\n  to learn its false positives against your real traffic, then promote to `deny`.\n- **bot_protection** - known malicious\u002Fabusive bots. `challenge` or `deny`.\n- **ai_bots** - AI scrapers and training crawlers. A content\u002Fpolicy decision:\n  `deny` to keep them out, `log` if you intend to be indexed by them.\n- **traffic-source \u002F vercel rulesets** - additional Vercel-maintained categories;\n  enable per your risk tolerance.\n\nSet actions in the dashboard (Project → Firewall) or via the SDK\n(`vercel.security.updateFirewallConfig` with `action: 'managedRules.update'`, the\nruleset id, and `{ active, action }`). Managed rules are toggles - encode your own\nexceptions as custom rules (next section) rather than expecting to edit the bundle.\n\n## references\u002Fcustom-rules\n\nA custom rule = one or more **conditions** combined into condition groups, mapped\nto an **action**. Condition `type`s include `path`, `ip`, geo, `user_agent`,\n`header`, `query`, and JA4 fingerprint; `op` is the match operator (`pre` prefix,\n`sub` substring, `re` regex, `inc` includes, `eq`, etc.). Actions: `deny`,\n`challenge`, `bypass`, `rate_limit`, `redirect`.\n\nAuthor from real signal in the Firewall observability tab, not guesses. Three\nthings to get right every time:\n\n1. **Order.** Rules evaluate first-to-last; the first match wins. Allow\u002Fbypass\n   rules for trusted traffic go ABOVE deny rules. Specific before broad.\n2. **Stage then publish.** Every change is a draft until published. Review with\n   `vercel firewall diff`, then `vercel firewall publish --yes`; abandon a bad\n   draft with `vercel firewall discard --yes`. Reorder with\n   `vercel firewall rules reorder \u003Cname-or-id>`.\n3. **Profile before denying.** A new broad rule starts at `challenge` or `log`,\n   not `deny`, until you have watched it against live traffic.\n\nCLI mirror of the dashboard: `vercel firewall rules add|list|inspect|enable|\ndisable|remove|reorder`, `vercel firewall overview`. The same config is available\nvia `@vercel\u002Fsdk` (`vercel.security.updateFirewallConfig`,\n`action: 'rules.insert'`) for programmatic\u002FIaC management.\n\n## references\u002Frate-limiting\n\nTwo surfaces, pick by what the key needs to be:\n\n- **WAF rate-limit rule** (declarative, edge): a custom rule with action\n  `rate_limit`, a window, a request count, keys (e.g. `ip`), and an on-exceed\n  action (`deny` or `challenge`). Best for blanket path protection where IP is a\n  fine key - anonymous `\u002Fapi` traffic, login brute-force defense by IP.\n- **`@vercel\u002Ffirewall` `checkRateLimit`** (in code): call it inside the handler\n  with a named limit and a `rateLimitKey` you compute - `auth.orgId`,\n  `session.userId`, a tenant id. You can also pair it with a dashboard rule\n  condition so the limit only applies under specific request shapes. Returns\n  `{ rateLimited }`; respond `429` when true.\n\nKeying guidance: anonymous → IP. Authenticated\u002Ftenant → stable identity. Never\nIP-key an authenticated route - a single building or mobile carrier behind one NAT\nwill trip the limit for everyone. Choose windows by route cost: tight on\nexpensive\u002Fmutating endpoints (checkout, LLM calls), loose on cheap reads.\n\n## references\u002Fsystem-bypass\n\nA bypass rule lets specific trusted traffic skip system-level mitigations -\nuseful for a verified mobile app, a partner integration, or an internal uptime\nmonitor that would otherwise trip a managed rule. It is a custom rule whose action\nis `bypass` with `bypassSystem: true` (via SDK,\n`action.mitigate = { action: 'bypass', bypassSystem: true }`).\n\nTwo non-negotiables:\n\n1. **Place it above deny rules** so first-match evaluation reaches it.\n2. **Scope it tightly** - a header secret, a narrow UA regex, a small IP\n   allowlist. A bypass on a common substring is a tunnel through your firewall that\n   any attacker can walk through by spoofing the match. The narrower, the safer.\n\n## references\u002Fbotid\n\nBotID is invisible bot verification you call per route. It runs a\nclient-side JS challenge plus server-side deep analysis and returns a verdict -\nno CAPTCHA shown to humans. It catches sophisticated automation (headless\nbrowsers, scripted clients) that the WAF cannot fingerprint by request shape\nalone. It is a complement to the WAF, not a replacement, and it is **not**\nauthorization.\n\nWiring (Next.js App Router):\n\n1. `npm i botid`, then wrap config with `withBotId` in `next.config` so the\n   proxy rewrites are installed.\n2. Declare protected routes client-side with `\u003CBotIdClient protect={[...]} \u002F>` in\n   the root layout `\u003Chead>` (Nuxt: `initBotId` in a plugin; SvelteKit and other\n   frameworks have equivalents). This attaches the classification headers.\n3. In the handler call `await checkBotId()` and reject when `verification.isBot`\n   (respond `403`). For Server Actions, throw on `isBot`.\n\nTuning and gotchas:\n\n- **`checkLevel`**: `'deepAnalysis'` for the highest-value routes, `'basic'` for\n  lighter ones. The client `advancedOptions.checkLevel` and the server\n  `checkBotId({ advancedOptions: { checkLevel } })` MUST match per route - a\n  mismatch blocks real users or lets bots through.\n- **Verified bots**: `checkBotId()` also returns `isVerifiedBot`,\n  `verifiedBotName`, and `verifiedBotCategory`, so you can allow, say,\n  `chatgpt-operator` while denying the rest.\n- **Separate frontend\u002Fbackend domains**: pass\n  `advancedOptions.extraAllowedHosts` on the server so cross-domain requests are\n  accepted.\n- **Local dev**: simulate verdicts with\n  `checkBotId({ developmentOptions: { bypass: 'BAD-BOT' } })` (default\n  `'HUMAN'`) to exercise the bot branch without deploying.\n\nProtect the routes where a bot causes real loss - checkout, signup, login,\ncredit\u002Fcoupon redemption, and LLM-backed endpoints (the ones `vercel-ai-gateway`\nfronts are prime targets, since each automated call costs real inference money).\nLeave read-only\u002Fpublic routes alone; BotID adds a round trip you do not want on\nevery page.\n",{"name":5,"metadata":24,"description":7},{"title":25},"Vercel Firewall and BotID","main","97a13607d669157a4a16d5ba79b77f208319f7b9","skills\u002Fvercel-firewall-and-botid",3,"https:\u002F\u002Fgithub.com\u002FSkillMedev\u002Fskills","https:\u002F\u002Fskillme.dev","https:\u002F\u002Fgithub.com\u002FSkillMedev","MCP-native catalog of Claude Agent Skills. Browse, recommend, install, and auto-apply skills in chat. Open source, every skill free and clonable on GitHub.","2026-10-14 03:19:31",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add SkillMedev\u002Fskills --skill vercel-firewall-and-botid",{"tool":41,"command":42},"bunx","bunx skills add SkillMedev\u002Fskills --skill vercel-firewall-and-botid",{"tool":44,"command":45},"pnpm","pnpm dlx skills add SkillMedev\u002Fskills --skill vercel-firewall-and-botid","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSkillMedev\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fvercel-firewall-and-botid\u002FSKILL.md",true,[],[50,57,64,71,78,85],{"skillNo":51,"name":52,"nameZh":6,"description":53,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":19},"01M75271B256DF3FX2VG5VRYEE","zone-2-cardio-plan","Use when someone asks to build a steady-state cardio plan, train an aerobic base or Zone 2, structure easy or endurance weekly cardio, train by heart-rate zones, or improve resting heart rate, VO2, or endurance. Builds a heart-rate-zone aerobic training block with session structure, modality choice, and progression. General fitness guidance, not medical advice. Do NOT use to design a strength or lifting program (use Strength Training Plan), high-intensity interval conditioning, HIIT, or circuits (use Conditioning & HIIT Program), or a mobility\u002Fflexibility routine (use Mobility Routine).","https:\u002F\u002Fgithub.com\u002FSkillMedev\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzone-2-cardio-plan\u002FSKILL.md",[],[],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M7526VP1QBBKYBE17S1WR86Y","youtube-script-writer","Writes retention-engineered long-form YouTube scripts on a hook\u002Fbody\u002Fpayoff architecture - a first-30-seconds hook that survives the retention cliff, a beat-sheet body with mini-hooks and bridges, timed pattern interrupts, and a payoff that over-delivers - with B-roll and editing cues marked inline. Use when someone says \"script my next video\", \"my retention graph dies at the start\", \"tighten this draft\", or \"outline a video on X\". Do NOT use for the 3-second opener of TikTok, Reels, or Shorts - use video-hook-writer instead; do NOT use for spoken voiceover synced to on-screen tutorial actions - use narration-script instead; do NOT use for a sales demo built on a buyer's discovery notes - use demo-script instead; do NOT use to design the thumbnail and title - use thumbnail-concept instead.","https:\u002F\u002Fgithub.com\u002FSkillMedev\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fyoutube-script-writer\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7526P2T0WKMHDXS4Q58237T","win-back-campaign","Designs segmented win-back email sequences for dormant users - dormancy tiers, a three-beat sequence with a single proportional incentive, and a suppression rule - and measures success by re-activation, not opens. Use when someone says \"our users went quiet\", \"design a win-back campaign\", \"how do I re-engage lapsed customers\", \"should we email people who haven't logged in for months\", or lifecycle messaging has stopped landing with a lapsed segment. Do NOT use for recovering an unfinished checkout - use abandoned-cart-sequence instead. Do NOT use for diagnosing and fixing why active customers cancel - use churn-reduction instead. Do NOT use for building always-on onboarding or nurture flows - use email-drip-builder instead.","https:\u002F\u002Fgithub.com\u002FSkillMedev\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwin-back-campaign\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7526HF2RCDJ50P93WRZRHVV","wikipedia-style","Writes neutral, verifiable, encyclopedic prose following Wikipedia's core content policies and manual of style - NPOV, inline citations, notability-backed claims, and a strict ban on promotional language. Use when someone asks \"write this like a Wikipedia article\", \"draft a Wikipedia page for this company or person\", \"make this neutral and encyclopedic\", or \"why does my article draft keep getting rejected\". Do NOT use for persuasive or opinion writing - use op-ed-writer instead; for thesis-driven academic papers, use academic-essay; for verifying claims in existing text, use fact-checker.","https:\u002F\u002Fgithub.com\u002FSkillMedev\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwikipedia-style\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7526D43CTGRKGKNQ2GB0KVX","whitepapers","Structures and writes authoritative B2B whitepapers - a standalone executive summary, a data-sized problem statement, methodology, evidence-driven findings, recommendations, and a soft call to action - flagging every claim that needs a real citation. Use when a marketer asks \"write a whitepaper on this topic\", \"turn our research into a lead-gen asset\", \"make this credible enough for executives\", or a draft reads like a product pitch instead of analysis. Do NOT use for customer-story-driven proof - use case-study-builder instead; for policy audiences, use policy-brief.","https:\u002F\u002Fgithub.com\u002FSkillMedev\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwhitepapers\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M75268423Y3K50SY5WC2NX2G","white-space-analysis","Finds unmet market gaps by ranking jobs-to-be-done on importance versus satisfaction, overlaying them against current solutions and workarounds, and validating that each gap is real, winnable, and worth winning. Use when someone asks \"where are the gaps in this market\", \"what's underserved here\", \"where should we play next\", or is hunting for product, feature, or market-entry opportunities. Do NOT use for profiling competitors and building battle cards - use competitive-intelligence instead; for putting a dollar figure on an identified opportunity - use market-sizing instead; for extracting jobs-to-be-done from raw customer interviews - use jtbd-extractor instead.","https:\u002F\u002Fgithub.com\u002FSkillMedev\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwhite-space-analysis\u002FSKILL.md",[],[]]