darvis/livewire-injection-stopper
The audit command scans your Livewire components and traits for property injection vulnerabilities. This is a critical security feature that prevents attackers from manipulating component properties via browser console or modified requests.
Livewire components expose public properties to the frontend. Attackers can modify these properties using browser developer tools or intercepted requests, potentially:
$isAdmin = true)$maxItems = 999999)$price = 0.01)$userId = 1)Use Livewire's #[Locked] attribute to protect properties that users shouldn't modify.
php artisan livewire-injection-stopper:audit
🔍 Scanning Livewire components for security issues...
✅ No security issues found!
Your components are secure!
🔍 Scanning Livewire components for security issues...
⚠️ Potential vulnerabilities found:
[CRITICAL]
📍 app/Livewire/Admin/UserEdit.php:15
Property: $isAdmin (bool)
💡 Add #[Locked] attribute above this property
[HIGH]
📍 app/Livewire/Cart/CartComponent.php:20
Property: $cart (?Cart)
💡 Add #[Locked] attribute above this property
[MEDIUM]
📍 app/Livewire/Blog/BlogEdit.php:25
Property: $published (bool)
💡 Add #[Locked] attribute above this property
Total: 3 vulnerable properties found
Properties containing: admin, role, permission, auth
Impact: Privilege escalation, unauthorized access
Action: Fix immediately
user, client, cart, max, limit#[Locked]Impact: Data manipulation, business logic bypass
Action: Fix as soon as possible
$published, $active, $redirect)$locale, $config)Impact: Unexpected behavior, minor exploits
Action: Review and fix
class UserEdit extends Component
{
public bool $isAdmin = false;
public ?User $user = null;
public int $maxItems = 10;
public function save()
{
// Attacker could set $isAdmin = true!
if ($this->isAdmin) {
// Grant admin access
}
}
}
use Livewire\Attributes\Locked;
class UserEdit extends Component
{
#[Locked]
public bool $isAdmin = false;
#[Locked]
public ?User $user = null;
#[Locked]
public int $maxItems = 10;
// Properties users CAN modify
public string $name = '';
public string $email = '';
public function save()
{
// Now $isAdmin cannot be manipulated!
if ($this->isAdmin) {
// Safe to use
}
}
}
User, Cart, Invoice)$isAdmin, $canEdit)$maxQuantity, $limit)$locale, $settings)$redirect, $available)$name, $email, $message)$searchTerm, $sortBy)$selectedQuantity, $checked)Add to your CI pipeline:
# .github/workflows/tests.yml
- name: Security Audit
run: php artisan livewire-injection-stopper:audit
The command returns:
0 - No issues found1 - Vulnerabilities detectedSee Livewire Security Best Practices for detailed attack scenarios and how to prevent them.
How can I help you explore Laravel packages today?