Summary
Hestia Control Panel 1.3.2 exposes an arbitrary file write vulnerability in its API index.php endpoint, allowing authenticated users to write files to attacker-controlled paths on the server.
By abusing the v-make-tmp-file command, an attacker can place SSH keys or other crafted content in sensitive locations, potentially leading to full account or system compromise.
Affected context
The vulnerability occurs in Hestia Control Panel deployments that:
- Expose the API interface via index.php
- Allow access to the v-make-tmp-file command for authenticated panel users or API clients
- Do not sufficiently constrain or validate file paths and target locations for temporary file creation
In these conditions, authenticated attackers can influence where the application writes files on the underlying server.
Exploit preconditions
- Attack surface: Hestia Control Panel API, specifically the index.php endpoint.
- Required access: Valid authenticated credentials or an API token with permission to invoke v-make-tmp-file.
- Trigger point: An API request that calls v-make-tmp-file with attacker-controlled path parameters.
- Why exploitation is possible: The application trusts user-supplied file paths and fails to restrict them to safe directories or sanitize traversal and target locations, allowing writes outside intended temporary paths.
Why this happens
This issue stems from allowing external input to directly control file paths used by the server-side application when creating or writing files.
The v-make-tmp-file command accepts user-controlled path parameters that are not properly constrained to a safe directory or validated against a whitelist of allowed locations.
This maps to CWE-73: External Control of File Name or Path, where the software uses input from an external source to construct file system paths, enabling writes to arbitrary or sensitive locations on the host.
Potential impact
- Creation of attacker-controlled SSH keys in authorized_keys files, enabling unauthorized remote access.
- Overwriting or planting configuration files to alter service behavior or weaken security controls.
- Dropping web shells or executable scripts where they can be executed by the web server or scheduled tasks.
- Persistence on the host through malicious files placed in startup directories or cron configurations.
- Pivoting from a limited panel account to broader system-level compromise.
General mitigation guidance
Effective mitigation focuses on tightly controlling where and how the application can create or write files:
- Restrict file creation operations to predefined, application-owned directories with no executable semantics (e.g., strictly controlled temp areas).
- Enforce strong path validation, rejecting any user-provided path containing traversal patterns or referencing outside allowed directories.
- Replace direct path concatenation with higher-level APIs that enforce sandboxed directories and canonicalization checks.
- Apply least-privilege principles to the service account so that even if file writes occur, sensitive system locations remain inaccessible.
- Introduce strict authorization checks around any file-generation or temporary-file commands exposed via the API, granting access only where operationally necessary.
How teams detect issues like this
Detection generally relies on a combination of code analysis and runtime monitoring:
- Use static analysis rules or code review checklists to flag any file operations that incorporate user-supplied paths, especially in API handlers or CLI wrappers like v-make-tmp-file.
- Look for patterns where input parameters are used directly in filesystem functions (e.g., fopen, file_put_contents, exec wrappers) without normalization or directory enforcement.
- Implement logging for security-relevant file write operations, including target paths and calling users, and alert on writes outside designated application directories.
- Employ file integrity monitoring on critical locations (e.g., SSH directories, configuration folders, webroot) to detect unexpected new or modified files.
- Integrate automated security testing or SAST tools in CI/CD to catch path-controlled file writes before deployment.

