Summary
FrontAccounting suffers from a path traversal flaw in its attachment upload handler that lets authenticated users write files outside the intended attachments directory.
By abusing the unique_name parameter and uploading executable scripts into the web root, an attacker can achieve remote code execution under the web server account.
Affected context
This vulnerability occurs in FrontAccounting deployments that expose the attachment upload functionality to authenticated users.
It manifests when the application constructs file system paths from user-controlled input (unique_name) without robust normalization or directory enforcement.
Environments where the web root resides on the same filesystem and the server executes uploaded PHP files are particularly at risk, though the exact exploitability depends on local server configuration and permissions.
Exploit preconditions
- Attack surface: HTTP(S) interface of FrontAccounting, specifically the attachment upload endpoint.
- Required access: Valid authenticated account with permission to upload attachments (often low-privilege user).
- Trigger point: Submission of an upload request where the unique_name parameter includes traversal sequences (e.g., "../../../shell.php") and the payload is a PHP script.
- Why exploitation is possible: The server trusts the unique_name parameter when building filesystem paths, fails to constrain writes to the attachments directory, and does not enforce safe file types or extensions, allowing executable files to be placed in the web root.
Why this happens
The bug stems from unsafe construction of filesystem paths using user-supplied values without strict validation or normalization.
The upload handler relies on the unique_name parameter to determine where an attachment should be stored, but does not properly remove or reject directory traversal sequences or verify that the final path remains inside the intended attachments directory.
Additionally, there is insufficient validation of uploaded file types and extensions, which allows PHP code to be placed in locations where the web server will execute it.
Conceptually, this maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where user input influences file paths beyond the intended sandbox.
Potential impact
- Remote code execution in the context of the web server user.
- Installation of web shells that can be used for persistent access.
- Reading or modification of application configuration and data files accessible to the web server.
- Tampering with FrontAccounting records or exporting sensitive financial information.
- Lateral movement to other services if local credentials or configuration files are accessible.
General mitigation guidance
Effective mitigation focuses on constraining filesystem access and reducing trust in user-supplied path components.
Recommended patterns include:
- Deriving storage paths solely from server-side logic and ignoring user-controlled directory hints.
- Normalizing and validating any path that incorporates user input, then enforcing that the resolved path remains within a dedicated upload directory.
- Applying strict allowlists for file types and extensions, and treating uploads as inert content (e.g., disabling script execution from upload directories).
- Running the web server and application components with least-privilege accounts and ensuring uploads are stored outside the executable web root.
- Applying defense-in-depth measures such as application-level checks that block traversal patterns and centralized file handling utilities that encapsulate safe path creation.
How teams detect issues like this
Detection typically involves a combination of static analysis, configuration review, and runtime monitoring:
- Static analysis rules that flag uses of user-controlled values in filesystem operations, especially concatenation of request parameters into paths.
- Code reviews that look for upload handlers or attachment features that do not normalize paths or enforce directory boundaries and extension allowlists.
- Security tests or dynamic analysis that attempt to upload files using traversal sequences and verify whether writes are constrained to the intended directory.
- Web server configuration audits confirming that upload directories are non-executable and isolated from the main web root.
- Automated application security testing tools can help surface path traversal and arbitrary file write patterns during CI/CD.

