don't trust live stream names as existing go2rtc streams

This commit is contained in:
Josh Hawkins
2026-11-07 12:50:09 -06:00
parent 40c27fb04f
commit f1e0a025c6
3 changed files with 34 additions and 2 deletions
+7 -1
View File
@@ -39,6 +39,7 @@ from frigate.config import AuthConfig, ProxyConfig
from frigate.const import CONFIG_DIR, JWT_SECRET_ENV_VAR, PASSWORD_HASH_ALGORITHM
from frigate.models import User
from frigate.notices import raise_notice
from frigate.util.live_streams import is_transcode_stream_name
from frigate.util.origin import origin_allowed
logger = logging.getLogger(__name__)
@@ -1282,7 +1283,12 @@ def _is_existing_go2rtc_stream(request: Request, stream_name: str) -> bool:
"""
frigate_config = request.app.frigate_config
if _get_stream_owner_cameras(request, stream_name):
# live.streams values are free-form config, so only names Frigate controls
# skip the lookup
if any(
stream_name == camera or is_transcode_stream_name(camera, stream_name)
for camera in frigate_config.cameras
):
return True
config_streams = getattr(frigate_config.go2rtc, "streams", None) or {}
@@ -280,6 +280,27 @@ class TestAuthInternalPort(BaseTestHttp):
)
self.assertEqual(resp.status_code, 202, url)
@patch(
"frigate.api.auth.requests.get",
side_effect=requests.ConnectionError("go2rtc unavailable"),
)
def test_live_stream_value_is_not_trusted_as_a_go2rtc_stream(self, _mock_get):
src = "ffmpeg:x#raw=-f"
self.minimal_config["cameras"]["front_door"]["live"] = {
"streams": {"Main": src}
}
app = self._create_app()
with AuthTestClient(app) as client:
resp = client.get(
"/auth",
headers={
"x-server-port": "5000",
"x-original-url": "/live/mse/api/ws?src=ffmpeg:x%23raw=-f",
},
)
self.assertEqual(resp.status_code, 403)
if __name__ == "__main__":
unittest.main(verbosity=2)
+6 -1
View File
@@ -23,7 +23,12 @@ _CONFIG = {
"dual_user": ["front_door", "back_door"],
}
},
"go2rtc": {"streams": {"doorbell_audio": ["rtsp://10.0.0.4:554/audio"]}},
"go2rtc": {
"streams": {
"doorbell_audio": ["rtsp://10.0.0.4:554/audio"],
"front_door_sub": ["rtsp://10.0.0.1:554/sub"],
}
},
"cameras": {
"front_door": {
"ffmpeg": {