Skip to content

Commit 3c17ed4

Browse files
PhiloNLclaude
andauthored
Add #[Locked] attributes to prevent client-side property tampering (#549)
This hardens the Modal component against Livewire hydration attacks (CVE-2025-54068). While the vulnerability was fixed in Livewire 3.6.4, adding #[Locked] to $activeComponent and $components provides defense-in-depth by preventing any client-side manipulation of these properties via the updates mechanism. The test was updated to use proper server-side methods instead of directly setting properties, which is exactly what #[Locked] prevents. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f97ca6b commit 3c17ed4

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/Modal.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@
88
use Illuminate\Support\Collection;
99
use Illuminate\Support\Reflector;
1010
use Illuminate\View\View;
11+
use Livewire\Attributes\Locked;
1112
use Livewire\Component;
1213
use Livewire\Mechanisms\ComponentRegistry;
1314
use ReflectionClass;
1415

1516
class Modal extends Component
1617
{
18+
#[Locked]
1719
public ?string $activeComponent;
1820

21+
#[Locked]
1922
public array $components = [];
2023

2124
public function resetState(): void

tests/LivewireModalTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,9 @@ public function testModalReset(): void
7272
Livewire::component('demo-modal', DemoModal::class);
7373

7474
Livewire::test(Modal::class)
75-
->dispatch('openModal', 'demo-modal')
76-
->set('components', [
77-
'some-component' => [
78-
'name' => 'demo-modal',
79-
'arguments' => ['bar'],
80-
'modalAttributes' => [],
81-
],
82-
])
83-
->set('activeComponent', 'some-component')
75+
->dispatch('openModal', component: 'demo-modal', arguments: ['message' => 'Test'])
76+
->assertNotSet('activeComponent', null)
77+
->assertNotSet('components', [])
8478
->call('resetState')
8579
// Verify properties are reset
8680
->assertSet('activeComponent', null)

0 commit comments

Comments
 (0)