Summary
WWBN AVideo's locale save endpoint builds file paths by directly concatenating user-controlled input from $_POST['flag'] and writes raw data from $_POST['code'] to that path without sanitization or CSRF protection.
An authenticated admin—or an attacker able to CSRF an admin session—can traverse out of the locale/ directory and write arbitrary .php files to writable locations on the server, potentially resulting in remote code execution.
Affected context
This vulnerability exists in WWBN AVideo (versions 29.0 and prior) within the locale/save.php endpoint, which is intended to save locale-related content.
It manifests when:
- The application processes POST requests to
locale/save.php - File paths are constructed directly from
$_POST['flag']without normalization or validation - File contents are taken verbatim from
$_POST['code']and written to disk - PHP files written via this mechanism are located in web-accessible directories and executed by the PHP interpreter
Exploit preconditions
- Attack surface: HTTP POST requests to
locale/save.php - Required access:
- Valid admin session in the application, OR
- Ability to perform Cross-Site Request Forgery (CSRF) against a logged-in admin, aided by:
- Lack of CSRF tokens
- Cookies configured with
SameSite=None - Trigger point: A crafted POST request where:
flagcontains path traversal sequences (e.g.,../) and a target filename (e.g., with a.phpextension)codecontains attacker-controlled PHP code or other payload- Why exploitation is possible:
- The path is built by naive concatenation of
$_POST['flag']into the filesystem path without sanitization or restriction to the intended directory - The file is opened for writing and
$_POST['code']is written verbatim viafwrite()without filtering or content validation - The web server is configured to execute
.phpfiles in the chosen writable directory
Why this happens
The root cause is improper handling of user-supplied path components and file content in a file-write operation.
At line 30, locale/save.php constructs a filesystem path by directly embedding the $_POST['flag'] value, which allows directory traversal (../) to escape the intended locale/ directory.
At line 40, the script writes the unvalidated $_POST['code'] data directly into the derived path using fwrite().
This combination fits CWE-22: Improper Limitation of a Pathname to a Restricted Directory, and also aligns with the broader class of arbitrary file write vulnerabilities: untrusted input influences both the file location and the file contents without enforced constraints, enabling attackers to create executable PHP files in web-accessible locations.
Potential impact
- Creation of arbitrary
.phpfiles on the server in directories writable by the web process - Remote code execution by sending HTTP requests to attacker-created PHP scripts
- Full compromise of the application instance, including reading or modifying data accessible to the web server user
- Installation of web shells or backdoors for persistent access
- Use of the compromised server as a pivot point for further attacks within the hosting environment or internal network
General mitigation guidance
Effective mitigation focuses on constraining filesystem access and hardening the request-handling workflow:
- Restrict file paths to a fixed, canonical base directory and normalize all paths before use, rejecting any that traverse outside (e.g., containing
..or absolute paths). - Enforce strict allowlists for filenames and extensions (e.g., limiting to known locale file names and non-executable extensions such as
.jsonor.txt). - Avoid writing executable files (like
.php) based on user input; store dynamic data in non-executable directories and formats. - Validate and sanitize user-controlled content before writing to disk, ensuring it cannot be directly executed as server-side code.
- Implement CSRF protections (tokens, proper SameSite cookie attributes) on state-changing endpoints such as configuration or locale-saving APIs.
- Run the web server under a minimally privileged user account with restricted write permissions, ensuring only necessary directories are writable.
How teams detect issues like this
Organizations can detect and monitor this class of issue using multiple approaches:
- Static analysis: Look for patterns where user input (e.g.,
$_POST,$_GET, request parameters) is directly concatenated into filesystem paths used byfopen,file_put_contents,fwrite, or similar APIs without validation or normalization. - Code review signals: Flag endpoints that:
- Accept path-like parameters (
file,name,lang,flag) and pass them into file operations - Allow
.phpor other executable extensions to be created or modified based on request data - Lack CSRF protections on state-changing routes.
- Runtime monitoring: Track unexpected creation or modification of
.phpfiles or other executable content within web roots, especially outside normal deployment cycles. - File integrity monitoring: Use tools to baseline expected files and detect new or altered scripts in application directories.

