diff --git a/build-plugin.sh b/build-plugin.sh index 2a6d061..b1446dc 100755 --- a/build-plugin.sh +++ b/build-plugin.sh @@ -5,7 +5,7 @@ set -eu export COPYFILE_DISABLE=1 PLUGIN="u-navigator" -VERSION="2026.09.12.r002" +VERSION="2026.11.21.r001" PKG_DIR="packages" WORK_DIR=".plugin-build" PKG_NAME="${PLUGIN}-${VERSION}.tgz" diff --git a/packages/u-navigator-2026.11.21.r001.tgz b/packages/u-navigator-2026.11.21.r001.tgz new file mode 100644 index 0000000..62581b4 Binary files /dev/null and b/packages/u-navigator-2026.11.21.r001.tgz differ diff --git a/plugin-root/usr/local/emhttp/plugins/u-navigator/api/common.php b/plugin-root/usr/local/emhttp/plugins/u-navigator/api/common.php index ea1fde8..a60c923 100644 --- a/plugin-root/usr/local/emhttp/plugins/u-navigator/api/common.php +++ b/plugin-root/usr/local/emhttp/plugins/u-navigator/api/common.php @@ -98,6 +98,22 @@ function unav_is_inside(string $path, string $root): bool { return str_starts_with($path, rtrim($root, '/') . '/'); } +function unav_is_root(string $real): bool { + foreach (unav_roots() as $root) { + if (rtrim($real, '/') === rtrim($root['path'], '/')) { + return true; + } + } + return false; +} + +// Destructive operations must never act on a configured root itself (e.g. /mnt/user). +function unav_assert_not_root(string $real): void { + if (unav_is_root($real)) { + unav_error(403, 'Root folders cannot be moved, deleted or changed'); + } +} + function unav_root_for_real(string $real): array { foreach (unav_roots() as $root) { if (unav_is_inside($real, $root['path'])) { @@ -239,9 +255,11 @@ function unav_permission_options(array $data): array { } function unav_job_dir(): string { - if (!is_dir(UNAV_JOB_DIR) && !mkdir(UNAV_JOB_DIR, 0777, true) && !is_dir(UNAV_JOB_DIR)) { + if (!is_dir(UNAV_JOB_DIR) && !mkdir(UNAV_JOB_DIR, 0700, true) && !is_dir(UNAV_JOB_DIR)) { unav_error(500, 'Could not create job directory'); } + // Job files drive a root worker: keep them private, also for directories created by older versions. + @chmod(UNAV_JOB_DIR, 0700); return UNAV_JOB_DIR; } diff --git a/plugin-root/usr/local/emhttp/plugins/u-navigator/api/job.php b/plugin-root/usr/local/emhttp/plugins/u-navigator/api/job.php index b328ea0..ee83e83 100644 --- a/plugin-root/usr/local/emhttp/plugins/u-navigator/api/job.php +++ b/plugin-root/usr/local/emhttp/plugins/u-navigator/api/job.php @@ -14,6 +14,9 @@ $data = unav_request_data(); $source = unav_existing_path($data['source'] ?? null); $destination = null; $permissions = null; +if (in_array($action, ['move', 'delete', 'permissions'], true)) { + unav_assert_not_root($source['path']); +} if (in_array($action, ['move', 'copy'], true)) { unav_assert_writable(); $destination = unav_destination_path($data['destination'] ?? null); diff --git a/plugin-root/usr/local/emhttp/plugins/u-navigator/api/job_worker.php b/plugin-root/usr/local/emhttp/plugins/u-navigator/api/job_worker.php index 17b13fe..3002c51 100644 --- a/plugin-root/usr/local/emhttp/plugins/u-navigator/api/job_worker.php +++ b/plugin-root/usr/local/emhttp/plugins/u-navigator/api/job_worker.php @@ -10,6 +10,9 @@ function unav_run_job(string $id): void { try { unav_worker_update($job, 'running', 5, 'Preparing'); + if (in_array($job['type'], ['move', 'delete', 'permissions'], true)) { + unav_worker_assert_not_root($job['source']); + } if ($job['type'] === 'move') { unav_worker_guard($job['source'], $job['destination']); unav_worker_move($job['source'], $job['destination'], $job); @@ -74,6 +77,13 @@ function unav_worker_guard_source(string $source): string { return $sourceReal; } +function unav_worker_assert_not_root(string $path): void { + $real = realpath($path); + if ($real !== false && unav_is_root($real)) { + throw new RuntimeException('Root folders cannot be moved, deleted or changed'); + } +} + function unav_worker_assert_inside_root(string $path): void { foreach (unav_roots() as $root) { if (unav_is_inside($path, $root['path'])) { diff --git a/plugin-root/usr/local/emhttp/plugins/u-navigator/api/preview.php b/plugin-root/usr/local/emhttp/plugins/u-navigator/api/preview.php index 7a035d4..eba0afb 100644 --- a/plugin-root/usr/local/emhttp/plugins/u-navigator/api/preview.php +++ b/plugin-root/usr/local/emhttp/plugins/u-navigator/api/preview.php @@ -87,6 +87,10 @@ if (($_GET['raw'] ?? '') === '1') { header('Content-Type: ' . $mime); header('Content-Length: ' . $size); header('X-Content-Type-Options: nosniff'); + if ($extension === 'svg') { + // Raw files are served from the WebGUI origin; scripts inside an SVG must not run there. + header("Content-Security-Policy: sandbox; default-src 'none'; img-src data:; style-src 'unsafe-inline'"); + } readfile($resolved['path']); exit; } diff --git a/u-navigator.plg b/u-navigator.plg index 6b79a19..011713b 100644 --- a/u-navigator.plg +++ b/u-navigator.plg @@ -1,7 +1,7 @@ - + @@ -24,7 +24,7 @@ https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/packages/&package; -97ee8d18a7eee6b3b1da1fa7451d5553 +c80bc2fddc79f1fd954f856809f877f8