Summary
NukeViet CMS can store a crafted attachment path submitted by an authenticated administrator without checking that it remains within the intended upload directory. When the associated comment is deleted, the stored path may allow deletion of application files, potentially causing an outage.
Affected context
The issue affects NukeViet CMS versions prior to 4.5.09 in the comment administration workflow. The edit handler stores a crafted attachment path, and the deletion handler later joins that path to the upload directory; the file deletion check limits paths to the application root rather than the upload directory.
Exploit preconditions
- Attack surface: Comment administration endpoints and filesystem deletion
- Required access: An authenticated administrator able to submit comment edits
- Trigger point: Deletion of a comment containing the stored attachment path
- Why exploitation is possible: The edit handler does not validate path containment, and the deletion check permits paths within the application root rather than restricting them to the upload directory
Why this happens
The handlers manipulate a user-controlled attachment path without canonicalizing and validating that the resolved path remains within the intended upload directory. This is a path traversal weakness mapped to CWE-22: Improper Limitation of a Pathname to a Restricted Directory. Checking against a broader application root does not enforce the narrower upload-directory boundary.
Potential impact
- Application files, including configuration files, could be deleted
- The CMS may become unavailable or fail to operate correctly
- Administrators may need to restore deleted files from backups
General mitigation guidance
Defensive patterns should ensure file operations remain within their intended directory boundaries.
- Resolve and canonicalize paths, then verify they are contained within the specific upload directory
- Prefer server-generated file identifiers over accepting filesystem paths from request data
- Validate attachment references against trusted records before deletion
- Apply least-privilege filesystem permissions so the web application cannot delete unrelated application files
- Treat authenticated input as untrusted and use safe-by-default file handling APIs
How teams detect issues like this
- Use static analysis to identify path joins involving request data and file deletion APIs
- Review code for fixed-length prefix removal or other path transformations without containment checks
- Add tests and code-review checks that verify resolved file paths cannot escape the designated upload directory
- Enforce policies requiring canonical path validation before filesystem operations

