darvis/livewire-injection-stopper
Protect your Laravel + Livewire app from spam bots and injection attacks. This package blocks automated bots, audits Livewire components for manipulable public properties, and silences bot-triggered exceptions so your Sentry logs stay clean.
app/Livewire, not a full component inventory.Adopt if:
public $isAdmin, public $userRole).CannotUpdateLockedPropertyException in logs.Look elsewhere if:
web group, so a POST without a valid CSRF token receives Laravel's 419 before the package ever sees it.extends Component; components extending your own base class are skipped entirely. It also skips properties without a default value, the types float, array, ?string, ?int and namespaced classes, combined attributes like #[Locked, Url], and single-line declarations such as #[Locked] public bool $x = false;. A ✅ No security issues found! message is also printed when app/Livewire does not exist, so a green result is not proof of safety.Configuration gotchas worth knowing before you ship (all newly documented in v1.3.1):
scalar_properties entries must be lowercase, and are matched against the whole property name — so email does not cover form.email.activeFilters.tags, hidden.0).* in whitelist_routes also matches slashes — a broad pattern can open more surface than intended.Livewire::test() does traverse the HTTP layer but with middleware disabled, so a component test will not demonstrate that a top-level array update is blocked in the browser — validate that path with a real request.*"This package adds a lightweight, automated shield against two costly security risks in our Laravel/Livewire apps:
By installing this in 5 minutes, we'll:
The v1.3.1 release is documentation-only — no code changes, no migration risk — and adds a step-by-step install guide with a verification check, a 5-minute quick start, and a troubleshooting page that turns error messages into fixes. That lowers the cost of adoption and the ongoing support burden. It's a no-code, low-risk upgrade with immediate ROI — think of 'set-and-forget' noise reduction and a security smoke test for our Livewire features. Important framing: it complements, and does not replace, our WAF or a proper security review — and its audit is a triage tool with known gaps, not a certification."*
*"This package solves two pain points with minimal friction:
curl, Python scripts) via user-agent/headers checks — no CAPTCHA or rate-limiting complexity. It sits at the end of the web group, so Laravel's CSRF 419 fires first, and requests with no User-Agent are never blocked — budget for that when sizing the spam reduction.public properties attackers could hijack (e.g., $isAdmin = true), with a CLI tool to flag risks. Example:
php artisan livewire:audit
Output: Lists vulnerable properties like public $userTier in ProfileComponent.CannotUpdateLockedPropertyException errors via dontReport()/reportable() (not renderable() since 1.3.0), preventing Sentry noise; the block response itself comes from the middleware and uses Laravel's default text/html content type.Tradeoffs & limits (now explicitly documented in 1.3.1):
extends Component, so components extending your own base class are invisible to it; it also skips properties without defaults, float/array/?string/?int/namespaced-typed properties, #[Locked, Url], and single-line #[Locked] declarations. ✅ No security issues found! also prints when app/Livewire is absent.scalar_properties must be lowercase and matches the whole name; published lists replace defaults rather than merge; * in whitelist_routes matches slashes.block_all_array_injections rule but are still blocked when the name starts with a fixed prefix (activeFilters.tags, hidden.0).Livewire::test() runs through the HTTP layer with middleware disabled, so component tests do not prove a top-level array update is blocked in the browser — add a request-level test.Recommendation: Add to new Livewire projects, and run livewire:audit during the next security sprint as a fast triage pass — then supplement with a manual review of base-class components and non-defaulted/typed properties it skips. Start from the new Quick start and run the install page's "check that it works" step; consult the Troubleshooting page (symptom → cause → fix) before filing issues. Composer install + middleware registration = done."*
How can I help you explore Laravel packages today?