GHSA-c7r6-vx3h-w5g2

Suggest an improvement
Source
https://github.com/advisories/GHSA-c7r6-vx3h-w5g2
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-c7r6-vx3h-w5g2/GHSA-c7r6-vx3h-w5g2.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-c7r6-vx3h-w5g2
Aliases
Published
2026-09-08T20:40:47Z
Modified
2026-09-08T20:45:04Z
Severity
  • 7.5 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H CVSS Calculator
Summary
Laravel Excel writes exports outside the configured filesystem disk when given a caller-controlled path
Details

Summary

Excel::store() resolved the destination path against the process working directory rather than the configured filesystem disk. When that path resolved to an existing file, the export was written straight to it with fopen(), bypassing the disk entirely. An application that passes a user-controlled value as the export path could therefore be made to overwrite an arbitrary existing file that the PHP process can write to, with content the user controls.

Details

Maatwebsite\Excel\Files\Disk::copy() contained two paths:

if (realpath($destination)) {
    $tempStream = fopen($destination, 'rb+');
    $success    = stream_copy_to_stream($readStream, $tempStream) !== false;
} else {
    $success = $this->put($destination, $readStream);
}

$destination is the $filePath argument given to Excel::store(), $export->store() or ->storeExcel(). realpath() resolves it against the current working directorypublic/ for a typical web request — not against the disk root. On a hit, the write went directly to the filesystem and never reached Flysystem, which would otherwise have rejected ../ traversal and confined absolute paths to the disk root. The disk argument was effectively ignored for those paths, including for remote disks such as S3.

Two consequences follow:

  • the destination could be any existing file the PHP process can write, in or out of the disk root;
  • the stream was opened 'rb+', which does not truncate, so a shorter export left trailing bytes of the previous file behind.

Because the file must already exist, the primitive is an overwrite rather than an arbitrary file creation. Overwriting a PHP file that is reachable by the web server (for example a front controller or a cached view) turns attacker-controlled row content into code execution, since CSV and HTML writers emit cell values verbatim. Passing an explicit writer type to store() bypasses the extension-based type detection that would otherwise reject a .php target.

Exploitation requires the application to pass an unsanitized, user-controlled value as the export path. Applications that pass a fixed or server-derived path are not affected.

Impact

Arbitrary overwrite of existing files writable by the PHP process, with partially attacker-controlled content, leading to remote code execution where the overwritten file is executed by the web server.

Patches

Fixed in 3.1.70. Disk::copy() now always writes through the configured filesystem disk, so Flysystem enforces the disk root for every export.

Note the behaviour change: passing an absolute path to store() previously wrote to that path once the file existed. Paths now always resolve relative to the disk root. Applications that relied on that should configure a disk rooted at the target location.

Workarounds

For anyone unable to upgrade, validate the path before passing it to store() — reject absolute paths and any .. segment, or derive the filename server-side and never build it from request input:

$name = basename($request->input('filename'));   // strips any directory part
Excel::store($export, 'exports/' . $name, 'local');

Credit

Reported responsibly by @seck19 via the contact address in SECURITY.md.

Database specific
{
    "cwe_ids":  [
        "CWE-22",
        "CWE-73"
    ],
    "github_reviewed":  true,
    "github_reviewed_at":  "2026-09-08T20:40:47Z",
    "nvd_published_at":  "2026-09-01T22:17:19Z",
    "severity":  "HIGH"
}
References

Affected packages

Packagist / maatwebsite/excel

Package

Name
maatwebsite/excel
Purl
pkg:composer/maatwebsite/excel

Affected ranges

Type
ECOSYSTEM
Events
Introduced
3.1.8
Fixed
3.1.70

Affected versions

3.*
3.1.8
3.1.9
3.1.10
3.1.11
3.1.12
3.1.13
3.1.14
3.1.15
3.1.16
3.1.17
3.1.18
3.1.19
3.1.20
3.1.21
3.1.22
3.1.23
3.1.24
3.1.25
3.1.26
3.1.27
3.1.28
3.1.29
3.1.30
3.1.31
3.1.32
3.1.33
3.1.34
3.1.35
3.1.36
3.1.37
3.1.38
3.1.39
3.1.40
3.1.41
3.1.42
3.1.43
3.1.44
3.1.45
3.1.46
3.1.47
3.1.48
3.1.49
3.1.50
3.1.51
3.1.52
3.1.53
3.1.54
3.1.55
3.1.56
3.1.57
3.1.58
3.1.59
3.1.60
3.1.61
3.1.62
3.1.63
3.1.64
3.1.65
3.1.66
3.1.67
3.1.68
3.1.69

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-c7r6-vx3h-w5g2/GHSA-c7r6-vx3h-w5g2.json"