Vercel Web Application Firewall

Global rule propagation in milliseconds

Instantly block yourself with the Vercel WAF

Status:
-

How it works

1

A single Vercel Web Application Firewall rule is configured for this project to check for the presence of a specific cookie in each request.

Tutorial step

2

On browser

A cookie containing the current time is added to your browser, and an API call is made to a Vercel Function, including the cookie in the request.

1 2 const cookieValue = `blockme-${Date.now()}`; document.cookie = `${cookieName}=${cookieValue}; path=/;`;
1 fetch('/api/update_firewall', { headers: { 'Content-Type': 'application/json' } })

3

On ▲ Vercel

The Vercel WAF is called via API to retrieve the latest Firewall configuration. An API call is then made to add your cookie to the block-me rule, delete any cookies older than 2 minutes, and publish the updated rule.

/app/api/update_firewall.js

1 const configUrl = `FIREWALL_API_URL_PLACEHOLDER?teamId=${process.env.TEAM_ID}&projectId=${process.env.PROJECT_ID}`;

/app/api/update_firewall.js

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 const updateFirewallUrl = `FIREWALL_API_URL_PLACEHOLDER?projectId=${process.env.PROJECT_ID}&teamId=${process.env.TEAM_ID}`; const headers = { 'Authorization': `Bearer API_TOKEN`, 'Content-Type': 'application/json', }; const updateResponse = await fetch(updateFirewallUrl, { method: 'PATCH', headers: headers, body: JSON.stringify({ id: 'rule_block_me_rule', action: 'rules.update', value: rule }), });

4

On ▲ Vercel & On Browser

Changes are propagated globally, typically in ~300ms. The iframe then loads https://blockme.vercel.app/blockme, refreshing periodically until the page is blocked.