Vercel Logo

Meet the scalper

It's 10:59am. Preorders open in one minute, and a line of real people is refreshing the page on their phones. At 11:00:00 a script grabs 150 rolls in about four seconds, and the first human to tap Hold my roll gets "Sold out." Let's be that script, against our own truck, and watch nothing stop it.

Outcome

The scalper script scrapes, preorders, and places fake orders against your deployment, and you can find every one of its requests in the Firewall traffic report, allowed.

Rules for running an attack script

The starter's attack/scalper.mjs plays three villains: Pinchy's scraping the location page, a preorder bot, and a fake-order bot. It sends a small number of requests to one URL that you pass in.

Your deployment, and nothing else

Point these scripts at the Claw & Order deployment you own. Every mode is capped at 500 requests and the script refuses plain http:// outside localhost. That cap keeps this a drill. Sending this traffic at a site you don't own is an attack, whatever the script is called.

Every mode takes --target. Through npm, put -- before the script's own arguments so npm passes them along:

npm run scalper -- <mode> --target "$URL"

Pinchy's checks where you parked

The rival truck reads /location on a timer so it can park across the street. The script compresses "every five minutes" into once a second for 20 requests, with a user agent that announces exactly who it is:

npm run scalper -- scrape --target "$URL"
scrape /location as PinchyScout → https://claw-and-order.vercel.app  (20 requests)
Only point this at a deployment you own.

  [01] 200 GET /location
  [02] 200 GET /location
  ...
  [20] 200 GET /location

Results
  200            20

Twenty 200s. The scraper signed every request PinchyScout/2.1 and got today's spot every time. One request a second is nowhere near enough volume for DDoS mitigation to notice, so as far as the platform knows, this is a regular visitor with an odd name.

The 11am rush

Now the preorder bot. It sends 200 preorders, ten at a time, each with its own phone number:

npm run scalper -- preorder --target "$URL"
preorder bot grabbing rolls → https://claw-and-order.vercel.app  (200 requests)
Only point this at a deployment you own.


Results
  201            150
  409            50

A 201 is a roll it took. A 409 is "Sold out." Open the home page in your browser.

Zero rolls left. Open the preorder page yourself and the button reads Sold out. You're the person in line with a phone, and you lost to a script.

Junk in the lunch orders

Last, the fake-order bot fills the office lunch form with 25 orders for 40 rolls each:

npm run scalper -- order --target "$URL"
fake-order bot filling the lunch form → https://claw-and-order.vercel.app  (25 requests)
Only point this at a deployment you own.


Results
  201            25

That's 1,000 rolls of lunch for totally.real.0@example.com through totally.real.24@example.com.

Read your traffic

Every rule we write from here on gets checked the same way: send traffic, then read what the Firewall did with it. Here's the report:

vercel firewall traffic list --since 1h --dimension user-agent --dimension path

Read it top down. Requests by Action comes first: one row per action from 1.2, with a total and a trend. Right now there's only an Allow row. Below it are the top lists you asked for with --dimension, the busiest user agents and paths. PinchyScout/2.1 and RollGrabber/0.9 sit near the top of the user agents, and /api/preorder leads the paths.

When one value looks interesting, inspect it to see only its traffic, broken down by something else:

vercel firewall traffic inspect user-agent "RollGrabber/0.9" --since 1h --group-by path

About 200 requests, all on /api/preorder, all allowed. We'll read every report this way from here on: actions and busiest values first, then inspect the one that doesn't belong.

The dashboard's Firewall page shows the same data with charts. Its traffic view (currently Traffic) filters by action and rule and groups by IP, user agent, path, JA4, country, and network. Use whichever you'd rather squint at.

Hands-on exercise 1.3

Run all three villains against your deployment and find their traffic.

Requirements:

  1. Run scrape, preorder, and order against your production URL.
  2. Check the home page after preorder, then open the preorder page yourself.
  3. Open the traffic view on the project's Firewall page and find the burst.
  4. Use the CLI to list the last hour of traffic by user agent and by path.
  5. Inspect RollGrabber/0.9 and confirm which path it hit.

Implementation hints:

  • vercel firewall traffic list --since 1h --dimension user-agent --dimension path narrows the report to the two lists you care about.
  • Look for PinchyScout/2.1 and RollGrabber/0.9 in the user agent list. The order bot sends a browser user agent, so it hides among your own visits.
  • Traffic can take a minute to appear. Run the command again if a list comes back empty.

Try It

Ask the CLI which actions it took in the last hour:

vercel firewall traffic list --since 1h --dimension rule

One row, Allow, and no rules in the rules list. The Firewall saw every request the scalper sent, and nothing told it to care.

Done-When

  • scrape returns 20 200s for /location
  • preorder empties the truck, and the preorder page's button reads Sold out in your browser
  • order places 25 fake lunch orders
  • vercel firewall traffic list shows PinchyScout/2.1 and RollGrabber/0.9, all allowed
  • traffic inspect on RollGrabber/0.9 shows its requests landed on /api/preorder

Troubleshooting

Every request returns 401. --target is a generated deployment URL or a preview URL, and Deployment Protection blocks scripts there. Use the production domain listed under Domains on the project overview, the one without a hash, and export URL again.

The script stops with a fetch failed error, or the results show network error. The --target URL is wrong or the deployment is down. Run echo "$URL" to check for a typo, open it in a browser to confirm the truck is up, and copy the domain from Domains again if needed.

traffic inspect says there's no traffic for the value. The value has to match exactly. Copy the user agent from the traffic list output instead of typing it.

npm run scalper scrape --target ... complains about a missing target. npm kept the arguments for itself. Add -- after scalper.

Solution

The three runs, against your own URL:

npm run scalper -- scrape   --target "$URL"
npm run scalper -- preorder --target "$URL"
npm run scalper -- order    --target "$URL"
vercel firewall traffic list --since 1h --dimension user-agent --dimension path
vercel firewall traffic inspect user-agent "RollGrabber/0.9" --since 1h --group-by path

Every villain got what it came for. In Section 2 we start writing rules, beginning with Pinchy's.

Was this helpful?

supported.