Skip to content
Security advisoryCVE-2021-43808

Laravel Framework XSS in Blade templating engine

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: html @section('content') @show resources/views/child.blade.php: html @extends('parent') @section('content') @endsection And a route like the follow…

Moderate6.1Published Modified Original advisory

As published by the sources

Affected packages

  • illuminate/view
    Affected<6.20.42 || >=7.0.0,<7.30.6 || >=8.0.0,<8.75.0
    Fixed in6.20.427.30.68.75.0
  • Affected<6.20.42 || >=7.0.0,<7.30.6 || >=8.0.0,<8.75.0
    Fixed in6.20.427.30.68.75.0

Derived from the fixed versions above

What to do

  1. Upgrade illuminate/view to the fixed version in your release line: 6.20.42, 7.30.6, 8.75.0.

    composer update illuminate/view --with-dependencies
  2. Upgrade laravel/framework to the fixed version in your release line: 6.20.42, 7.30.6, 8.75.0.

    composer update laravel/framework --with-dependencies

To see which version you have installed, run composer show vendor/package. Running composer audit lists the known advisories that match your installed versions.

Quoted from the original advisory

Details

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

laravel.now is an independent community project. It is not affiliated with, endorsed by, sponsored by, or in any way officially connected to Laravel, Laravel LLC, Taylor Otwell, or the Laravel framework maintainers. Laravel is a trademark of Taylor Otwell. All other trademarks belong to their respective owners.

This site is operated by the makers of Lockhound. Links to Lockhound are promotional.