XSS via unescaped Stringable values in Blade component attribute bag
Summary
Impact
Blade component attribute bags did not HTML-escape non-Htmlable object values, such as Illuminate\Support\Stringable, passed to ComponentAttributeBag::merge() or prepends(). Applications that place user-controlled Stringable values (for example, the result of `request()->stri...
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| composerlaravel/framework |
<13.43.0→ >=13.43.0 |
>=13.43.0 |
| composerlaravel/framework |
<12.73.0→ >=12.73.0 |
>=12.73.0 |
Original description The description as published by the source.
Impact
Blade component attribute bags did not HTML-escape non-Htmlable object values, such as Illuminate\Support\Stringable, passed to ComponentAttributeBag::merge() or prepends(). Applications that place user-controlled Stringable values (for example, the result of request()->string()) into component attributes could allow an attacker to break out of the attribute and inject arbitrary attributes, such as event handlers. This results in cross-site scripting that runs in the origin of the application.
Patches
The fix escapes all attribute values except null, booleans and Htmlable instances, and also escapes values wrapped with prepends(). It was merged to the 12.x branch in https://github.com/laravel/framework/pull/62503.
Workarounds
Cast user-controlled values to plain strings, for example request()->string('title')->toString(), before passing them to merge() or prepends().
Source: GitHub Repository Security Advisories (Game のスタック) GitHub Advisory OSV
References
- GITHUB_REPO_ADVISORY laravel/framework