/

CVE-2026-40909

Severity:

HIGH RISK

(8.7)

Path Traversal File Write in WWBN AVideo locale/save.php

CVE-2026-40909

Analyzed

Vulnerability type

Category:

Path Traversal / Arbitrary File Write

CWE:

CWE-22

Impact:

Remote Code Execution via Arbitrary File Write

Severity:

HIGH RISK

(8.7)

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

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:
  • flag contains path traversal sequences (e.g., ../) and a target filename (e.g., with a .php extension)
  • code contains 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 via fwrite() without filtering or content validation
  • The web server is configured to execute .php files 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 .php files 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 .json or .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 by fopen, 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 .php or 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 .php files 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.

Sources

SourceLink
github.comgithub.com/WWBN/AVideo/commit/57f89ffbc27d37c9d9dd727212334846e78ac21a
github.comgithub.com/WWBN/AVideo/security/advisories/GHSA-6rc6-p838-686f

Frequently asked

questions

Yes, but exploitation typically requires either direct access as an authenticated admin or the ability to perform CSRF against an admin's browser. If an attacker can cause an admin to load a malicious page while logged in, they may trigger the vulnerable endpoint remotely.

The attacker needs logical admin privileges in the application, or practical control over an admin's browser session (through CSRF). No direct filesystem or shell access is required; exploitation happens purely via crafted HTTP requests.

Constrain all file operations to a well-defined directory, canonicalize paths, and reject any path that escapes that directory. Combine this with strict filename and extension allowlists, avoid writing executable files from user input, and introduce robust CSRF protections on all state-changing endpoints.

Adopt secure file-handling patterns as a standard:

  • Never build paths by simple string concatenation with raw user input.
  • Centralize path validation and normalization utilities.
  • Prohibit dynamic creation of executable code files from HTTP input.
  • Enforce CSRF protection, least-privilege filesystem permissions, and regular security reviews focusing on endpoints performing file I/O.
Find out what's already
exploitable in your codebase.