Insufficient Type Distinction Affecting livewire/livewire package, versions <3.5.2


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team

    Threat Intelligence

    EPSS
    0.05% (17th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-PHP-LIVEWIRELIVEWIRE-8171408
  • published 9 Oct 2024
  • disclosed 8 Oct 2024
  • credit Jeremy Angele

How to fix?

Upgrade livewire/livewire to version 3.5.2 or higher.

Overview

livewire/livewire is an A front-end framework for Laravel.

Affected versions of this package are vulnerable to Insufficient Type Distinction when validating uploaded files in the generateHashNameWithOriginalNameEmbedded() function. An attacker can execute code by uploading a file with a valid MIME type such as image/png which actually contains executable code and has an executable file extension like .php.

Note: This is only exploitable if the following conditions are met, illustrated in the snippet below:

  1. The affected application applies $file->getClientOriginalName() to filenames.

  2. Files are stored in a publicly accessible directory on the affected server.

  3. The affected server is configured to execute uploaded files.

class SomeComponent extends Component
{
    use WithFileUploads;

#[Validate(&#39;image|extensions:png&#39;)]
public $file;

public function save()
{
    $this-&gt;validate();

    $this-&gt;file-&gt;storeAs(
        path: &#39;images&#39;,
        name: $this-&gt;file-&gt;getClientOriginalName(),
        options: [&#39;disk&#39; =&gt; &#39;public&#39;],
    );
}

}

References

CVSS Scores

version 4.0
version 3.1
Expand this section

Snyk

Recommended
7.7 high
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    Low
  • Attack Requirements (AT)
    Present
  • Privileges Required (PR)
    Low
  • User Interaction (UI)
    None
  • Confidentiality (VC)
    High
  • Integrity (VI)
    High
  • Availability (VA)
    High
  • Confidentiality (SC)
    None
  • Integrity (SI)
    None
  • Availability (SA)
    None