/

CVE-2026-33686

Severity:

HIGH RISK

(8.8)

Path Traversal in Sharp Laravel CMS FileUtil

CVE-2026-33686

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File System Access within Application Context

Severity:

HIGH RISK

(8.8)

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

Sharp, a Laravel-based content management framework, contains a path traversal vulnerability in its FileUtil class prior to version 9.20.0, caused by improper handling of file extensions.

By injecting path separators into crafted filenames, an attacker may influence how paths are constructed in the storage layer, potentially accessing or manipulating files outside the intended directory scope when user-supplied filenames are processed.

Affected context

This vulnerability affects Sharp installations that use the FileUtil utility for handling user-supplied filenames, such as uploaded files or dynamically generated paths.

It is relevant where:

  • Filenames or file extensions can be influenced by an external party (e.g., end users, integrations, or other services).
  • These filenames are later combined with storage paths or used to determine file locations.
  • Additional path validation or normalization is not performed after FileUtil processing.

Under these conditions, crafted filenames containing path separators in the "extension" portion may influence file resolution beyond the intended directory.

Exploit preconditions

  • Attack surface: Any feature that accepts or constructs filenames using FileUtil (e.g., upload endpoints, file management interfaces, or import/export features).
  • Required access: Ability to submit or control filenames or file-related parameters processed by Sharp (usually authenticated or unauthenticated web access, depending on application configuration).
  • Trigger point: Invocation of FileUtil::explodeExtension() and subsequent use of its output to build file paths, store files, or route file operations.
  • Why exploitation is possible: The implementation splits on the last dot using strrpos() and does not sanitize the resulting extension; this allows path separators to remain in the "extension" and be passed into the storage layer, enabling traversal when those values are later concatenated into paths.

Why this happens

The core issue is improper neutralization of special elements used in pathname construction, aligning with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').

The vulnerable FileUtil::explodeExtension() function determines the file extension using simple string operations (strrpos() and substring extraction), which treat everything after the last dot as the extension without validating its content.

Because the extension is not normalized or constrained to a safe character set, attackers can embed path separators (e.g., slashes or directory traversal sequences) into the "extension" portion of the filename.

When downstream code combines the base name and extension into a file path for reading, writing, or storing files, these crafted components can alter the effective path, bypassing directory restrictions and causing path traversal within the storage layer.

Potential impact

  • Access to files outside the intended upload or storage directories, dependent on application logic and permissions.
  • Overwriting of existing files within the application's writable directories if file names collide and are not protected.
  • Circumvention of file-type or extension-based validation and storage rules.
  • Assistance in chaining with other vulnerabilities (e.g., if uploads can reach executable locations in certain environments).

General mitigation guidance

Effective mitigation focuses on enforcing strict normalization and validation of filenames and extensions before they influence filesystem paths:

  • Use robust path handling APIs (such as pathinfo() for extension extraction) instead of ad-hoc string parsing like strrpos().
  • Constrain both the base name and extension to a conservative character set via strict regular expressions, rejecting or normalizing characters such as slashes, backslashes, and traversal sequences.
  • Resolve target paths against a predefined, application-controlled root directory and reject paths that escape this root after normalization.
  • Apply defense-in-depth by separating upload directories from executable code, using non-public storage locations and least-privilege filesystem permissions.
  • Centralize file path construction in hardened utility functions rather than scattering string concatenation throughout the codebase.

How teams detect issues like this

Teams can identify and monitor for this class of issue using a combination of static and review-based approaches:

  • Static analysis rules that flag manual path construction (e.g., concatenation with / or \) and custom filename parsing when user input is involved.
  • Pattern-based checks for extension handling that relies on strrpos(), substr(), or similar string methods instead of path-aware functions like pathinfo().
  • Code review guidelines that require explicit validation and normalization of filenames and extensions, with attention to directory traversal patterns (../, ..\\) and path separator characters.
  • Integration of automated code scanning tools into CI pipelines to detect unsafe path manipulation, backed by security-focused unit tests that exercise edge-case filenames.

Sources

SourceLink
github.comgithub.com/code16/sharp/pull/715
github.comgithub.com/code16/sharp/security/advisories/GHSA-9ffq-6457-8958

Frequently asked

questions

Yes, if the application exposes endpoints or features where remote users can influence filenames or extensions that are processed by FileUtil. The exact scope depends on how those filenames are later used to construct paths.

Not necessarily. If public-facing features (such as anonymous uploads or file-based interactions) use FileUtil with user-controlled filenames, exploitation could be unauthenticated. Where such features are behind login, the attacker would need at least the level of access required to reach those endpoints.

Replace ad-hoc string parsing of filenames with path-aware APIs for extension and basename extraction, and apply strict whitelist-based validation to both components. Additionally, normalize and resolve all constructed paths against a fixed root directory and reject any path that attempts to escape it.

Establish secure coding standards for file handling: avoid concatenating raw user input into filesystem paths, mandate centralized helpers for path construction and validation, enforce automated checks for path traversal patterns, and incorporate security reviews for any feature that reads or writes files based on external input.

Find out what's already
exploitable in your codebase.