GitHub Security Advisory: GHSA-r64r-883r-wcwh
Package: wwbn/avideo (COMPOSER)
Severity: HIGH (CVSS 8.6)
CWE: CWE-306: Missing Authentication for Critical Function
Vulnerable versions: <= 26.0
Patched in: unpatched

Summary: AVideo: Unauthenticated CDN Configuration Takeover via Empty Default Key Bypass and Mass-Assignment

Details:
## Summary

The CDN plugin endpoints `plugin/CDN/status.json.php` and `plugin/CDN/disable.json.php` use key-based authentication with an empty string default key. When the CDN plugin is enabled but the key has not been configured (the default state), the key validation check is completely bypassed, allowing any unauthenticated attacker to modify the full CDN configuration — including CDN URLs, storage credentials, and the authentication key itself — via mass-assignment through the `par` request parameter.

## Details

The CDN plugin defines a default empty key in `plugin/CDN/CDN.php:68`:

```php
$obj->key = "";
```

The `status.json.php` endpoint authenticates requests using this key, but the check has a critical logic flaw at lines 16-27:

```php
// Line 16-19: Requires attacker to provide SOME key value
if (empty($_REQUEST['key'])) {
    $resp->msg = 'Key is empty';
    die(json_encode($resp));
}

// Line 21-26: Only validates key IF stored key is non-empty
if (!empty($obj->key)) {      // When key is "" (default), this is FALSE
    //check the key
    if ($obj->key !== $_REQUEST['key']) {
        $resp->msg = 'Key Does not match';
        die(json_encode($resp));
    }
}
```

When the stored key is the default empty string `""`, `!empty("")` evaluates to `false`, and the entire key comparison block is skipped. Any non-empty value provided by the attacker passes authentication.

Following the bypass, lines 28-31 perform unchecked mass-assignment:

```php
$obj->key = $_REQUEST['key'];
foreach ($_REQUEST['par'] as $key => $value) {
    $obj->{$key} = $value;
    $resp->{$key} = $value;
}
```

The attacker-controlled `par` array sets arbitrary properties on the plugin data object. At line 95, the modified object is persisted to the database:

```php
$cdn = AVideoPlugin::loadPluginIfEnabled('CDN');
$id = $cdn->setDataObject($obj);
```

`setDataObject()` in `Plugin.abstract.php:263` serializes the entire object to JSON and saves it, making all mass-assigned properties persistent.

Exploitable properties (defined in `CDN.php:62-87`) include:
- `CDN` — main CDN URL for serving all video content
- `CDN_S3`, `CDN_B2`, `CDN_FTP` — storage-specific CDN URLs
- `enable_storage` — enables CDN storage functionality
- `storage_hostname`, `storage_username`, `storage_password` — storage backend credentials
- `key` — the authentication key itself (via mass-assignment, can override line 28)

The `disable.json.php` endpoint has the identical authentication bypass (lines 16-27) and additionally deactivates the CDN plugin entirely (line 37: `$cdn->setStatus('inactive')`).

This contrasts with other sensitive endpoints in the codebase that properly use session-based authentication. For example, `Gallery/saveSort.json.php` (commit 087dab884) uses `isGlobalTokenValid()`, and commit daca4ffb1 added `User::isAdmin()` checks to other configuration endpoints.

## PoC

**Prerequisites:** AVideo instance with CDN plugin enabled and key not configured (default state after ena