From 0d047d79c2d7bd73022df3d65af54ed2cdf6fc2f Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Tue, 24 Nov 2026 08:01:41 -0600 Subject: [PATCH] deny admin-only media to viewer The media auth check allowed any role without a camera list before it looked at admin-only paths, so viewer could list and download the face library, classification train and dataset images, and GenAI request frames from /clips/ even though the matching API routes and UI pages are admin-only. Admin-only paths are now denied to every non-admin role before that check. --- frigate/api/media_auth.py | 4 +++- frigate/test/test_media_auth.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/frigate/api/media_auth.py b/frigate/api/media_auth.py index 49a3e6f8f9..442b4d9087 100644 --- a/frigate/api/media_auth.py +++ b/frigate/api/media_auth.py @@ -311,6 +311,9 @@ def deny_response_for_media_uri( if not role or role == "admin": return None + if resolution == MediaAuthResolution.ADMIN_ONLY: + return 403 + if not is_role_restricted(role, frigate_config): return None @@ -319,7 +322,6 @@ def deny_response_for_media_uri( if resolution in ( MediaAuthResolution.LISTING_MULTI_CAMERA, - MediaAuthResolution.ADMIN_ONLY, MediaAuthResolution.UNRESOLVED_MEDIA, ): return 403 diff --git a/frigate/test/test_media_auth.py b/frigate/test/test_media_auth.py index 98a84a74c9..c47cd1e156 100644 --- a/frigate/test/test_media_auth.py +++ b/frigate/test/test_media_auth.py @@ -332,6 +332,18 @@ class TestDenyResponseForMediaUri(unittest.TestCase): self.assertIsNone(self._deny("/clips/back_door-1.jpg", "viewer")) self.assertIsNone(self._deny("/clips/", "viewer")) + def test_unrestricted_role_blocked_admin_only(self): + for uri in ( + "/clips/faces/", + "/clips/faces/train/foo.webp", + "/clips/faces/alice/ref.webp", + "/clips/genai-requests/x/0.jpg", + "/clips/preview_restart_cache/x.mp4", + "/clips/some_model/train/x.jpg", + "/clips/some_model/dataset/cat/x.jpg", + ): + self.assertEqual(self._deny(uri, "viewer"), 403, uri) + def test_restricted_role_allowed_camera(self): self.assertIsNone(self._deny("/clips/front_door-1.jpg", "limited_user")) self.assertIsNone(