Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2022-51022 Overview
CVE-2022-51022 is an unauthenticated path traversal vulnerability [CWE-22] in YiShaAdmin versions 2.2 through 3.1. The flaw resides in the /admin/File/DownloadFile endpoint, which accepts a filePath parameter without proper sanitization. Attackers can submit crafted GET requests containing directory traversal sequences to read arbitrary files on the host. The endpoint also accepts a delete parameter, enabling attackers to remove files after reading them. The Shadowserver Foundation first observed exploitation evidence on 2023-10-20. The issue is fixed in commit 025b062.
Critical Impact
Unauthenticated remote attackers can read and delete arbitrary files, including sensitive system files such as /etc/passwd, leading to information disclosure and integrity loss.
Affected Products
- YiShaAdmin 2.2
- YiShaAdmin 3.0
- YiShaAdmin 3.1 (fixed in commit 025b062)
Discovery Timeline
- 2026-10-22 - CVE CVE-2022-51022 published to NVD
- 2026-10-22 - Last updated in NVD database
Technical Details for CVE-2022-51022
Vulnerability Analysis
The vulnerability exists in the DownloadFile method within YiSha.Util/FileHelper.cs. The endpoint /admin/File/DownloadFile takes a user-controlled filePath parameter and concatenates it with the application's ContentRootPath to construct an absolute file path. The server then reads the file with File.ReadAllBytes and returns its contents to the caller.
Because the endpoint does not require authentication and does not restrict access to a safe directory, any remote attacker can traverse outside the web root. Supplying delete=1 in the request causes the server to call File.Delete on the resolved path, extending the impact from information disclosure to file destruction.
Root Cause
The FilterFilePath helper only removed ../ substrings and did not handle variants such as .. without a trailing separator or encoded traversal payloads. The download handler also lacked a directory allowlist, so any path resolvable by the host operating system could be reached. Both deficiencies combined enable arbitrary file read and delete operations with the privileges of the YiShaAdmin process.
Attack Vector
Exploitation requires a single unauthenticated HTTP GET request to the DownloadFile endpoint with a traversal payload in filePath. Setting delete=1 triggers deletion after read. Public detection content exists in the Nuclei Template for LFI, and additional context is published in the VulnCheck Advisory for Path Traversal.
public static string FilterFilePath(string filePath)
{
filePath = filePath.Replace("../", string.Empty);
+ filePath = filePath.Replace("..", string.Empty);
filePath = filePath.TrimStart('/');
return filePath;
}
Source: GitHub Commit Update
Detection Methods for CVE-2022-51022
Indicators of Compromise
- HTTP GET requests to /admin/File/DownloadFile containing .., ../, URL-encoded %2e%2e, or absolute paths in the filePath query parameter.
- Requests to the same endpoint with delete=1, indicating an attempted file deletion.
- Unexpected read or deletion of sensitive files such as /etc/passwd, web.config, or appsettings.json on hosts running YiShaAdmin.
Detection Strategies
- Deploy the Nuclei Template for LFI against YiShaAdmin instances to identify unpatched deployments.
- Create web application firewall (WAF) rules that block traversal sequences in requests targeting /admin/File/DownloadFile.
- Correlate access logs for anonymous requests to the download endpoint with subsequent file system changes on the host.
Monitoring Recommendations
- Enable verbose HTTP access logging on the YiShaAdmin host and forward logs to a central analytics platform.
- Alert on file deletion events in application directories, especially outside wwwroot and Resource.
- Track outbound responses from the application that contain OS configuration files or credential material.
How to Mitigate CVE-2022-51022
Immediate Actions Required
- Upgrade YiShaAdmin to a build that includes commit 025b062 or later.
- Restrict network exposure of the /admin/File/ routes to trusted administrative networks until patched.
- Audit the host for missing or modified files that may indicate exploitation.
Patch Information
The maintainers addressed the issue in two commits. The first strengthens the sanitization helper, and the second restricts downloads to the wwwroot and Resource directories. Review the GitHub Commit Update and the GitHub Commit Fix for the full diff. The researcher report is available on Huntr Security Bounty.
public static TData<FileContentResult> DownloadFile(string filePath, int delete)
{
+ filePath = filePath.Replace("../", string.Empty);
+ filePath = filePath.TrimStart('/');
+ if (!filePath.StartsWith("wwwroot") && !filePath.StartsWith("Resource"))
+ {
+ throw new Exception("非法访问");
+ }
TData<FileContentResult> obj = new TData<FileContentResult>();
string absoluteFilePath = GlobalContext.HostingEnvironment.ContentRootPath + Path.DirectorySeparatorChar + filePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
byte[] fileBytes = File.ReadAllBytes(absoluteFilePath);
if (delete == 1)
{
File.Delete(absoluteFilePath);
}
Source: GitHub Commit Fix
Workarounds
- Place YiShaAdmin behind a reverse proxy that rejects requests to /admin/File/DownloadFile containing traversal characters or absolute paths.
- Run the application under a least-privilege service account that cannot read or delete OS-level sensitive files.
- Apply filesystem ACLs that deny the YiShaAdmin process access to directories outside its deployment root.
# Example NGINX rule to block traversal payloads to the vulnerable endpoint
location /admin/File/DownloadFile {
if ($args ~* "(\.\.|%2e%2e|/etc/|\\)") {
return 403;
}
proxy_pass http://yishaadmin_upstream;
}
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

