/

CVE-2026-84374

Severity:

HIGH RISK

(7.5)

Path Traversal (CWE-22) in Laravel Excel Disk Copy Method

CVE-2026-84374

Deferred

Vulnerability type

Category:

Path Traversal and Arbitrary File Overwrite

CWE:

CWE-22, CWE-73

Impact:

Arbitrary File Overwrite with Potential Remote Code Execution

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Laravel Excel contains a path handling vulnerability in its disk copy operation. When application-controlled export paths identify existing writable files, an attacker may overwrite those files with generated export content, potentially enabling remote code execution if an executable file is replaced.

Affected context

The issue may occur in Laravel Excel deployments where application input influences the destination passed to Excel export storage operations such as Excel::store(), $export->store(), or storeExcel(). Risk exists when the destination is resolved against the process working directory and an attacker-controlled path identifies an existing file writable by the application process, allowing the operation to bypass the configured filesystem disk's path confinement.

Exploit preconditions

  • Attack surface: Application functionality that accepts or derives an export destination from untrusted input
  • Required access: Ability to influence the export path, typically through an exposed application parameter or workflow
  • Trigger point: The Maatwebsite\Excel\Files\Disk::copy() operation while storing generated export content
  • Target condition: The resolved path must refer to an existing file that the application process can write
  • Why exploitation is possible: The destination is resolved using the process working directory rather than the configured filesystem disk, bypassing expected path confinement

Why this happens

The underlying bug is a mismatch between application-level path resolution and filesystem abstraction boundaries. The Disk::copy() method resolves a caller-controlled destination with realpath() and then opens the resulting file for read/write access, instead of consistently routing the destination through the configured disk's confinement and validation rules.

This behavior maps primarily to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because an external path can escape the intended storage location. It also relates to CWE-73: External Control of File Name or Path, because untrusted input influences the file selected for writing.

Potential impact

  • An attacker may overwrite existing writable files with export content.
  • Sensitive application files may be corrupted or replaced.
  • Non-truncating writes may leave trailing data in files when the replacement content is shorter.
  • An executable server-side script may be modified, which could lead to remote code execution.
  • Application integrity, availability, or generated-data trust may be affected.

General mitigation guidance

Mitigation generally focuses on treating export destinations as trusted server-side resources rather than accepting arbitrary paths from application input.

Common defensive patterns include:

  • Restricting export destinations to approved logical names or fixed directories.
  • Resolving and validating paths against an explicitly permitted storage root before writing.
  • Preserving filesystem-disk confinement and avoiding direct host-path resolution for user-influenced destinations.
  • Rejecting absolute paths, traversal segments, symbolic-link escapes, and unexpected path components.
  • Separating export output from executable and configuration directories.
  • Applying least-privilege filesystem permissions so the application cannot modify executable code or sensitive files.
  • Using dedicated temporary storage and controlled promotion workflows for generated exports.
  • Validating output names and enforcing secure-by-default storage policies at application boundaries.

How teams detect issues like this

Detection approaches may include:

  • Static analysis rules that flag realpath(), direct filesystem writes, or file-open operations receiving request-derived paths.
  • Code review checks for export APIs whose destination arguments originate from users, jobs, or externally controlled configuration.
  • Tests verifying that absolute paths, traversal sequences, symbolic links, and paths outside the configured disk are rejected.
  • Runtime monitoring for unexpected writes by the application process to source, configuration, upload, or executable directories.
  • Policy enforcement requiring export destinations to use allowlisted identifiers rather than raw filesystem paths.
  • Automated security review tools can help identify data-flow paths from external input to file-writing operations.

Sources

SourceLink
github.comgithub.com/SpartnerNL/Laravel-Excel/commit/b5cafdfcf7ec63924e83303763be8fcae340f70b
github.comgithub.com/SpartnerNL/Laravel-Excel/releases/tag/3.1.70
github.comgithub.com/SpartnerNL/Laravel-Excel/security/advisories/GHSA-c7r6-vx3h-w5g2

Frequently asked

questions

It may be remotely exploitable when a network-facing application allows untrusted users or tenants to influence the export destination. The vulnerability is not automatically reachable in every deployment; the relevant export workflow and input path must be exposed.

An attacker generally needs application-level access to a feature that accepts or derives a controllable export path. The selected target must also be an existing file writable by the application process.

Use server-controlled destination identifiers and enforce strict containment within an approved storage directory. Avoid passing raw user-controlled paths into file-writing or export-storage operations.

Apply allowlists for destination names, validate canonical paths and symbolic-link behavior, isolate generated files from executable content, and run the application with only the filesystem permissions it requires.

Find out what's already
exploitable in your codebase.