/

CVE-2025-66480

Severity:

CRITICAL RISK

(9.8)

Path Traversal and Unrestricted File Upload in Wildfire IM

CVE-2025-66480

Analyzed

Vulnerability type

Category:

Path Traversal and Unrestricted File Upload

CWE:

CWE-22, CWE-434

Impact:

Remote Code Execution via Arbitrary File Write

Severity:

CRITICAL RISK

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

Wildfire IM's im-server component contains a critical flaw in its file upload endpoint (/fs) where user-supplied filenames are concatenated directly with the storage directory without sanitizing path traversal sequences.

An attacker who can reach this upload endpoint may write arbitrary files anywhere the application has write access, which can lead to remote code execution and full server compromise by placing or overwriting executable or configuration files.

Affected context

This vulnerability affects deployments of Wildfire IM im-server prior to version 1.4.3 that expose or internally consume the /fs multipart file upload endpoint implemented by com.xiaoleilu.loServer.action.UploadFileAction.

The issue arises when the server uses a configurable base directory for uploaded files and then directly appends the user-controlled filename from the request without canonicalization or validation.

Any environment where the application process has write permissions to sensitive directories (webroots, configuration directories, user SSH directories, cron paths, or script locations) is at increased risk, particularly where uploaded content may later be interpreted as code or executed automatically.

Exploit preconditions

  • Attack surface: HTTP(S) interface for the /fs file upload endpoint in the im-server component.
  • Required access: Ability to send a multipart/form-data file upload request to the vulnerable endpoint (typically network access; authentication requirements depend on deployment configuration).
  • Trigger point: Submission of an upload request with a crafted filename containing directory traversal sequences (e.g., ../../) or other path manipulation constructs.
  • Why exploitation is possible: The writeFileUploadData method in UploadFileAction concatenates the configured upload directory with the raw filename from the request, without normalizing the path or stripping traversal sequences, enabling writes outside the intended upload directory to any filesystem location writable by the process.

Why this happens

The underlying bug is a combination of path traversal and unrestricted file upload, driven by trusting user-controlled path components.

Instead of treating the filename from the multipart request as untrusted data that must be normalized and constrained to a safe directory, the implementation directly appends it to the configured storage path.

This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where lack of canonicalization and validation permits ..-based directory escapes, and to CWE-434: Unrestricted Upload of File with Dangerous Type, because the application does not enforce strict controls on file type or destination, allowing attackers to place executable or configuration files in locations where they can be interpreted as code or used to influence system behavior.

Potential impact

  • Arbitrary file creation in directories writable by the application process.
  • Overwriting of existing files such as configuration files, SSH authorized_keys, scheduled task definitions, or application resources.
  • Remote Code Execution by placing web shells, scripts, binaries, or modified configuration that triggers code execution.
  • Privilege escalation if overwritten files are consumed by higher-privileged services or automated processes.
  • Persistent backdoor installation through modified startup scripts, cron jobs, or service configurations.

General mitigation guidance

Effective mitigation focuses on constraining both where files can be written and what can be uploaded:

  • Enforce strict path handling by normalizing and canonicalizing uploaded filenames and rejecting any value that attempts to navigate outside a designated upload directory (e.g., contains .., absolute paths, or path separators).
  • Replace client-supplied filenames with server-generated identifiers (UUIDs or hashed names) and keep any original names only as metadata, never as filesystem paths.
  • Apply a strong allowlist of permitted file types and sizes, and decouple uploaded content from any execution context (e.g., store outside webroots or executable directories).
  • Use filesystem and OS-level permissions to ensure the im-server process can write only to a narrowly scoped upload directory and cannot modify configuration, executable, or system directories.
  • Design downstream processing so that uploaded files are treated as data, not code: no automatic execution, dynamic loading, or interpretation without additional validation.

How teams detect issues like this

Detection typically involves both code-level and operational controls:

  • Static analysis: Define rules that flag direct concatenation of user-controlled values into filesystem paths, especially in upload handlers (e.g., usages of new File(baseDir + userFilename) or equivalent), and highlight any missing checks for .., slashes, or path canonicalization.
  • Code review: Scrutinize file upload endpoints for:
  • Use of client-supplied filenames in filesystem paths.
  • Lack of path normalization and directory whitelisting.
  • Storage locations that overlap with executable directories or configuration paths.
  • Policy enforcement: Incorporate secure upload patterns into coding standards, and enforce them via CI checks, pre-commit hooks, or automated review tools that search for direct use of raw request parameters in file paths.
  • Runtime monitoring: Log all file uploads, including resolved filesystem paths, and alert on uploads to atypical directories or patterns indicating traversal attempts; consider file integrity monitoring on sensitive directories to detect unexpected changes.

Sources

SourceLink
github.comgithub.com/wildfirechat/im-server/commit/2f9c4e028c01c64913cab32e7248bcca183a5230
github.comgithub.com/wildfirechat/im-server/releases/tag/1.4.3
github.comgithub.com/wildfirechat/im-server/security/advisories/GHSA-74hq-jhx2-fq6c

Frequently asked

questions

Yes. If the /fs upload endpoint is reachable over the network, an attacker can exploit the vulnerability remotely by sending crafted multipart upload requests with malicious filenames, without needing local filesystem access.

It depends on how the Wildfire IM im-server is deployed. If the /fs endpoint is exposed without authentication or with weak controls, unauthenticated attackers may exploit it. Even when authentication is required, any user able to upload files can potentially leverage this flaw, so the risk is not limited to administrators.

The safest pattern is to stop trusting client-provided filenames: generate server-side filenames, normalize and validate any path components, and strictly confine all uploads to a dedicated non-executable directory. Combined with strong file-type validation and least-privilege filesystem permissions, this removes the path traversal and arbitrary write conditions.

Adopt a defense-in-depth upload design: treat all filenames and paths as untrusted input, enforce canonicalization and directory whitelisting, avoid storing uploads in locations where they can be executed or interpreted as code, and institutionalize these patterns through secure coding guidelines, code review checklists, and automated scanning focused on file and path handling.

Find out what's already
exploitable in your codebase.