diff --git a/app/url_guard.py b/app/url_guard.py index d4b91ee..8d59f86 100644 --- a/app/url_guard.py +++ b/app/url_guard.py @@ -13,8 +13,18 @@ This module provides two layers: covers redirects, DNS rebinding, and media URLs yt-dlp derives from remote metadata — for any backend that resolves through Python's socket module. -Native resolvers (curl_cffi/libcurl via ``--impersonate``) bypass the socket -guard; network isolation (e.g. Docker) remains the backstop for those. +Known limitations — network isolation (e.g. Docker) remains the backstop for +all of these: + +* The socket guard is installed only in the download subprocess. Metadata + extraction (``ytdl.DownloadQueue.__extract_info``) runs in the main process, + where installing a process-wide guard would reject the server's own bind on + ``HOST=0.0.0.0``. So extraction — which also follows redirects — is covered + only by ``validate_url`` at ingress, not at connect time; a redirect from an + allowed host to an internal one during extraction is not blocked (a lower- + impact, blind SSRF, since the extraction response is not written to disk). +* Native resolvers (curl_cffi/libcurl via ``--impersonate``) resolve outside + Python's socket module and bypass the connect-time guard entirely. """ import ipaddress diff --git a/app/ytdl.py b/app/ytdl.py index dc485fc..20cf2da 100644 --- a/app/ytdl.py +++ b/app/ytdl.py @@ -1269,6 +1269,11 @@ class DownloadQueue: return opts def __extract_info(self, url, ytdl_options_presets=None, ytdl_options_overrides=None): + # NOTE: extraction runs in the main process, so the connect-time socket + # guard (installed only in the download subprocess) does not apply here. + # The ingress validate_url check guards the submitted URL, but redirects + # followed during extraction are not re-validated. See url_guard's module + # docstring for why the guard can't be installed process-wide. debug_logging = logging.getLogger().isEnabledFor(logging.DEBUG) user_opts = self._build_ytdl_options(ytdl_options_presets, ytdl_options_overrides) params = {