From e906d65c9b46fde8ccd2a806d63244bdaa996477 Mon Sep 17 00:00:00 2001 From: YvesCesar Date: Fri, 13 Nov 2026 20:12:09 -0400 Subject: [PATCH] fix(security): hide dotfiles and dependency manifests inside app directories Signed-off-by: YvesCesar --- .docker/nginx/config/nextcloud.conf | 1 + tests/proxy/compose-policy.bats | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.docker/nginx/config/nextcloud.conf b/.docker/nginx/config/nextcloud.conf index 1476601d..cd90fe3b 100644 --- a/.docker/nginx/config/nextcloud.conf +++ b/.docker/nginx/config/nextcloud.conf @@ -153,6 +153,7 @@ server { # Hide metadata files which would otherwise be served as plain files and # leak dependency information (composer.json, package.json, core/shipped.json). location ~ ^/(?:composer\.(?:json|lock)|package(?:-lock)?\.json|core/shipped\.json)$ { return 404; } + location ~ ^/(?:apps|apps-extra|apps-writable)/[^/]+/(?:\.|composer\.(?:json|lock)$|package(?:-lock)?\.json$) { return 404; } # Pass PHP requests to PHP-FPM. # diff --git a/tests/proxy/compose-policy.bats b/tests/proxy/compose-policy.bats index a5d151aa..f3a0d626 100644 --- a/tests/proxy/compose-policy.bats +++ b/tests/proxy/compose-policy.bats @@ -81,3 +81,7 @@ setup() { done < <(grep -E '^[[:space:]]*-?[[:space:]]*uses:[[:space:]]+[^./][^[:space:]]+@' "$workflow" || true) done < <(find "$REPO_ROOT/.github/workflows" -type f \( -name '*.yml' -o -name '*.yaml' \)) } + +@test "nginx hides dotfiles and dependency manifests inside app directories" { + grep -Fxq ' location ~ ^/(?:apps|apps-extra|apps-writable)/[^/]+/(?:\.|composer\.(?:json|lock)$|package(?:-lock)?\.json$) { return 404; }' "$REPO_ROOT/.docker/nginx/config/nextcloud.conf" +}