CVE-2021-43808: Laravel/framework Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-66hf-2p6w-jqfw
CVSS 6.1
CWE-327 CWE-79
Published
Advisory Summary

CVE-2021-43808 is a MODERATE (CVSS 6.1) cross-site scripting vulnerability (CWE-327: Use of a Broken or Risky Cryptographic Algorithm) affecting Laravel/framework libraries in the Packagist ecosystem. The issue involves laravel framework xss in blade templating engine. Remediation is available by upgrading affected packages to version 6.20.42, 7.30.6, 8.75.0.

CVE-2021-43808 at a Glance

CVE Identifier CVE-2021-43808
GHSA Identifier GHSA-66hf-2p6w-jqfw
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-327: Use of a Broken or Risky Cryptographic Algorithm
Affected Product Laravel/framework
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 6.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2021-43808

To remediate this vulnerability, upgrade all affected Laravel/framework dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

laravel/framework fixed: 6.20.42
Upgrade laravel/framework to 6.20.42
laravel/framework fixed: 7.30.6
Upgrade laravel/framework to 7.30.6
laravel/framework fixed: 8.75.0
Upgrade laravel/framework to 8.75.0
illuminate/view fixed: 6.20.42
Upgrade illuminate/view to 6.20.42
illuminate/view fixed: 7.30.6
Upgrade illuminate/view to 7.30.6
illuminate/view fixed: 8.75.0
Upgrade illuminate/view to 8.75.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for laravel/framework

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-43808, inspect your project dependencies for Laravel/framework:

inspect dependencies for laravel/framework

Analyze the terminal output to locate any version of Laravel/framework in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 6.20.42), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-327: Use of a Broken or Risky Cryptographic Algorithm, where the product uses a broken or risky cryptographic algorithm or protocol. In Laravel/framework, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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') <input value="{{ $value }}"> @show ``` resources/views/child.blade.php: ```html @extends('parent') @section('content') <input value="{{ $value }}"> @endsection ``` And a route like the following: ```php 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.

CVE-2021-43808 Affected Laravel/framework Versions

6 component(s)
Fixed Versions:
6.20.427.30.68.75.0
Product / Package Ecosystem Affected Versions Fixed Version
laravel/framework
Packagist
< 6.20.42
6.20.42
laravel/framework
Packagist
≥ 7.0.0
< 7.30.6
7.30.6
laravel/framework
Packagist
≥ 8.0.0
< 8.75.0
8.75.0
illuminate/view
Packagist
< 6.20.42
6.20.42
illuminate/view
Packagist
≥ 7.0.0
< 7.30.6
7.30.6
illuminate/view
Packagist
≥ 8.0.0
< 8.75.0
8.75.0

References

Frequently Asked Questions

What is CVE-2021-43808?
CVE-2021-43808 is a security vulnerability in Laravel/framework involving Laravel Framework XSS in Blade templating engine under CWE-327: Use of a Broken or Risky Cryptographic Algorithm.
Which Laravel/framework versions are affected?
Affected versions include releases prior to 6.20.42, 7.30.6, 8.75.0 across affected packages: laravel/framework, illuminate/view.
What version fixes CVE-2021-43808?
Upgrading to 6.20.42, 7.30.6, 8.75.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is laravel/framework affected?
Yes, laravel/framework is affected in releases prior to 6.20.42, 7.30.6, 8.75.0. Upgrade your dependency to 6.20.42, 7.30.6, 8.75.0 or later.
Is illuminate/view affected?
Yes, illuminate/view is affected in releases prior to 6.20.42, 7.30.6, 8.75.0. Upgrade your dependency to 6.20.42, 7.30.6, 8.75.0 or later.
What is the CVSS score of CVE-2021-43808?
CVE-2021-43808 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2021-43808?
CVE-2021-43808 is classified under CWE-327: Use of a Broken or Risky Cryptographic Algorithm (The product uses a broken or risky cryptographic algorithm or protocol.).
How can I check Packagist dependencies for CVE-2021-43808?
Run the dependency tree command: 'inspect dependencies for laravel/framework'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-66hf-2p6w-jqfw",
  "modified" : "2022-08-11T19:19:57Z",
  "published" : "2021-12-08T19:57:36Z",
  "aliases" : [ "CVE-2021-43808" ],
  "summary" : "Laravel Framework XSS in Blade templating engine",
  "details" : "A security researcher has disclosed a possible XSS vulnerability in the Blade templating engine.\n\nGiven the following two Blade templates:\n\nresources/views/parent.blade.php:\n\n```html\n@section('content')\n<input value=\"{{ $value }}\">\n@show\n```\n\nresources/views/child.blade.php:\n\n```html\n@extends('parent')\n\n@section('content')\n<input value=\"{{ $value }}\">\n@endsection\n```\n\nAnd a route like the following:\n\n```php\nRoute::get('/example', function() {\n    $value = '//localhost/###parent-placeholder-040f06fd774092478d450774f5ba30c5da78acc8## onclick=location.assign(this.value);//';\n\n    return view('child', ['value' => $value]);\n});\n```\n\nThe 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.\n\nThis vulnerability has been patched by determining the parent placeholder at runtime and using a random hash that is unique to each request.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "laravel/framework"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "6.20.42"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "laravel/framework"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "7.0.0"
      }, {
        "fixed" : "7.30.6"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "laravel/framework"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "8.75.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "illuminate/view"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "6.20.42"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "illuminate/view"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "7.0.0"
      }, {
        "fixed" : "7.30.6"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "illuminate/view"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "8.75.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/laravel/framework/security/advisories/GHSA-66hf-2p6w-jqfw"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-43808"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/laravel/framework/pull/39906"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/laravel/framework/pull/39908"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/laravel/framework/pull/39909"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/laravel/framework/commit/b8174169b1807f36de1837751599e2828ceddb9b"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/illuminate/view/CVE-2021-43808.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/laravel/framework/CVE-2021-43808.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/laravel/framework"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/laravel/framework/releases/tag/v6.20.42"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/laravel/framework/releases/tag/v7.30.6"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/laravel/framework/releases/tag/v8.75.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-327", "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-12-07T21:33:14Z",
    "nvd_published_at" : "2021-12-08T00:15:00Z"
  }
}