Summary
Hermes WebUI exposes an arbitrary file deletion issue where the /api/session/delete endpoint accepts unvalidated session identifiers as filesystem paths.
An authenticated attacker can supply absolute or traversal-based paths in the session_id parameter to delete JSON files outside the intended session directory, potentially disrupting application behavior or destroying important data.
Affected context
This vulnerability occurs in deployments of Hermes WebUI that:
- Expose the /api/session/delete HTTP endpoint to authenticated users
- Derive filesystem paths from the session_id parameter
- Assume session identifiers are confined to a predefined SESSION_DIR
- Operate on a filesystem where the application has write/delete permissions to JSON files beyond the session directory
The risk is higher when the application runs with broad filesystem permissions or on shared hosts where JSON configuration or data files are critical.
Exploit preconditions
- Attack surface: HTTP API, specifically the /api/session/delete endpoint.
- Required access: Valid authenticated access to Hermes WebUI sufficient to invoke session deletion.
- Input control: Ability to supply arbitrary values in the session_id parameter (e.g., absolute paths or ../ traversal sequences).
- Trigger point: Server-side file deletion logic that constructs a path from session_id and performs a delete operation.
- Why exploitation is possible: The implementation trusts session_id as a safe identifier and does not normalize, constrain, or validate the resulting path against the SESSION_DIR boundary before deleting the target file.
Why this happens
The underlying issue is an improper restriction of pathnames derived from user-controlled input, mapped to CWE-22 (Improper Limitation of a Pathname to a Restricted Directory).
Instead of treating session_id as an opaque token, the code appears to concatenate it directly with a base directory or accept it as an absolute path, then passes the resulting path to a delete operation.
Without robust canonicalization and boundary checks, attackers can craft session_id values that include absolute paths or directory traversal sequences (e.g., ../) to escape SESSION_DIR and target arbitrary writable JSON files.
Conceptually, this pattern confuses an untrusted identifier (session_id) with a trusted filesystem path, breaking the assumption that operations are confined to a safe directory.
Potential impact
- Deletion of JSON session files, causing user sessions or workflows to fail.
- Deletion of application JSON configuration or state files, leading to outages or misconfiguration.
- Destruction of critical data stored in JSON format, potentially resulting in data loss and integrity issues.
- Facilitation of further attacks by removing security-related files (e.g., audit logs or controls) if they are JSON and writable.
- Service instability or denial of service if key application resources are deleted.
General mitigation guidance
Effective mitigation focuses on treating session identifiers as opaque tokens and strictly constraining filesystem operations:
- Construct file paths by combining a fixed, trusted base directory (SESSION_DIR) with sanitized filenames, not arbitrary user-supplied paths.
- Normalize and canonicalize the resulting path, then enforce that it remains under the intended SESSION_DIR before performing any delete operations.
- Reject any session_id containing path separators, traversal tokens, or absolute-path indicators; treat it as an identifier rather than a path.
- Implement allowlists for expected filename patterns (e.g., alphanumeric IDs with a fixed extension) instead of accepting arbitrary strings.
- Run the application with least-privilege filesystem permissions so it can only modify files within its dedicated data directories.
- Consider abstracting file management behind higher-level storage APIs rather than directly operating on raw filesystem paths.
How teams detect issues like this
Organizations can identify and monitor for this vulnerability through:
- Static analysis rules that flag the use of user-controlled parameters (like session_id) in filesystem APIs (unlink, remove, delete) without validation or path normalization.
- Code review checklists that require reviewers to verify directory confinement and canonicalization for any file deletion or modification functionality.
- Runtime monitoring of file deletion events from the application process, especially deletes targeting paths outside the expected session directory.
- Logging and anomaly detection on the /api/session/delete endpoint, alerting on unusual session_id values (absolute paths, ../ sequences, or unexpected file locations).
- Integration of automated security scanning tools in CI that look for CWE-22 patterns and enforce policy on path construction.

