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.
web group, so a POST without a valid CSRF token receives Laravel’s 419 before the package can block it. This is important for test design and incident triage.renderable(); since 1.3.0 it uses dontReport() and reportable() only, while the block response comes from middleware.composer require plus optional/auto-enabled middleware registration. No migrations or service-provider changes are required.composer.json constraint before rollout. The current assessment said Livewire 3.x, but v1.3.1 docs reference Livewire 4.4 behavior and debug-mode TypeError handling, so support for newer Livewire versions should be verified rather than assumed.block_rules can block them.scalar_properties entries must be lowercase, and matching is against the whole property name; email does not cover form.email.block_all_array_injections, but it is still blocked when the whole name starts with a fixed prefix such as activeFilters.tags or hidden.0.* in whitelist_routes also matches slashes.extends Component, properties without default values, float, array, ?string, ?int, namespaced class types, and #[Locked, Url].#[Locked] public bool $x = false; is not recognized at all; this is a coverage gap, not a false positive.use Livewire\Attributes\Locked.silence_errors can still mask legitimate CannotUpdateLockedPropertyException cases if enabled broadly.Livewire::test() goes through the HTTP layer with middleware disabled, so component tests do not prove that a top-level array update is blocked in the browser.* and published config replacement match our intended security posture?#[Locked, Url]?dontReport()/reportable() behavior and the configured silence_errors scope?web group. CSRF runs before it, so invalid-token POSTs fail before the package sees them.Livewire::test() and for audit blind spots.dontReport()/reportable() only and whether any renderable() assumptions remain in internal docs or runbooks.scan_components off.php artisan livewire-injection-stopper:scan on a representative subset.#[Locked] declarations.scalar_properties to lowercase and full property names.whitelist_routes wildcard behavior.silence_errors only after confirming it does not hide legitimate Livewire failures.composer.json.TrustProxies; verify interaction with Throttle and CSRF. The package cannot block requests that Laravel rejects with 419 first.| Step | Action | Dependencies | Output |
|---|---|---|---|
| 1 | Install package | Composer access | Package installed |
| 2 | Run Quick Start / “Check that it works” | Staging environment | Verified middleware behavior |
| 3 | Pilot spam blocking | Middleware registered | Blocked-request logs |
| 4 | Run audit scan | CLI access | Partial security report |
| 5 | Manually review scan gaps | Dev feedback | Coverage exceptions list |
| 6 | Tune config | Updated config | Lowercase scalar properties, reviewed lists, route whitelists |
| 7 | Enable error silencing carefully | Sentry integration | Reduced noise without hidden failures |
| 8 | Monitor | Logs/metrics/Sentry | Block rate, no-UA rate, CSRF 419 rate |
config/livewire-injection-stopper.php, especially block_rules, whitelist_routes, scalar_properties, and any published lists that replace defaults.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Overly aggressive bot blocking | Legitimate traffic blocked | Whitelist user agents, tune block_rules, monitor block rate |
| User-Agent-less traffic bypass | Automated traffic not blocked | Edge/proxy controls, separate monitoring, explicit risk acceptance |
| CSRF 419 before package | Package appears ineffective or noisy in tests | Ensure valid CSRF tokens; test browser-like flow, not only Livewire::test() |
| False confidence in audit scan | Vulnerable props missed | Manual review of skipped base classes, no-default props, types, and one-line #[Locked] |
| Published list replaces defaults | Accidental weakening/over-blocking | Diff published config against package defaults |
| Silent error suppression | Legitimate errors hidden | Narrow silence_errors, review Sentry, confirm dontReport()/reportable() behavior |
| Livewire version incompatibility | Broken behavior or misleading test results | Pin compatible version; validate debug/non-debug behavior |
| Package abandonment | Unpatched issues | Fork if needed; MIT license permits this |
Livewire::test() limitations.silence_errors.How can I help you explore Laravel packages today?