Summary
HTMLy CMS up to version 3.1.1 contains a path traversal flaw in the admin autosave endpoint that lets low-privileged authenticated users move arbitrary files on the server.
By injecting directory traversal sequences into the oldfile parameter, an attacker can influence file existence checks and rename operations, causing unintended relocation of any file writable by the web server into attacker-controlled draft locations.
Affected context
This vulnerability arises in HTMLy CMS installations where authenticated users can access the admin autosave functionality.
The issue is present when user-supplied filenames from the oldfile parameter are used directly in filesystem operations without path normalization, sanitization, or enforcement of a safe base directory.
It typically impacts environments where the web server process has write access to content, configuration, or other application files under the CMS directory tree.
Exploit preconditions
- Attack surface: HTTP(S) request to the admin autosave endpoint (
admin.php) in HTMLy CMS. - Required access: Low-privileged authenticated access to the CMS dashboard or autosave feature.
- Trigger point: Submission of an autosave request containing crafted
oldfilevalues with directory traversal sequences (e.g.,../patterns). - Why exploitation is possible: The application passes the
oldfileparameter directly tofile_exists()andrename()without canonicalizing the path or enforcing directory boundaries, allowing attacker-controlled paths to influence where files are located on disk.
Why this happens
The core bug is an improper limitation of the path used for filesystem operations, aligning with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
HTMLy CMS relies on user-controlled input (oldfile) to build filesystem paths for autosave and draft handling, but it does not normalize, validate, or restrict those paths to a dedicated content directory.
Consequently, directory traversal sequences are honored by the underlying operating system APIs, enabling attackers to target arbitrary writable files and relocate them to locations under their control.
Potential impact
- Files writable by the web server can be relocated into attacker-chosen draft or content directories.
- Application content may be overwritten, reordered, or made unavailable due to unintended file moves.
- Draft areas controlled by the attacker can be populated with sensitive or configuration files that might later be exposed or manipulated.
- Integrity of posts, media, or auxiliary scripts can be degraded, potentially aiding further exploitation via content spoofing or confusion.
General mitigation guidance
Effective mitigation focuses on treating all filesystem paths derived from user input as untrusted and constraining them to well-defined directories.
Common patterns include:
- Performing path canonicalization and rejecting any path containing traversal components or resolving outside the intended content root.
- Maintaining a whitelist of valid filenames or IDs and mapping them to server-side paths rather than accepting raw paths from the client.
- Implementing a dedicated storage area for autosave and draft files, with strict checks to ensure operations never cross directory boundaries.
- Running the web server and CMS code with least-privilege filesystem permissions so that only necessary content files are writable.
- Centralizing file-handling logic behind a safe abstraction that enforces directory constraints and normalizes paths.
How teams detect issues like this
Detection generally relies on examining how the application constructs paths from request parameters and applies filesystem functions.
Security teams can:
- Use static analysis rules to flag direct use of user input in functions such as
file_exists(),rename(),unlink(), or similar filesystem APIs without prior validation. - Perform code reviews focusing on areas that accept filename or path parameters, looking for missing canonicalization and boundary checks.
- Define secure coding policies that require all path-based operations to pass through vetted helper functions enforcing restricted directories.
- Employ automated application security testing (DAST/IAST) tools configured to send directory traversal payloads to endpoints exposing file-related parameters, observing unexpected file moves or access patterns.

