Summary
The UsersWP WordPress plugin contains an arbitrary file deletion flaw where attacker-controlled file metadata is used to build filesystem paths without proper validation or boundary checks.
Authenticated users with Subscriber-level access and above can abuse an AJAX handler to delete files outside the uploads directory, including critical configuration files such as wp-config.php, when the vulnerable conditions are present.
Affected context
This vulnerability occurs in WordPress sites that:
- Have the UsersWP plugin installed at version 1.2.65 or earlier
- Allow logged-in users (Subscriber and above) to submit or edit forms containing file-type fields
- Rely on UsersWP_Validation::validate_fields() together with UsersWP_Forms::upload_file_remove() for handling file uploads and removals
In these contexts, untrusted metadata from file fields can propagate directly into filesystem operations targeting the server's uploads directory and beyond.
Exploit preconditions
- Attack surface: Web application via UsersWP AJAX endpoints
- Required access: Valid authenticated account with at least Subscriber-level privileges
- Trigger point: Invocation of the
upload_file_removeAJAX handler that constructs a deletion path from user-controlled file metadata - Why exploitation is possible: File-field values are only passed through
sanitize_text_field(), which preserves directory traversal sequences; the resulting value is concatenated with the uploads base directory withoutrealpathcanonicalization or enforcement that the computed path stays inside the uploads directory before callingunlink().
Why this happens
The core issue is improper path validation when using user-supplied input to construct filesystem paths, aligning with CWE-22: Improper Limitation of a Pathname to a Restricted Directory (Path Traversal).
UsersWP's validation logic treats file-type fields as text, allowing traversal sequences like ../ to persist, and the subsequent AJAX handler directly concatenates this untrusted metadata with the uploads base directory.
Because there is no canonicalization, normalization, or strict check that the target path resides within an allowed directory, attackers can influence unlink() to operate on arbitrary files on the server.
Potential impact
- Authenticated users may delete critical WordPress configuration files (e.g.,
wp-config.php), potentially breaking the site. - Attackers could remove
.htaccessor similar protection files, weakening security controls. - Deletion of plugin or theme files could cause functionality loss, downtime, or inconsistent system behavior.
- Removal of log files may hinder incident investigation and monitoring.
- Targeted deletion of backup files could make recovery from other compromises more difficult.
General mitigation guidance
Effective mitigation focuses on constraining filesystem operations and treating all path fragments derived from user input as untrusted.
Common defensive patterns include:
- Implementing strict allow-listing for directories and filenames, ensuring deletion targets are limited to known safe locations inside the uploads directory.
- Canonicalizing paths using
realpathor equivalent APIs and verifying that the resolved path starts with the expected uploads base directory before performing any file operation. - Separating user-visible identifiers (such as media IDs or tokens) from actual filesystem paths, storing the true paths server-side and never trusting client-supplied path segments.
- Applying least-privilege to the web server user and filesystem, so even if validation fails, the impact of file deletion is constrained.
- Designing file-handling components to be secure by default, making unsafe direct path manipulation or concatenation hard or impossible for developers to implement.
How teams detect issues like this
Organizations can detect similar path traversal and arbitrary file deletion risks through a combination of:
- Static analysis rules that flag direct use of user-controlled input in filesystem APIs such as
unlink,delete,rename, orfile_put_contents. - Code review practices that look for path construction via simple string concatenation of input values with base directories, and verify that canonicalization and boundary checks are present.
- Application-level logging of file deletion operations, including the requesting user, source endpoint, and full resolved path, then monitoring for deletions outside expected directories.
- Security policy enforcement in CI/CD pipelines that require use of centralized, hardened file-management utilities rather than ad hoc path handling in plugin code.
- Optional automated scanning tools that understand WordPress-specific patterns and can highlight risky AJAX handlers and form processing functions that manipulate files.

