From 619e03ab320848a53e181af7fac2fc61c2831b8b Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Fri, 5 Jun 2026 17:34:30 -0400 Subject: [PATCH] fix: stop serving private user assets via unauthenticated nginx static route The default Docker image symlinked /romm/assets into the nginx static web root (/assets/romm/assets), where it was served by an unauthenticated `location /assets { try_files ... }` block. /romm/assets holds private user data (save files, save states, screenshots, avatars) that is meant to be accessible only through the authenticated /api/raw/assets/{path} route (Scope.ASSETS_READ). The static symlink bypassed that protection, letting any unauthenticated caller read another user's files given a (guessable) path. Avatar URLs leaked the hex user ID through the same static route, making path construction straightforward. Fix: - Drop the /romm/assets symlink from the Docker image build and both entrypoint scripts; only /romm/resources (public cover art, screenshots, manuals) remains statically served. - Point the frontend avatar URLs at the authenticated /api/raw/assets/ route instead of /assets/romm/assets/. Browser loads authenticate via the existing session cookie. Co-Authored-By: Claude Opus 4.8 (1M context) --- docker/Dockerfile | 3 +-- docker/init_scripts/docker-entrypoint.sh | 19 +++++++-------- entrypoint.sh | 24 +++++++++---------- .../Users/Dialog/DeleteUser.vue | 2 +- .../Administration/Users/Dialog/EditUser.vue | 2 +- .../Administration/Users/UsersTable.vue | 2 +- .../common/Navigation/SettingsDrawer.vue | 2 +- .../components/common/Navigation/UserBtn.vue | 2 +- frontend/src/views/Settings/UserProfile.vue | 2 +- 9 files changed, 27 insertions(+), 31 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1571e0a46..60496e400 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -181,8 +181,7 @@ COPY --from=frontend-build /front/dist ${WEBSERVER_FOLDER} COPY ./frontend/assets ${WEBSERVER_FOLDER}/assets RUN mkdir -p ${WEBSERVER_FOLDER}/assets/romm && \ - ln -sf /romm/resources ${WEBSERVER_FOLDER}/assets/romm/resources && \ - ln -sf /romm/assets ${WEBSERVER_FOLDER}/assets/romm/assets + ln -sf /romm/resources ${WEBSERVER_FOLDER}/assets/romm/resources COPY ./backend /backend # Setup init script and config files diff --git a/docker/init_scripts/docker-entrypoint.sh b/docker/init_scripts/docker-entrypoint.sh index 5392c7b38..1b86987df 100755 --- a/docker/init_scripts/docker-entrypoint.sh +++ b/docker/init_scripts/docker-entrypoint.sh @@ -61,18 +61,17 @@ fi # Replace environment variables used in nginx configuration templates. /docker-entrypoint.d/20-envsubst-on-templates.sh >/dev/null -# Fix symbolic links used by nginx for assets, if they do not point to the correct location, +# Fix symbolic links used by nginx for resources, +# if they don't point to the correct location, # set by the ROMM_BASE_PATH environment variable. -for subfolder in assets resources; do - if [[ -L /var/www/html/assets/romm/${subfolder} ]]; then - target=$(readlink "/var/www/html/assets/romm/${subfolder}") +if [[ -L /var/www/html/assets/romm/resources ]]; then + target=$(readlink "/var/www/html/assets/romm/resources") - # If the target is not the same as ${ROMM_BASE_PATH}/${subfolder}, recreate the symbolic link. - if [[ ${target} != "${ROMM_BASE_PATH}/${subfolder}" ]]; then - rm "/var/www/html/assets/romm/${subfolder}" - ln -s "${ROMM_BASE_PATH}/${subfolder}" "/var/www/html/assets/romm/${subfolder}" - fi + # If the target is not the same as ${ROMM_BASE_PATH}/resources, recreate the symbolic link. + if [[ ${target} != "${ROMM_BASE_PATH}/resources" ]]; then + rm "/var/www/html/assets/romm/resources" + ln -s "${ROMM_BASE_PATH}/resources" "/var/www/html/assets/romm/resources" fi -done +fi exec "$@" diff --git a/entrypoint.sh b/entrypoint.sh index 33e77dc2c..6c581a395 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,21 +5,19 @@ set -e echo "Starting entrypoint script..." # Create symlinks for frontend -for subfolder in assets resources; do - if [[ -L /app/frontend/assets/romm/${subfolder} ]]; then - target=$(readlink "/app/frontend/assets/romm/${subfolder}") +if [[ -L /app/frontend/assets/romm/resources ]]; then + target=$(readlink "/app/frontend/assets/romm/resources") - # If the target is not the same as ${ROMM_BASE_PATH}/${subfolder}, recreate the symbolic link. - if [[ ${target} != "${ROMM_BASE_PATH}/${subfolder}" ]]; then - rm "/app/frontend/assets/romm/${subfolder}" - ln -s "${ROMM_BASE_PATH}/${subfolder}" "/app/frontend/assets/romm/${subfolder}" - fi - elif [[ ! -e /app/frontend/assets/romm/${subfolder} ]]; then - # Ensure parent directory exists before creating symbolic link - mkdir -p "/app/frontend/assets/romm" - ln -s "${ROMM_BASE_PATH}/${subfolder}" "/app/frontend/assets/romm/${subfolder}" + # If the target is not the same as ${ROMM_BASE_PATH}/resources, recreate the symbolic link. + if [[ ${target} != "${ROMM_BASE_PATH}/resources" ]]; then + rm "/app/frontend/assets/romm/resources" + ln -s "${ROMM_BASE_PATH}/resources" "/app/frontend/assets/romm/resources" fi -done +elif [[ ! -e /app/frontend/assets/romm/resources ]]; then + # Ensure parent directory exists before creating symbolic link + mkdir -p "/app/frontend/assets/romm" + ln -s "${ROMM_BASE_PATH}/resources" "/app/frontend/assets/romm/resources" +fi # Define a signal handler to propagate termination signals function handle_termination() { diff --git a/frontend/src/components/Settings/Administration/Users/Dialog/DeleteUser.vue b/frontend/src/components/Settings/Administration/Users/Dialog/DeleteUser.vue index fa94524a6..9414131c2 100644 --- a/frontend/src/components/Settings/Administration/Users/Dialog/DeleteUser.vue +++ b/frontend/src/components/Settings/Administration/Users/Dialog/DeleteUser.vue @@ -65,7 +65,7 @@ function closeDialog() { diff --git a/frontend/src/components/Settings/Administration/Users/UsersTable.vue b/frontend/src/components/Settings/Administration/Users/UsersTable.vue index 295c2eb7a..a6360306f 100644 --- a/frontend/src/components/Settings/Administration/Users/UsersTable.vue +++ b/frontend/src/components/Settings/Administration/Users/UsersTable.vue @@ -136,7 +136,7 @@ onMounted(() => { diff --git a/frontend/src/components/common/Navigation/SettingsDrawer.vue b/frontend/src/components/common/Navigation/SettingsDrawer.vue index 5e11fcabd..4cfd51674 100644 --- a/frontend/src/components/common/Navigation/SettingsDrawer.vue +++ b/frontend/src/components/common/Navigation/SettingsDrawer.vue @@ -92,7 +92,7 @@ function onClose() { diff --git a/frontend/src/views/Settings/UserProfile.vue b/frontend/src/views/Settings/UserProfile.vue index 885a7bf16..b0764ffb6 100644 --- a/frontend/src/views/Settings/UserProfile.vue +++ b/frontend/src/views/Settings/UserProfile.vue @@ -92,7 +92,7 @@ onUnmounted(() => { :src=" imagePreviewUrl || (userToEdit.avatar_path - ? `/assets/romm/assets/${userToEdit.avatar_path}?ts=${userToEdit.updated_at}` + ? `/api/raw/assets/${userToEdit.avatar_path}?ts=${userToEdit.updated_at}` : defaultAvatarPath) " >