Skip to content
~/cynarski.me

Stopping Livewire update-route probes with a Cloudflare rule

3 min read Security

After any Livewire vulnerability is announced, the access logs fill up with POST /livewire/update requests from scanners. Most of them are fishing for unpatched Livewire 3 apps. They're harmless to a patched app, but each one still costs a PHP invocation, and on Lambda that's money.

Livewire 4 already helps. The endpoint moved from the well-known /livewire/update to /livewire-<hash>/update, where the hash is derived from your APP_KEY:

bash
php artisan route:list | grep livewire
# POST  livewire-a1b2c3d4/update  default-livewire.update

Livewire also rejects requests without its headers. Still, a request has to reach PHP before it can be rejected there. A firewall rule drops it at the edge instead.

What a real request looks like

The Livewire JavaScript client always sends:

  • POST
  • an X-Livewire header
  • Content-Type: application/json
  • an Origin header with your own domain (it's a same-origin fetch)

Scanners usually get at least one of these wrong. We'll block anything that doesn't match.

Rule 1: block the legacy path

This app doesn't serve anything under /livewire/, so every hit is a probe. In the Cloudflare dashboard go to Security → WAF → Custom rules → Create rule, choose Edit expression, and paste:

text
starts_with(http.request.uri.path, "/livewire/")

Action: Block.

Rule 2: only browser-shaped requests to the real endpoint

text
starts_with(http.request.uri.path, "/livewire-")
and ends_with(http.request.uri.path, "/update")
and (
    http.request.method ne "POST"
    or not any(http.request.headers.names[*] == "x-livewire")
    or not any(http.request.headers["content-type"][*] contains "application/json")
    or not any(http.request.headers["origin"][*] in {"https://cynarski.me" "https://dev.cynarski.me"})
)

Action: Block. Use Block rather than a challenge: the endpoint is called by fetch(), which can't solve a challenge page, so a challenge would just break the app for real visitors.

Notes:

  • The expression uses starts_with/ends_with instead of a regex because the matches operator isn't available on every plan.
  • Matching on the prefix rather than the exact hash means the rule keeps working after you rotate APP_KEY.
  • If you use file uploads, give /upload-file the same treatment.
  • The rules only apply to proxied DNS records (orange cloud).

Check it

bash
# Probe of the legacy path → 403 from Cloudflare
curl -s -o /dev/null -w '%{http_code}\n' -X POST https://cynarski.me/livewire/update

# Real path, but not browser-shaped → 403 from Cloudflare
curl -s -o /dev/null -w '%{http_code}\n' -X POST https://cynarski.me/livewire-a1b2c3d4/update

Then click around a page that uses Livewire, such as the search palette (⌘K), and confirm it still works. Security → Events shows what the rules blocked.

What this doesn't do

This is noise reduction, not a security boundary. Headers are trivial to forge, so a targeted attacker can get past the rule. What actually protects you is keeping Livewire up to date, #[Locked] on properties users shouldn't change, and authorisation inside component actions. The rule keeps scanners from reaching PHP at all, which keeps the logs readable and the Lambda bill smaller.