darvis/livewire-injection-stopper
The package includes middleware that automatically blocks requests based on:
Out of the box, the following patterns are blocked (case-insensitive):
python-requests - Python HTTP librarycurl - Command-line HTTP toolwget - File download toolscrapy - Web scraping frameworkbot, spider, crawler - Generic bot patternspostman, insomnia, httpie - API testing toolsEdit config/livewire-injection-stopper.php:
'blocked_user_agents' => [
'python-requests',
'my-custom-bot',
// Add your patterns here
],
Comment out or remove patterns you want to allow:
'blocked_user_agents' => [
'python-requests',
// 'curl', // Now allowed
// 'wget', // Now allowed
'bot',
],
Block specific IP addresses:
'blocked_ips' => [
'192.168.1.100',
'10.0.0.50',
],
Exclude routes from checks (useful for webhooks):
'whitelist_routes' => [
'api/webhooks/*',
'api/mollie-webhook',
'api/stripe-webhook',
],
Pattern Matching:
api/webhooks/* - Matches any route starting with api/webhooks/api/webhook - Exact match onlyChoose the HTTP status code for blocked requests:
// 403 = Forbidden (honest response)
'response_status' => 403,
// 404 = Not Found (misleads bots)
'response_status' => 404,
Customize the message shown to blocked users:
'response_message' => 'Access Denied',
Enable or disable logging of blocked requests:
'log_blocked_requests' => true,
When enabled, blocked requests are logged as:
[2026-01-03 10:00:00] local.WARNING: [LivewireInjectionStopper] Blocked User-Agent: python-requests/2.28.0
{
"ip": "123.45.67.89",
"user_agent": "python-requests/2.28.0",
"url": "https://example.com/contact",
"method": "POST"
}
When check_payload_injection is enabled, the middleware inspects Livewire update payloads and blocks suspicious array assignments to scalar/top-level properties.
This supports common Livewire payload formats, including component-based and operation-based updates structures.
Relevant settings in config/livewire-injection-stopper.php:
'check_payload_injection' => true,
'block_all_array_injections' => true,
'scalar_properties' => [
'content', 'email', 'status', // etc.
],
If a malicious payload still reaches Livewire and throws an exception, package exception silencing can still prevent Sentry noise.
If you don't want global protection, you can apply the middleware selectively:
// In routes/web.php
Route::middleware(['livewire-injection-stopper'])->group(function () {
// Protected routes
});
// Or on specific routes
Route::post('/contact', ContactController::class)
->middleware('livewire-injection-stopper');
return [
'blocked_user_agents' => [
'python-requests',
'curl',
'wget',
'bot',
],
'blocked_ips' => [
'192.168.1.100',
],
'whitelist_routes' => [
'api/webhooks/*',
],
'response_status' => 403,
'response_message' => 'Access Denied',
'log_blocked_requests' => true,
];
How can I help you explore Laravel packages today?