/

CVE-2022-51022

Severity:

CRITICAL RISK

(9.1)

Path Traversal (CWE-22) in YiShaAdmin File Download

CVE-2022-51022

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Read and File Deletion

Severity:

CRITICAL RISK

(9.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

YiShaAdmin contains an unauthenticated path traversal vulnerability in the File/DownloadFile endpoint, where the filePath parameter can reference locations outside the intended download directory. An attacker may read arbitrary files and, when deletion is enabled, remove files accessible to the application process.

YiShaAdmin contains an unauthenticated path traversal vulnerability in the File/DownloadFile endpoint, where the filePath parameter can reference locations outside the intended download directory. An attacker may read arbitrary files and, when deletion is enabled, remove files accessible to the application process.

Affected context

The issue occurs in YiShaAdmin deployments using the /admin/File/DownloadFile endpoint when user-controlled file paths are resolved without sufficient canonicalization and boundary checks. Risk is higher when the endpoint is reachable without authentication and the application process has access to sensitive system or application files.

The issue occurs in YiShaAdmin deployments using the /admin/File/DownloadFile endpoint when user-controlled file paths are resolved without sufficient canonicalization and boundary checks. Risk is higher when the endpoint is reachable without authentication and the application process has access to sensitive system or application files.

Exploit preconditions

  • Attack surface: The /admin/File/DownloadFile HTTP endpoint
  • Required access: Network access to the endpoint; authentication may not be required
  • Trigger point: Processing the filePath parameter during file download handling
  • Additional condition: The application must be able to access the targeted file
  • Deletion condition: File removal requires the deletion behavior to be enabled and the process to have delete permissions
  • Why exploitation is possible: User-supplied paths are accepted without reliably restricting resolution to the intended storage directory
  • Attack surface: The /admin/File/DownloadFile HTTP endpoint
  • Required access: Network access to the endpoint; authentication may not be required
  • Trigger point: Processing the filePath parameter during file download handling
  • Additional condition: The application must be able to access the targeted file
  • Deletion condition: File removal requires the deletion behavior to be enabled and the process to have delete permissions
  • Why exploitation is possible: User-supplied paths are accepted without reliably restricting resolution to the intended storage directory

Why this happens

The vulnerability results from improper limitation of a file path derived from HTTP input. When traversal sequences are accepted and the resulting path is not canonicalized and checked against an approved directory, the application may resolve references outside its intended file boundary.

This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'). The insecure pattern combines attacker-controlled path input with file read or deletion operations without enforcing a trusted storage root.

The vulnerability results from improper limitation of a file path derived from HTTP input. When traversal sequences are accepted and the resulting path is not canonicalized and checked against an approved directory, the application may resolve references outside its intended file boundary.

This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'). The insecure pattern combines attacker-controlled path input with file read or deletion operations without enforcing a trusted storage root.

Potential impact

  • An unauthenticated attacker may read sensitive system, configuration, or application files
  • The application may disclose credentials, tokens, or other secrets stored in accessible files
  • An attacker could remove files required for application availability or operation
  • Compromised files could support follow-on attacks or broader application compromise
  • Exposure of sensitive data could create privacy, compliance, or operational consequences
  • An unauthenticated attacker may read sensitive system, configuration, or application files
  • The application may disclose credentials, tokens, or other secrets stored in accessible files
  • An attacker could remove files required for application availability or operation
  • Compromised files could support follow-on attacks or broader application compromise
  • Exposure of sensitive data could create privacy, compliance, or operational consequences

General mitigation guidance

Mitigation generally focuses on treating file path parameters as untrusted references rather than filesystem locations.

Common defensive patterns include:

  • Resolve requested paths against a fixed, trusted storage directory and verify that the canonical result remains within that directory
  • Prefer opaque file identifiers or server-managed filenames instead of accepting filesystem paths
  • Reject traversal markers, absolute paths, symbolic-link escapes, and unexpected path formats as defense-in-depth
  • Separate download and deletion capabilities, requiring explicit authorization for destructive operations
  • Apply least-privilege filesystem permissions to the application process and isolate downloadable content
  • Disable unauthenticated access where it is not required and enforce authorization at the endpoint
  • Use read-only storage or controlled deletion services where possible

Mitigation generally focuses on treating file path parameters as untrusted references rather than filesystem locations.

Common defensive patterns include:

  • Resolve requested paths against a fixed, trusted storage directory and verify that the canonical result remains within that directory
  • Prefer opaque file identifiers or server-managed filenames instead of accepting filesystem paths
  • Reject traversal markers, absolute paths, symbolic-link escapes, and unexpected path formats as defense-in-depth
  • Separate download and deletion capabilities, requiring explicit authorization for destructive operations
  • Apply least-privilege filesystem permissions to the application process and isolate downloadable content
  • Disable unauthenticated access where it is not required and enforce authorization at the endpoint
  • Use read-only storage or controlled deletion services where possible

How teams detect issues like this

Organizations can detect related weaknesses through:

  • Static analysis rules that flag filesystem operations using request parameters
  • Code review checks for path joining without canonicalization and directory-boundary validation
  • Tests covering encoded, normalized, absolute, traversal, and symbolic-link path variants
  • Runtime monitoring for unusual file access or deletion requests involving system and configuration directories
  • Web application firewall or gateway policies that identify suspicious path patterns as a supplementary control
  • Automated security review tools that correlate file operations with unauthenticated routes

Organizations can detect related weaknesses through:

  • Static analysis rules that flag filesystem operations using request parameters
  • Code review checks for path joining without canonicalization and directory-boundary validation
  • Tests covering encoded, normalized, absolute, traversal, and symbolic-link path variants
  • Runtime monitoring for unusual file access or deletion requests involving system and configuration directories
  • Web application firewall or gateway policies that identify suspicious path patterns as a supplementary control
  • Automated security review tools that correlate file operations with unauthenticated routes

Sources

SourceLink
github.comgithub.com/liukuo362573/YiShaAdmin/commit/025b0628b1295bd2d9fd6c9b5b82692a345151ef
github.comgithub.com/liukuo362573/YiShaAdmin/commit/c3b66e66bf6d70a561190cd8da7f4df7b141931d
github.comgithub.com/projectdiscovery/nuclei-templates/blob/main/http/vulnerabilities/other/yishaadmin-lfi.yaml
huntr.comhuntr.com/bounties/2acdd87a-12bd-4ce4-994b-0081eb908128
vulncheck.comvulncheck.com/advisories/yishaadmin-3.1-unauthenticated-path-traversal-via-downloadfile-endpoint

Frequently asked

questions

It can be remotely exploitable when the affected endpoint is network-accessible and accepts requests without authentication. The attacker still depends on the application process having access to the targeted files.

Access to the endpoint may be sufficient if authentication is not enforced. The ability to read or delete a file also depends on the permissions granted to the YiShaAdmin process.

Avoid accepting raw filesystem paths from clients. Use server-side file identifiers, resolve files within a fixed storage root, and verify canonical path boundaries before any read or deletion operation.

Apply authorization to file operations, enforce least-privilege filesystem permissions, test path normalization edge cases, and monitor unexpected file access or deletion activity.

It can be remotely exploitable when the affected endpoint is network-accessible and accepts requests without authentication. The attacker still depends on the application process having access to the targeted files.

Access to the endpoint may be sufficient if authentication is not enforced. The ability to read or delete a file also depends on the permissions granted to the YiShaAdmin process.

Avoid accepting raw filesystem paths from clients. Use server-side file identifiers, resolve files within a fixed storage root, and verify canonical path boundaries before any read or deletion operation.

Apply authorization to file operations, enforce least-privilege filesystem permissions, test path normalization edge cases, and monitor unexpected file access or deletion activity.

Find out what's already
exploitable in your codebase.