diff --git a/app/Livewire/Storage/Form.php b/app/Livewire/Storage/Form.php index 330aabaa4..807bef0d4 100644 --- a/app/Livewire/Storage/Form.php +++ b/app/Livewire/Storage/Form.php @@ -44,7 +44,7 @@ class Form extends Component 'secret' => 'required|max:255', 'bucket' => 'required|max:255', 'endpoint' => 'required|url|max:255', - 'path' => 'nullable|max:255|regex:/^[a-zA-Z0-9\/\-_\.]*$/', + 'path' => ['nullable', 'max:255', 'regex:/^[a-zA-Z0-9\/\-_\.]*$/', 'not_regex:/\.\./'], ]; } @@ -68,6 +68,7 @@ class Form extends Component 'endpoint.max' => 'The Endpoint may not be greater than 255 characters.', 'path.max' => 'The Path Prefix may not be greater than 255 characters.', 'path.regex' => 'The Path Prefix may only contain letters, numbers, slashes (/), dashes (-), underscores (_), and dots (.).', + 'path.not_regex' => 'The Path Prefix may not contain directory traversal sequences (..).', ] ); } diff --git a/bootstrap/helpers/databases.php b/bootstrap/helpers/databases.php index 77b5c5f5b..1d22c364b 100644 --- a/bootstrap/helpers/databases.php +++ b/bootstrap/helpers/databases.php @@ -213,7 +213,7 @@ function deleteBackupsS3(string|array|null $filenames, S3Storage $s3): void if (filled($s3->path)) { $pathPrefix = ltrim($s3->path, '/'); $filenames = array_map(function ($filename) use ($pathPrefix) { - // The filename is the local path (e.g., /var/lib/coolify/backups/databases/...) + // The filename is the backup path (e.g., /data/coolify/backups/databases/...) // We need to prepend the path prefix to match the S3 key structure $cleanFilename = ltrim($filename, '/'); diff --git a/resources/views/livewire/storage/form.blade.php b/resources/views/livewire/storage/form.blade.php index 6278adf93..146c272e3 100644 --- a/resources/views/livewire/storage/form.blade.php +++ b/resources/views/livewire/storage/form.blade.php @@ -42,8 +42,8 @@