Summary
Wekan's avatar upload feature previously passed user-controlled filenames into a shell command used for MIME-type detection, without safely handling shell metacharacters.
An attacker who could upload an avatar with a crafted filename containing shell syntax could execute arbitrary commands on the Wekan server process.
Affected context
The vulnerability occurs in Wekan instances that allow users to upload avatar images, where the application builds shell commands using user-supplied filenames.
Specifically, the logic in models/avatars.js and models/fileValidation.js used child_process.exec() with a command string that directly embeds the avatar filename.
Environments where file uploads are broadly available or where filename validation is minimal are most exposed, especially when the Wekan process runs with elevated privileges.
Exploit preconditions
- Attack surface: HTTP(S) endpoint(s) handling avatar image uploads.
- Required access: Ability to authenticate (if required by the instance) and upload or influence avatar filenames.
- Trigger point: Server-side MIME-type detection that executes a shell command including the user-controlled filename.
- Why exploitation is possible: The filename is interpolated into a shell command executed via
child_process.exec()without proper escaping or argument separation, allowing shell metacharacters like backticks and$()to be interpreted as commands.
Why this happens
The core bug stems from constructing shell command strings by concatenating user-controlled input and then executing them via child_process.exec().
This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, because shell metacharacters in filenames are not neutralized, enabling command injection.
Additionally, it aligns with CWE-88: Argument Injection or Modification, as untrusted content is embedded into command arguments instead of using safe APIs that separate executable paths from parameters.
At an abstract level, the pattern is "dynamic shell command construction with untrusted input" instead of using parameterized or non-shell-based APIs for MIME detection.
Potential impact
- Execution of arbitrary OS commands with the privileges of the Wekan server process.
- Reading, modifying, or deleting application and system files accessible to the Wekan runtime.
- Exfiltration or corruption of Wekan board data and configuration.
- Pivoting to other services or hosts reachable from the compromised server.
- Installation of backdoors, cryptominers, or other persistent malware.
General mitigation guidance
Effective mitigation generally focuses on eliminating shell-based command construction paths and strictly constraining how external utilities are invoked.
Recommended defensive patterns include:
- Replacing
child_process.exec()with safer alternatives that accept argument arrays (for example,spawn-style APIs) and avoid going through the shell. - Using in-process MIME-type detection libraries instead of external shell commands where feasible.
- Treating filenames as opaque data: never interpolating them into shell commands or scripts; if external tools are unavoidable, pass filenames as separate arguments, not as part of a command string.
- Applying strict server-side validation and normalization of filenames, rejecting characters and patterns that are not needed for legitimate use (such as backticks,
$(), and other metacharacters). - Running the Wekan service with least-privilege OS accounts and restricted filesystem and network permissions to reduce impact if exploitation occurs.
How teams detect issues like this
Detection typically involves examining both source code and runtime behavior for dangerous command construction patterns.
Useful approaches include:
- Static analysis rules that flag uses of
child_process.exec()or similar shell-invoking APIs when any part of the command string is derived from request data, filenames, or other user inputs. - Code review checklists that require reviewers to verify that all external command executions use parameterized argument arrays and that no user-controlled data is concatenated into shell commands.
- Application-level logging that records unusual or malformed filenames supplied during avatar uploads, coupled with monitoring for suspicious command executions on the host.
- Host-based intrusion detection or endpoint monitoring configured to alert on unexpected shell invocations or processes spawned by the Wekan service account.

