Skip to content

Laravel Framework XSS in Blade templating engine

Moderate severity GitHub Reviewed Published Dec 7, 2021 in laravel/framework • Updated Feb 5, 2024

Package

composer illuminate/view (Composer)

Affected versions

< 6.20.42
>= 7.0.0, < 7.30.6
>= 8.0.0, < 8.75.0

Patched versions

6.20.42
7.30.6
8.75.0
composer laravel/framework (Composer)
< 6.20.42
>= 7.0.0, < 7.30.6
>= 8.0.0, < 8.75.0
6.20.42
7.30.6
8.75.0

Description

A security researcher has disclosed a possible XSS vulnerability in the Blade templating engine.

Given the following two Blade templates:

resources/views/parent.blade.php:

@section('content')
<input value="{{ $value }}">
@show

resources/views/child.blade.php:

@extends('parent')

@section('content')
<input value="{{ $value }}">
@endsection

And a route like the following:

Route::get('/example', function() {
    $value = '//localhost/###parent-placeholder-040f06fd774092478d450774f5ba30c5da78acc8## onclick=location.assign(this.value);//';

    return view('child', ['value' => $value]);
});

The broken HTML element may be clicked and the user is taken to another location in their browser due to XSS. This is due to the user being able to guess the parent placeholder SHA-1 hash by trying common names of sections. If the parent template contains an exploitable HTML structure an XSS vulnerability can be exposed.

This vulnerability has been patched by determining the parent placeholder at runtime and using a random hash that is unique to each request.

References

@taylorotwell taylorotwell published to laravel/framework Dec 7, 2021
Reviewed Dec 7, 2021
Published by the National Vulnerability Database Dec 8, 2021
Published to the GitHub Advisory Database Dec 8, 2021
Last updated Feb 5, 2024

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

EPSS score

0.139%
(51st percentile)

CVE ID

CVE-2021-43808

GHSA ID

GHSA-66hf-2p6w-jqfw

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.