Severity:

HIGH RISK

(8.1)

Path Traversal / Arbitrary File System Access

CVE-2026-5436

Deferred

Vulnerability type

Category:

Path Traversal / Arbitrary File System Access

CWE:

CWE-22

Impact:

Arbitrary File Move and Potential Remote Code Execution

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

MW WP Form for WordPress improperly validates an attacker-controlled upload field key, allowing absolute filesystem paths to be used when resolving upload destinations.

In vulnerable configurations, this can let an unauthenticated attacker move sensitive or executable files (such as wp-config.php) into web-accessible locations, potentially resulting in remote code execution.

Affected context

This vulnerability arises in WordPress sites using the MW WP Form plugin when:

  • A form includes at least one file upload field, and
  • The "Saving inquiry data in database" option is enabled for that form.

In this context, the plugin processes user-submitted file uploads and uses the upload field key to build filesystem paths. Because absolute paths passed via this key are not properly constrained to the intended upload directory, the plugin may operate on arbitrary files that already exist on the server.

Exploit preconditions

  • Attack surface: Publicly accessible WordPress forms powered by MW WP Form that have:
  • At least one upload field, and
  • "Saving inquiry data in database" enabled.
  • Required access: No authentication required; an attacker only needs the ability to submit the vulnerable form.
  • Trigger point: Submission of a specially crafted POST request where:
  • The mwf_upload_files[] parameter contains keys that are absolute paths to existing files on the server.
  • Why exploitation is possible:
  • The attacker-controlled upload field key flows into _set_request_valiables() and is stored in the Data model.
  • regenerate_upload_file_keys() passes this value as $name into generate_user_filepath() / generate_user_file_dirpath().
  • generate_user_file_dirpath() uses WordPress path_join(), which returns absolute paths unchanged, ignoring the intended base directory constraint.
  • The plugin's validation only verifies that the referenced file exists, which is true for legitimate system files (e.g., wp-config.php).
  • _get_attachments() later reuses the same keys and calls move_temp_file_to_upload_dir(), which uses rename() to move the targeted file into the uploads directory.

Why this happens

The core issue is a path traversal / arbitrary file path handling flaw where untrusted input is used directly in filesystem path construction without enforcing a safe base directory.

Specifically:

  • The $name parameter, derived from user-controlled upload field keys (mwf_upload_files[]), is treated as a trusted component of a filesystem path.
  • The code relies on path_join() to construct paths, but this helper is designed to preserve absolute paths, effectively bypassing any intended root directory restriction.
  • Validation logic only checks for the existence of the referenced file, not that it resides within an allowed directory or matches an expected pattern.

This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where external input is allowed to influence which files on the filesystem are accessed or moved.

Potential impact

  • Arbitrary file move operations on the WordPress server's filesystem.
  • Relocation of sensitive configuration files (e.g., wp-config.php) into web-accessible directories.
  • Potential remote code execution if a PHP or other executable file is moved into a location where it can be invoked by the web server.
  • Loss of confidentiality for secrets stored in configuration or data files once they are exposed via the web root.
  • Service instability or outages if key application files are moved away from their expected locations.

General mitigation guidance

Effective mitigation focuses on strictly constraining filesystem operations and isolating untrusted input from path construction:

  • Enforce directory whitelisting: Ensure all upload- and attachment-related paths are normalized and explicitly checked to reside within a predefined, application-owned directory (e.g., the uploads folder).
  • Disallow absolute and traversal paths: Reject or sanitize any user-influenced path component that:
  • Begins with a directory separator or drive letter, or
  • Contains .. segments or similar traversal constructs.
  • Treat form field keys as data, not paths: Use internal, server-generated identifiers for file storage paths rather than reusing form field names or client-supplied keys as direct filesystem components.
  • Validate against strict patterns: Apply allowlist-based validation (e.g., alphanumeric plus a small set of safe characters) to all path-related parameters derived from requests.
  • Least-privilege file permissions: Run the web server and PHP process with minimal filesystem rights, limiting what can be moved, read, or written even if path validation fails.
  • Configuration hardening: Avoid placing highly sensitive files (such as configuration secrets) in locations accessible to the web server user where possible, and separate code, configuration, and data onto distinct paths.

How teams detect issues like this

Organizations can detect and monitor for this class of issue using multiple complementary approaches:

  • Static analysis and linting:
  • Flag uses of path manipulation functions (path_join, rename, copy, filesystem APIs) where any argument is derived from request data, form field names, or generic array keys.
  • Enforce rules requiring normalization and base-directory enforcement before any file operation that touches user-controlled values.
  • Code review practices:
  • Examine form handling code paths, especially upload handlers, for flows where untrusted input becomes part of a filesystem path.
  • Verify that any existence checks (file_exists, similar functions) are paired with directory boundary checks, not used as a sole validation mechanism.
  • Runtime monitoring and logging:
  • Log file move and rename operations performed by the application, including source and destination paths, and alert on movement of configuration files or code into the uploads directory.
  • Monitor web server logs for sudden access to PHP or other executable files in the uploads folder or other unexpected directories.
  • Automated security testing:
  • Use dynamic application security testing (DAST) tools or custom scripts to submit crafted upload requests and observe whether out-of-scope files can be moved or exposed.

Sources

SourceLink
github.comgithub.com/web-soudan/mw-wp-form/commit/f872ab18ca670f5867b2241745daa30cd0fab861
plugins.trac.wordpress.orgplugins.trac.wordpress.org/browser/mw-wp-form/tags/5.1.1/classes/models/class.data.php#L591
plugins.trac.wordpress.orgplugins.trac.wordpress.org/browser/mw-wp-form/tags/5.1.1/classes/models/class.directory.php#L138
plugins.trac.wordpress.orgplugins.trac.wordpress.org/changeset/3501261/mw-wp-form
wordfence.comwordfence.com/threat-intel/vulnerabilities/id/bc308993-7fc5-41db-a396-f05e95fe47b8?source=cve

Frequently asked

questions

Yes. If a vulnerable MW WP Form-based form is publicly accessible with an upload field and database saving enabled, an unauthenticated attacker can craft POST requests to exploit the issue remotely.

No authentication is required under typical conditions. The main prerequisite is the ability to submit the affected form. However, if site-specific protections (such as IP allowlists, captchas, or access control plugins) restrict form submission, those controls can indirectly limit exploitability.

The safest pattern is to completely decouple user-supplied values from filesystem paths: normalize and validate all paths against a fixed, application-controlled base directory, disallow absolute and traversal paths, and generate internal file identifiers rather than using form field keys or user input as path components.

Establish a consistent file-handling abstraction that:

  • Accepts only vetted, normalized paths rooted in a small set of approved directories.
  • Uses allowlist-based validation for any path segments derived from external input.
  • Centralizes path operations so security checks are applied uniformly.

Combine this with regular secure code reviews, targeted static analysis rules for file operations, and defense-in-depth measures such as least-privilege filesystem permissions.

Find out what's already
exploitable in your codebase.