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
/fsfile 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
writeFileUploadDatamethod inUploadFileActionconcatenates 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.

