fix: Wurzelordner schützen und SVG-Vorschau absichern
- move, delete und permissions lehnen einen konfigurierten Root (z. B. /mnt/user) in job.php und erneut im Worker ab. - preview.php?raw=1 sendet für SVG eine Sandbox-CSP, damit eingebettete Skripte nicht im WebGUI-Origin laufen. - Job-Verzeichnis wird mit 0700 angelegt bzw. korrigiert. - Paket 2026.11.21.r001. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4afacca2fb
commit
017ed6489a
7 files changed
+39
-4
No files matched your search
+1
-1
@@ -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"
|
||||
|
||||
Binary file not shown.
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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'])) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE PLUGIN [
|
||||
<!ENTITY name "u-navigator">
|
||||
<!ENTITY author "Michael Roll">
|
||||
<!ENTITY version "2026.09.12.r002">
|
||||
<!ENTITY version "2026.11.21.r001">
|
||||
<!ENTITY package "&name;-&version;.tgz">
|
||||
<!ENTITY pluginURL "https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/u-navigator.plg">
|
||||
<!ENTITY support "https://git.casaderoll.de/michael/Unraid-Navigator">
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
<FILE Name="/boot/config/plugins/&name;/&package;">
|
||||
<URL>https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/packages/&package;</URL>
|
||||
<MD5>97ee8d18a7eee6b3b1da1fa7451d5553</MD5>
|
||||
<MD5>c80bc2fddc79f1fd954f856809f877f8</MD5>
|
||||
</FILE>
|
||||
|
||||
<FILE Run="/bin/bash">
|
||||
|
||||
Reference in new issue
Block a user