/

CVE-2025-66292

Severity:

HIGH RISK

(8.1)

Path Traversal / Arbitrary File System Access

CVE-2025-66292

Analyzed

Vulnerability type

Category:

Path Traversal / Arbitrary File System Access

CWE:

CWE-22, CWE-73

Impact:

Arbitrary File Deletion and Potential Denial of Service

Severity:

HIGH RISK

(8.1)

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

DPanel's /api/common/attach/delete API endpoint contains a path traversal flaw that allows authenticated users to delete arbitrary files on the server filesystem.

Because user-controlled paths are joined and passed directly to os.Remove without enforcing a jail or validating traversal sequences, an attacker can escape the intended storage directory and remove sensitive or critical system files.

Affected context

This vulnerability affects DPanel deployments where:

  • The /api/common/attach/delete endpoint is exposed to authenticated users (especially admin backends),
  • File deletion requests accept a user-supplied path parameter,
  • The backend uses storage.Local{}.GetSaveRealPath in combination with filepath.Join, but does not enforce a chroot/jail or perform strict path validation.

In such environments, any authenticated user with access to this endpoint may be able to target files beyond the expected upload or attachment directory.

Exploit preconditions

  • Attack surface: HTTP(S) API endpoint /api/common/attach/delete.
  • Required access: Valid authenticated session with permissions to reach the administrative backend or the attach-delete API.
  • Input control: Ability to supply crafted path values (including traversal sequences) to the path parameter.
  • Trigger point: Invocation of the Delete function in app/common/http/controller/attach.go, which:
  • Forwards the user-supplied path to storage.Local{}.GetSaveRealPath (in common/service/storage/local.go),
  • Uses filepath.Join to construct the file path,
  • Passes the resulting path directly to os.Remove without ensuring it remains inside a restricted directory.
  • Why exploitation is possible: filepath.Join normalizes .. segments but does not impose a directory boundary. Without explicit checks to keep the final path under an allowed base directory, the code effectively trusts user-controlled paths for filesystem deletion.

Why this happens

The underlying issue is improper neutralization and validation of user-supplied file paths before performing filesystem operations.

Specifically:

  • The application takes a path parameter from an authenticated HTTP request and forwards it through storage.Local{}.GetSaveRealPath into os.Remove.
  • While filepath.Join resolves relative segments, it does not prevent traversal outside the intended storage root.
  • No explicit enforcement of a chroot-like boundary (e.g., verifying that the final path still resides under the configured base directory) is performed.

This maps to:

  • CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') — user input is used to construct paths without properly confining the result.
  • CWE-73: External Control of File Name or Path — file deletion behavior is driven by externally controlled path data.

The insecure pattern is "trusting user-controlled path components in destructive file operations, with only syntactic joining but no semantic directory boundary enforcement."

Potential impact

  • Deletion of arbitrary application files, including configuration or uploaded assets.
  • Removal of log files, hindering incident investigations and monitoring.
  • Deletion of security-related files (e.g., keys, certificates) stored on accessible paths.
  • Partial or total application outage if essential binaries, libraries, or configuration files are removed.
  • Potential impact on co-hosted services if shared paths or misconfigurations expose additional directories.

General mitigation guidance

Effective mitigation focuses on constraining filesystem operations to well-defined, trusted directories and treating all path input as untrusted:

  • Enforce directory boundaries: After computing a resolved path, verify that it remains under a configured base directory (e.g., by resolving to an absolute path and checking it has the expected prefix).
  • Canonicalization plus validation: Normalize paths (resolving . and ..) and reject any input that attempts to escape the designated storage root.
  • Whitelist-based paths: Prefer referencing files by internal identifiers or database records rather than raw user-supplied paths.
  • Limit available operations: Ensure deletion APIs only operate on files that the application itself created in specific, known directories.
  • Least-privilege filesystem permissions: Run the service under an account with minimal filesystem privileges so that even if a path traversal occurs, the scope of deletable files is limited.
  • Segregated storage: Store user-managed content in separate directories or volumes from application code and critical system files to reduce blast radius.

How teams detect issues like this

Organizations can detect and monitor for this class of vulnerability through:

  • Static analysis patterns:
  • Flagging use of os.Remove, os.RemoveAll, or similar file operations where the target path is derived from HTTP parameters or other untrusted input.
  • Identifying path-building functions that combine user-controlled data with base directories without subsequent boundary checks.
  • Code review signals:
  • Controllers or handlers that accept path, file, or filename parameters and pass them into storage layers without robust validation.
  • Reliance on filepath.Join alone as a security boundary mechanism.
  • Absence of checks to ensure resolved paths remain inside an allowed root directory.
  • Policy enforcement:
  • Secure coding guidelines requiring canonicalization + root validation for all file operations involving user input.
  • CI-integrated linters or SAST tools configured with custom rules for path traversal and externalized file path control.
  • Runtime monitoring:
  • Logging and alerting on deletion of unexpected files, especially outside designated upload directories.
  • Host-based intrusion detection systems (HIDS) monitoring sensitive directories for anomalous deletions initiated by the application process.

Sources

SourceLink
github.comgithub.com/donknap/dpanel/commit/cbda0d90204e8212f2010774345c952e42069119
github.comgithub.com/donknap/dpanel/releases/tag/v1.9.2
github.comgithub.com/donknap/dpanel/security/advisories/GHSA-vh2x-fw87-4fxq

Frequently asked

questions

Yes, but it requires authentication. Any attacker who can obtain valid credentials and reach the /api/common/attach/delete endpoint can attempt to exploit the path traversal behavior over the network.

The attacker must be an authenticated user with permission to use the administrative backend or the relevant attachment deletion API. The exact required role depends on how the instance is configured, but it does not require shell or OS-level access.

The most robust pattern is to treat all incoming paths as untrusted, resolve them to absolute paths under a defined base directory, and enforce that the final path remains within that directory before performing any filesystem operation. Additionally, use opaque identifiers instead of raw paths in APIs where possible.

Establish a standard file-access abstraction that:

  • Accepts only logical identifiers from higher layers,
  • Performs path canonicalization and boundary checks centrally,
  • Exposes only safe operations on pre-approved directories.

Combine this with secure coding guidelines, automated static analysis for file path usage, and security-focused code reviews for any feature that interacts with the filesystem.

Find out what's already
exploitable in your codebase.