Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2024-21504 Overview
CVE-2024-21504 is a reflected Cross-Site Scripting (XSS) vulnerability affecting Laravel Livewire versions from 3.3.5 before 3.4.9. The flaw is triggered when a Livewire component uses the [Url] attribute to bind a property to a URL query parameter. An attacker can craft a malicious link that injects HTML or JavaScript into the rendered page. When a victim clicks the link, the injected payload executes in the context of the victim's browser session with the origin of the vulnerable application. The issue is tracked under [CWE-79] and was addressed in Livewire release v3.4.9.
Critical Impact
Successful exploitation allows arbitrary HTML and script execution in the victim's browser, enabling session token theft, credential harvesting, and unauthorized actions within the Livewire application.
Affected Products
- Laravel Livewire 3.3.5 through versions prior to 3.4.9
- Applications using the [Url] attribute on Livewire component properties
- Any Laravel deployment bundling vulnerable Livewire releases via Composer
Discovery Timeline
- 2024-03-19 - CVE-2024-21504 published to NVD
- 2026-06-17 - Last updated in NVD database
Technical Details for CVE-2024-21504
Vulnerability Analysis
Livewire is a full-stack framework for Laravel that builds dynamic interfaces without leaving PHP. The [Url] attribute allows a component property to be synchronized with a URL query string parameter, so state persists across page loads and can be shared via link. In vulnerable releases, values pulled from the URL into [Url]-bound properties were reflected into the DOM without proper output encoding. An attacker who controls the query string can therefore introduce HTML or JavaScript that becomes part of the rendered page.
Because the injected content originates from the trusted application origin, browser same-origin protections do not block it. The attacker's payload can access cookies scoped to the site, read DOM contents, and issue authenticated Livewire actions on the victim's behalf.
Root Cause
The root cause is missing sanitization of user-controlled input flowing from URL query parameters into [Url]-bound Livewire properties. The framework did not neutralize HTML control characters before the value was interpolated into the browser directive-processing pipeline handled by the underlying Alpine.js walker.
Attack Vector
Exploitation is remote and requires user interaction. The attacker crafts a URL to a vulnerable Livewire page that includes a malicious payload in a query parameter bound to an [Url] property. The victim must open the link, at which point the payload is reflected into the page and executed by the browser. No authentication is required on the attacker's side.
// Security patch in dist/livewire.js from commit c65b3f0798ab2c9338213ede3588c3cdf4e6fcc0
// Removes the _x_inited short-circuit that allowed directives to be re-processed
// on attacker-controlled DOM subtrees.
}) {
deferHandlingDirectives(() => {
walker(el, (el2, skip) => {
- if (el2._x_inited) {
- if (el2._x_ignore)
- skip();
- return;
- }
intercept(el2, skip);
initInterceptors.forEach((i) => i(el2, skip));
directives(el2, el2.attributes).forEach((handle) => handle());
- if (el2._x_ignore) {
- skip();
- } else {
- el2._x_inited = true;
- }
+ el2._x_ignore && skip();
});
});
}
function destroyTree(root, walker = walk) {
walker(root, (el) => {
cleanupAttributes(el);
cleanupElement(el);
- delete el._x_inited;
});
}
Source: Livewire commit c65b3f0
Detection Methods for CVE-2024-21504
Indicators of Compromise
- Inbound HTTP requests containing angle brackets, <script> fragments, javascript: URIs, or event-handler tokens such as onerror= within query string parameters bound to Livewire components.
- Referrer headers pointing to phishing domains or URL shorteners that funnel users into Livewire routes with encoded payloads.
- Web application firewall or reverse-proxy logs showing repeated encoded payload variants against the same Livewire endpoint.
Detection Strategies
- Inventory Livewire components that declare the [Url] attribute on public properties and correlate them with exposed routes.
- Inspect access logs for query parameter values that decode to HTML control characters against those routes.
- Add server-side logging of Livewire hydration payloads and flag values containing markup for offline review.
Monitoring Recommendations
- Enable Content Security Policy (CSP) report-only mode and monitor report-uri telemetry for inline script violations tied to Livewire pages.
- Alert on browser console errors or CSP violations spikes originating from authenticated users after clicking external links.
- Forward web server, WAF, and CSP report logs to a centralized analytics pipeline for cross-source correlation and retention.
How to Mitigate CVE-2024-21504
Immediate Actions Required
- Upgrade livewire/livewire to version 3.4.9 or later using Composer across every affected environment.
- Audit application code for uses of the [Url] attribute and validate that bound properties enforce strict type and character allow-lists.
- Enforce a restrictive Content Security Policy that disallows inline scripts and untrusted event handlers on Livewire-rendered pages.
Patch Information
The fix ships in Livewire v3.4.9 and is implemented in commit c65b3f0798ab2c9338213ede3588c3cdf4e6fcc0, delivered through Livewire pull request #8117. Release notes are available in the Livewire v3.4.9 release. Additional advisory details are documented in the Snyk vulnerability report SNYK-PHP-LIVEWIRELIVEWIRE-6446222.
Workarounds
- Remove the [Url] attribute from public properties until the upgrade is applied, and read query parameters manually with server-side validation.
- Cast affected properties to strict scalar types such as int or enums so raw string payloads are rejected before rendering.
- Deploy a WAF rule that blocks query string values containing <, >, or javascript: on routes handled by Livewire components.
# Upgrade Livewire to the patched release using Composer
composer require livewire/livewire:^3.4.9
composer update livewire/livewire
php artisan view:clear
php artisan config:clear
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

