Package: liquidsoap
Version: 2.4.6-1
Severity: grave
Tags: security patch upstream
Justification: user security hole

Dear Maintainer,

Liquidsoap's OpenSSL client transport, http.transport.ssl(), checks that
the server certificate chains to a trusted CA, but never sets the expected
host before the handshake. Any trusted certificate is therefore accepted
for any server. An attacker able to intercept or redirect the connection
(DNS spoofing, a hostile network) can pose as the streaming server and
capture the source password and stream sent with
output.icecast(transport=http.transport.ssl(), ...).

Advisory: https://www.liquidsoap.info/security/LSA-2026-001/
Upstream fix, released in 2.4.7 today:
https://github.com/savonet/liquidsoap/commit/c6b050492ce4b51fbe1def91d4204de8b68011f6

The version in trixie, 2.3.2-2, is affected as well.

Attached are patches against 2.4.6 (sid, forky) and 2.3.2 (trixie), with
DEP-3 headers. They only change the ssl transport, build against the
ocaml-ssl already in each suite (0.8.1 and 0.7.0), and need no other
change. We applied and compiled them against the Debian sources of each
suite.

The version in bookworm, 2.1.3, connects to HTTPS servers through ocaml-cry
and is affected through it; I am filing a separate bug against ocaml-cry.

Thanks,
Romain Beauxis, Liquidsoap upstream
Description: ssl: verify the server certificate matches the requested host
 http.transport.ssl() checked that the server certificate chains to a trusted
 CA, but never set the expected host, so any trusted certificate was accepted
 for any server. Set it with Ssl.set_host, or Ssl.set_ip for a canonical IP
 literal, before the handshake. Non-canonical IP literals, empty hosts and hosts
 containing NUL are refused: ocaml-ssl < 0.8.0 silently ignores an address
 OpenSSL rejects, which would disable the check.
 .
 Backport to Liquidsoap 2.4.6.
Author: Romain Beauxis <[email protected]>
Origin: upstream, https://github.com/savonet/liquidsoap/commit/c6b050492ce4b51fbe1def91d4204de8b68011f6
Bug: https://www.liquidsoap.info/security/LSA-2026-001/
Forwarded: not-needed
Last-Update: 2026-12-05
---
--- a/src/core/optionals/ssl/builtins_ssl.ml	2026-12-05 09:50:35
+++ b/src/core/optionals/ssl/builtins_ssl.ml	2026-12-05 09:50:35
@@ -119,6 +119,22 @@
         Unix.close s;
         Printexc.raise_with_backtrace exn bt
   end
+
+let invalid_peer_host host =
+  Runtime_error.raise ~pos:[]
+    ~message:(Printf.sprintf "Invalid SSL server host: %S" host)
+    "ssl"
+
+(* Only canonical IP literals reach [Ssl.set_ip]: ocaml-ssl < 0.8.0 ignores an
+   address OpenSSL rejects, which disables the identity check. *)
+let set_peer_identity socket host =
+  if host = "" || String.contains host '\000' then invalid_peer_host host;
+  match Unix.inet_addr_of_string host with
+    | addr when Unix.string_of_inet_addr addr = host -> Ssl.set_ip socket host
+    | _ -> invalid_peer_host host
+    | exception Failure _ ->
+        Ssl.set_client_SNI_hostname socket host;
+        Ssl.set_host socket host
 
 let transport ~min_protocol ~max_protocol ~read_timeout ~write_timeout ~password
     ~certificate ~key () =
@@ -153,7 +169,7 @@
         in
         try
           let socket = Ssl.embed_socket unix_socket ctx in
-          (try Ssl.set_client_SNI_hostname socket host with _ -> ());
+          set_peer_identity socket host;
           Ssl.connect socket;
           let err = Ssl.get_verify_result socket in
           if err <> 0 then
Description: ssl: verify the server certificate matches the requested host
 http.transport.ssl() checked that the server certificate chains to a trusted
 CA, but never set the expected host, so any trusted certificate was accepted
 for any server. Set it with Ssl.set_host, or Ssl.set_ip for a canonical IP
 literal, before the handshake. Non-canonical IP literals, empty hosts and hosts
 containing NUL are refused: ocaml-ssl < 0.8.0 silently ignores an address
 OpenSSL rejects, which would disable the check.
 .
 Backport to Liquidsoap 2.3.2.
Author: Romain Beauxis <[email protected]>
Origin: upstream, https://github.com/savonet/liquidsoap/commit/c6b050492ce4b51fbe1def91d4204de8b68011f6
Bug: https://www.liquidsoap.info/security/LSA-2026-001/
Forwarded: not-needed
Last-Update: 2026-12-05
---
--- a/src/core/builtins/builtins_ssl.ml	2026-12-05 09:50:35
+++ b/src/core/builtins/builtins_ssl.ml	2026-12-05 09:50:35
@@ -98,6 +98,22 @@
         Printexc.raise_with_backtrace exn bt
   end
 
+let invalid_peer_host host =
+  Runtime_error.raise ~pos:[]
+    ~message:(Printf.sprintf "Invalid SSL server host: %S" host)
+    "ssl"
+
+(* Only canonical IP literals reach [Ssl.set_ip]: ocaml-ssl < 0.8.0 ignores an
+   address OpenSSL rejects, which disables the identity check. *)
+let set_peer_identity socket host =
+  if host = "" || String.contains host '\000' then invalid_peer_host host;
+  match Unix.inet_addr_of_string host with
+    | addr when Unix.string_of_inet_addr addr = host -> Ssl.set_ip socket host
+    | _ -> invalid_peer_host host
+    | exception Failure _ ->
+        Ssl.set_client_SNI_hostname socket host;
+        Ssl.set_host socket host
+
 let transport ~min_protocol ~max_protocol ~read_timeout ~write_timeout ~password
     ~certificate ~key () =
   object (self)
@@ -131,7 +147,7 @@
         in
         try
           let socket = Ssl.embed_socket unix_socket ctx in
-          (try Ssl.set_client_SNI_hostname socket host with _ -> ());
+          set_peer_identity socket host;
           Ssl.connect socket;
           let err = Ssl.get_verify_result socket in
           if err <> 0 then

Reply via email to