api(remote): fix use of missing node_id field

Fixes #5088
This commit is contained in:
Matthew Penner 2024-05-04 16:06:13 -06:00
parent b7b2413f3d
commit 7bfc265a7e
No known key found for this signature in database
2 changed files with 21 additions and 7 deletions

View file

@ -36,10 +36,17 @@ class BackupStatusController extends Controller
/** @var \Pterodactyl\Models\Backup $model */
$model = Backup::query()
->where('node_id', $node->id)
->where('uuid', $backup)
->firstOrFail();
// Check that the backup is "owned" by the node making the request. This avoids other nodes
// from messing with backups that they don't own.
/** @var \Pterodactyl\Models\Server $server */
$server = $model->server;
if ($server->node_id !== $node->id) {
throw new HttpForbiddenException('You do not have permission to access that backup.');
}
if ($model->is_successful) {
throw new BadRequestHttpException('Cannot update the status of a backup that is already marked as completed.');
}