Details
// Only accept the key argument from actual CLI invocations (intended usage:
// cron "php .../cloneClient.json.php <myKey>"). Over HTTP, require admin.
$cliKey = (PHP_SAPI === 'cli' && !empty($argv[1]))
? preg_replace("/[^A-Za-z0-9 ]/", '', $argv[1])
: '';
if (empty($objClone) || empty($cliKey) || $objClone->myKey !== $cliKey) {
if (!User::isAdmin()) {
$resp->msg = "You can't do this";
$log->add("Clone: {$resp->msg}");
// Do NOT echo $objClone->myKey — it is a shared secret used to
// authenticate to the configured remote clone server.
die(json_encode($resp));
}
}
Additional hardening recommended:
- Replace the static
myKey = md5(systemRootPath . salt)with a randomly generated, per-installation key stored in the plugin configuration that can be rotated (see similar advice from GHSA-wqcc-qf63-c2x4 / CWE-331 on AVideo secret generation). - On the remote side (
cloneServer.json.php), consider requiring thesqlFilepath to be unguessable (already is, viauniqid()) AND gating the dump behind an IP allowlist or an additional pre-shared rotating token, so that loss of a client'smyKeydoes not immediately yield a full database dump. - Serve
videos/clones/with an.htaccess/nginx rule that denies direct HTTP access, so that even if a rogue client is authenticated, the dump is not downloadable over the web.