Package: ocaml-cry Version: 0.6.7-1 Severity: grave Tags: security patch bookworm Justification: user security hole
Dear Maintainer, ocaml-cry 0.6.7 opens HTTPS connections with Ssl.open_connection_with_context but never checks the verification result nor sets the expected host, so any certificate is accepted for any server, including a self-signed one. Liquidsoap 2.1.3 in bookworm uses it for output.icecast(protocol="https", ...), so an attacker able to intercept or redirect the connection can capture the source password and stream. Advisory: https://www.liquidsoap.info/security/LSA-2026-001/ Only bookworm is affected: trixie and later ship ocaml-cry 1.0.x, which liquidsoap no longer uses for HTTPS. Attached is a patch against 0.6.7, with a DEP-3 header. It sets the expected host (SNI and Ssl.set_host, or Ssl.set_ip for a canonical IP literal) before the handshake and checks the verification result after it, closing the socket on failure. It builds against the ocaml-ssl in bookworm (0.5.13); we applied and compiled it against the Debian source package. Thanks, Romain Beauxis, Liquidsoap upstream
Description: https: verify the server certificate and its host Liquidsoap 2.0.x and 2.1.x connect to HTTPS servers through ocaml-cry, which neither checked the certificate verification result nor set the expected host, so any certificate was accepted for any server. Set the expected host (SNI and Ssl.set_host, or Ssl.set_ip for a canonical IP literal) before the handshake and check the verification result after it, closing the socket on failure. . Patch for ocaml-cry 0.6.7. Author: Romain Beauxis <[email protected]> Origin: other, https://www.liquidsoap.info/security/LSA-2026-001/ Bug: https://www.liquidsoap.info/security/LSA-2026-001/ Forwarded: not-needed Last-Update: 2026-12-05 --- --- a/src/cry_https.ssl.ml 2026-12-05 09:58:19 +++ b/src/cry_https.ssl.ml 2026-12-05 09:58:19 @@ -24,15 +24,40 @@ Ssl_threads.init (); Ssl.init () +let invalid_host host = failwith (Printf.sprintf "Invalid SSL server host: %S" host) + +(* Only canonical IP literals reach [Ssl.set_ip]: an address OpenSSL rejects + is silently ignored, which disables the identity check. *) +let set_peer_identity ssl host = + if host = "" || String.contains host '\000' then invalid_host host; + match Unix.inet_addr_of_string host with + | addr when Unix.string_of_inet_addr addr = host -> Ssl.set_ip ssl host + | _ -> invalid_host host + | exception Failure _ -> + Ssl.set_client_SNI_hostname ssl host; + Ssl.set_host ssl host + +let check_verify_result ssl = + let err = Ssl.get_verify_result ssl in + if err <> 0 then + failwith + (Printf.sprintf "SSL verification error: %s" + (Ssl.get_verify_error_string err)) + let register fn = - let connect_ssl ~host:_ socket = + let connect_ssl ~host socket = let ctx = Ssl.create_context Ssl.SSLv23 Ssl.Client_context in - (* SSL_VERIFY_NONE is default in shout. TODO: add option.. *) Ssl.set_verify ctx [] (Some Ssl.client_verify_callback); Ssl.set_verify_depth ctx 3; ignore (Ssl.set_default_verify_paths ctx); let ssl = Ssl.embed_socket socket ctx in - Ssl.connect ssl; + (try + set_peer_identity ssl host; + Ssl.connect ssl; + check_verify_result ssl + with e -> + (try Unix.close socket with _ -> ()); + raise e); let shutdown () = Ssl.shutdown ssl; Unix.close (Ssl.file_descr_of_socket ssl)

