CVE-2026-33686: Code16/sharp Path Traversal Vulnerability

HIGH
Advisory Identifier: GHSA-9ffq-6457-8958
CVSS 8.8
CWE-22
Published
Advisory Summary

CVE-2026-33686 is a HIGH (CVSS 8.8) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Code16/sharp libraries in the Packagist ecosystem. The issue involves sharp is vulnerable to path traversal via unsanitized extension in fileutil. Remediation is available by upgrading affected packages to version 9.20.0.

CVE-2026-33686 at a Glance

CVE Identifier CVE-2026-33686
GHSA Identifier GHSA-9ffq-6457-8958
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Code16/sharp
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 8.8

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

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

How to Fix CVE-2026-33686

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

code16/sharp fixed: 9.20.0
Upgrade code16/sharp to 9.20.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 code16/sharp

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-33686, inspect your project dependencies for Code16/sharp:

inspect dependencies for code16/sharp

Analyze the terminal output to locate any version of Code16/sharp in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 9.20.0), 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-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Code16/sharp, 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

### Summary A path traversal vulnerability exists in the FileUtil class of the code16/sharp package. The application fails to sanitize file extensions properly, allowing path separators to be passed into the storage layer. ### Detail In `src/Utils/FileUtil.php`, the `FileUtil::explodeExtension()` function extracts a file's extension by splitting the filename at the last dot. However, the extracted extension is never sanitized. While the application uses a `normalizeName()` function, this function only cleans the base filename, meaning any path separators (such as /) injected into the extension will survive and be passed into the `storeAs()` function. ### Impact Exploiting this flaw allows an authenticated attacker to manipulate file paths: - Files can be written outside of the intended tmp directory via path traversal. For more details on the package, visit: https://github.com/code16/sharp - Existing critical files (such as .env or configuration files) could potentially be overwritten. Review the CWE definition here: https://cwe.mitre.org/data/definitions/22.html (Note: This vulnerability was successfully chained with CWE-434 in a local Proof of Concept to confirm the traversal.) ### Patches This issue has been patched by properly sanitizing the extension using `pathinfo(PATHINFO_EXTENSION)` instead of `strrpos()`, alongside applying strict regex replacements to both the base name and the extension. The fix is available in pull request #715 ### Credits Reported by [zaurgsynv](https://github.com/zaurgsynv).

CVE-2026-33686 Affected Code16/sharp Versions

1 component(s)
Fixed Versions:
9.20.0
Product / Package Ecosystem Affected Versions Fixed Version
code16/sharp
Packagist
< 9.20.0
9.20.0

References

Frequently Asked Questions

What is CVE-2026-33686?
CVE-2026-33686 is a security vulnerability in Code16/sharp involving Sharp is Vulnerable to Path Traversal via Unsanitized Extension in FileUtil under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Code16/sharp versions are affected?
Affected versions include releases prior to 9.20.0 across affected packages: code16/sharp.
What version fixes CVE-2026-33686?
Upgrading to 9.20.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is code16/sharp affected?
Yes, code16/sharp is affected in releases prior to 9.20.0. Upgrade your dependency to 9.20.0 or later.
What is the CVSS score of CVE-2026-33686?
CVE-2026-33686 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-33686?
CVE-2026-33686 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check Packagist dependencies for CVE-2026-33686?
Run the dependency tree command: 'inspect dependencies for code16/sharp'. 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-9ffq-6457-8958",
  "modified" : "2026-03-27T21:36:04Z",
  "published" : "2026-03-25T20:01:04Z",
  "aliases" : [ "CVE-2026-33686" ],
  "summary" : "Sharp is Vulnerable to Path Traversal via Unsanitized Extension in FileUtil",
  "details" : "### Summary\nA path traversal vulnerability exists in the FileUtil class of the code16/sharp package. The application fails to sanitize file extensions properly, allowing path separators to be passed into the storage layer.\n\n### Detail\nIn `src/Utils/FileUtil.php`, the `FileUtil::explodeExtension()` function extracts a file's extension by splitting the filename at the last dot. However, the extracted extension is never sanitized. While the application uses a `normalizeName()` function, this function only cleans the base filename, meaning any path separators (such as /) injected into the extension will survive and be passed into the `storeAs()` function.\n\n### Impact\nExploiting this flaw allows an authenticated attacker to manipulate file paths:\n- Files can be written outside of the intended tmp directory via path traversal. For more details on the package, visit: https://github.com/code16/sharp\n- Existing critical files (such as .env or configuration files) could potentially be overwritten. Review the CWE definition here: https://cwe.mitre.org/data/definitions/22.html (Note: This vulnerability was successfully chained with CWE-434 in a local Proof of Concept to confirm the traversal.)\n\n### Patches\nThis issue has been patched by properly sanitizing the extension using `pathinfo(PATHINFO_EXTENSION)` instead of `strrpos()`, alongside applying strict regex replacements to both the base name and the extension. The fix is available in pull request #715\n\n### Credits\nReported by [zaurgsynv](https://github.com/zaurgsynv).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "code16/sharp"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "9.20.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/code16/sharp/security/advisories/GHSA-9ffq-6457-8958"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-33686"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/code16/sharp/pull/715"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/code16/sharp"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-25T20:01:04Z",
    "nvd_published_at" : "2026-03-26T22:16:31Z"
  }
}