diff --git a/.gitea/workflows/nexjast-ci.yml b/.gitea/workflows/nexjast-ci.yml index 459ddab9..39efcc87 100644 --- a/.gitea/workflows/nexjast-ci.yml +++ b/.gitea/workflows/nexjast-ci.yml @@ -612,6 +612,10 @@ jobs: python3 tools/ci/verify_cross_region_chat.py dotnet run --configuration Release --project tools/ci/CrossRegionChatRegression/CrossRegionChatRegression.csproj + - name: Verify outgoing TLS certificate validation defaults (OGL-006) + shell: bash + run: dotnet run --configuration Release --project tools/ci/OglTlsVerificationRegression/OglTlsVerificationRegression.csproj + - name: Verify estate-wide LSL messaging shell: bash run: python3 tools/ci/verify_estate_say.py diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 484971c1..8b5d8643 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -88,8 +88,11 @@ namespace OpenSim.Framework.Servers m_osSecret = UUID.Random().ToString(); } - private static bool m_NoVerifyCertChain = true; - private static bool m_NoVerifyCertHostname = true; + // OGL-006: verify outgoing TLS certificates by default. Operators can + // still opt out per installation via [Startup] NoVerifyCertChain / + // NoVerifyCertHostname for peers with self-signed certificates. + private static bool m_NoVerifyCertChain = false; + private static bool m_NoVerifyCertHostname = false; public static bool ValidateServerCertificate( object sender, diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpListener.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpListener.cs index 4be06324..5c01852e 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpListener.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpListener.cs @@ -17,7 +17,7 @@ namespace OSHttpServer private readonly IHttpContextFactory m_contextFactory; private readonly int m_port; private readonly ManualResetEvent m_shutdownEvent = new(false); - private readonly SslProtocols m_sslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13; + private readonly SslProtocols m_sslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13; private TcpListener m_listener; private ILogWriter m_logWriter = NullLogWriter.Instance; diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 744e732e..6b4277d1 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -125,7 +125,7 @@ namespace OpenSim.Framework PooledConnectionLifetime = TimeSpan.FromMinutes(3) }; //shh.SslOptions.ClientCertificates = null, - shh.SslOptions.EnabledSslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13; + shh.SslOptions.EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13; if (NoVerifyCertChain) { shh.SslOptions.CertificateRevocationCheckMode = X509RevocationMode.NoCheck; @@ -191,7 +191,7 @@ namespace OpenSim.Framework PooledConnectionLifetime = TimeSpan.FromMinutes(3) }; //shh.SslOptions.ClientCertificates = null, - shh.SslOptions.EnabledSslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13; + shh.SslOptions.EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13; if (NoVerifyCertChain) { shh.SslOptions.CertificateRevocationCheckMode = X509RevocationMode.NoCheck; diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index a8d992e7..66a7fabb 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -155,7 +155,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest PooledConnectionLifetime = TimeSpan.FromMinutes(3) }; //shhnc.SslOptions.ClientCertificates = null, - shhnc.SslOptions.EnabledSslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13; + shhnc.SslOptions.EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13; shhnc.SslOptions.CertificateRevocationCheckMode = X509RevocationMode.NoCheck; shhnc.SslOptions.RemoteCertificateValidationCallback = (message, cert, chain, errors) => { @@ -192,7 +192,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest PooledConnectionLifetime = TimeSpan.FromMinutes(3) }; //shhnc.SslOptions.ClientCertificates = null, - shh.SslOptions.EnabledSslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13; + shh.SslOptions.EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13; shh.SslOptions.CertificateRevocationCheckMode = X509RevocationMode.NoCheck; shh.SslOptions.RemoteCertificateValidationCallback = (message, cert, chain, errors) => { diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 915e65d3..77f4c154 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -523,13 +523,12 @@ ; # SSL certificates validation options ; # - ; SSL certificate validation options - ; you can allow selfsigned certificates or no official CA with next option set to true - ; NoVerifyCertChain = true - ; you can also bypass the hostname or domain verification - ; NoVerifyCertHostname = true - ; having both options true does provide encryption but with low security - ; set both true if you don't care to use SSL, they are needed to contact regions or grids that do use it. + ; Outgoing HTTPS certificate validation (OGL-006). Default: verify (false). + ; Only set these to true for a peer grid with a self-signed or private-CA + ; certificate. true accepts forged certificates (man-in-the-middle). + ; Plain http:// grid and Hypergrid URIs are not affected by these options. + ; NoVerifyCertChain = false + ; NoVerifyCertHostname = false [Map] ; Warp3D diagnostic PNGs are optional, but legacy behavior remains diff --git a/bin/Robust.HG.OGLAsset.ini.example b/bin/Robust.HG.OGLAsset.ini.example index 17a5d0cf..b7eed341 100644 --- a/bin/Robust.HG.OGLAsset.ini.example +++ b/bin/Robust.HG.OGLAsset.ini.example @@ -133,13 +133,12 @@ ; The certificate host IP. RobustCertHostIp = "127.0.0.1" - ; peers SSL certificate validation options - ; you can allow selfsigned certificates or no official CA with next option set to true - NoVerifyCertChain = true - ; you can also bypass the hostname or domain verification - NoVerifyCertHostname = true - ; having both options true does provide encryption but with low security - ; set both true if you don't care to use SSL, they are needed to contact regions or grids that do use it. + ; Outgoing HTTPS certificate validation (OGL-006). Default: verify. + ; Only set these to true for a peer grid with a self-signed or private-CA + ; certificate. true accepts forged certificates (man-in-the-middle). + ; Plain http:// grid and Hypergrid URIs are not affected by these options. + NoVerifyCertChain = false + NoVerifyCertHostname = false [ServiceList] diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index 23f68b38..15d72858 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example @@ -114,13 +114,12 @@ ; The certificate host IP. RobustCertHostIp = "127.0.0.1" - ; peers SSL certificate validation options - ; you can allow selfsigned certificates or no official CA with next option set to true - NoVerifyCertChain = true - ; you can also bypass the hostname or domain verification - NoVerifyCertHostname = true - ; having both options true does provide encryption but with low security - ; set both true if you don't care to use SSL, they are needed to contact regions or grids that do use it. + ; Outgoing HTTPS certificate validation (OGL-006). Default: verify. + ; Only set these to true for a peer grid with a self-signed or private-CA + ; certificate. true accepts forged certificates (man-in-the-middle). + ; Plain http:// grid and Hypergrid URIs are not affected by these options. + NoVerifyCertChain = false + NoVerifyCertHostname = false [ServiceList] diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index 58baf81b..0f17fd03 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example @@ -93,13 +93,12 @@ ; The certificate host IP. RobustCertHostIp = "127.0.0.1" - ; peers SSL certificate validation options - ; you can allow selfsigned certificates or no official CA with next option set to true - NoVerifyCertChain = true - ; you can also bypass the hostname or domain verification - NoVerifyCertHostname = true - ; having both options true does provide encryption but with low security - ; set both true if you don't care to use SSL, they are needed to contact regions or grids that do use it. + ; Outgoing HTTPS certificate validation (OGL-006). Default: verify. + ; Only set these to true for a peer grid with a self-signed or private-CA + ; certificate. true accepts forged certificates (man-in-the-middle). + ; Plain http:// grid and Hypergrid URIs are not affected by these options. + NoVerifyCertChain = false + NoVerifyCertHostname = false [ServiceList] AssetServiceConnector = "${Const|PrivatePort}/OpenSim.Server.Handlers.dll:AssetServiceConnector" diff --git a/doc/NexVerse/BUGLISTE_TECHNISCHES_AUDIT_2026-10-25.md b/doc/NexVerse/BUGLISTE_TECHNISCHES_AUDIT_2026-10-25.md index 44d300ad..6d20771f 100644 --- a/doc/NexVerse/BUGLISTE_TECHNISCHES_AUDIT_2026-10-25.md +++ b/doc/NexVerse/BUGLISTE_TECHNISCHES_AUDIT_2026-10-25.md @@ -50,11 +50,12 @@ Diese Liste ist Bestandteil der [Roadmap](ROADMAP.md). IDs sind stabil und solle ### OGL-006 · Server-Basispfad ignoriert TLS-Zertifikatsfehler standardmäßig -- **Status:** offen · **Priorität:** P1 · **Kategorie:** Konfigurationsrisiko +- **Status:** im Code behoben (2026-12-03), Staging-Abnahme offen · **Priorität:** P1 · **Kategorie:** Konfigurationsrisiko - **Fundstelle:** [`OpenSim/Framework/Servers/BaseOpenSimServer.cs`](https://github.com/opengenesislink/opengenesislinkserver/blob/main/OpenSim/Framework/Servers/BaseOpenSimServer.cs#L87-L121) - **Befund:** NoVerifyCertChain/Hostname starten mit true und beeinflussen globale HTTPS-Zertifikatsprüfungen. ROBUST-ServerMain besitzt separate Defaults. - **Maßnahme:** Sichere Defaults, explizite Ausnahmen und HTTPS-Tests gegen falsche, abgelaufene oder nicht vertrauenswürdige Zertifikate. - **Abnahmekriterium:** reproduzierbarer Regressionstest (inkl. Negativfällen) und dokumentierte Prüfung im geeigneten Staging; kein unkontrollierter Produktiv-Cutover. +- **Umsetzung:** `BaseOpenSimServer` verifiziert standardmäßig (ROBUST tat das bereits); Beispiel-Configs auf `false`; ausgehendes TLS nur noch 1.2/1.3. Regressionstest `tools/ci/OglTlsVerificationRegression` (14 Prüfungen: Defaults, Protokolle, selbstsigniert abgelehnt, falscher Hostname abgelehnt, expliziter Opt-out). Bestehende Installationen mit `NoVerifyCertChain = true` in ihrer aktiven INI behalten ihr Verhalten bis zur manuellen Umstellung. ### OGL-007 · PBR-Materialaktualisierung nicht atomar diff --git a/tools/ci/OglTlsVerificationRegression/OglTlsVerificationRegression.csproj b/tools/ci/OglTlsVerificationRegression/OglTlsVerificationRegression.csproj new file mode 100644 index 00000000..780a2f45 --- /dev/null +++ b/tools/ci/OglTlsVerificationRegression/OglTlsVerificationRegression.csproj @@ -0,0 +1,30 @@ + + + Exe + net10.0 + disable + disable + false + + + + + + + ../../../bin/OpenMetaverse.dll + + + ../../../bin/OpenMetaverseTypes.dll + + + ../../../bin/log4net.dll + + + ../../../bin/Nini.dll + + + + + + + diff --git a/tools/ci/OglTlsVerificationRegression/Program.cs b/tools/ci/OglTlsVerificationRegression/Program.cs new file mode 100644 index 00000000..5e064e0d --- /dev/null +++ b/tools/ci/OglTlsVerificationRegression/Program.cs @@ -0,0 +1,194 @@ +// OGL-006 regression: outgoing HTTPS from the simulator/ROBUST HTTP clients +// must verify certificates by default and must not offer TLS < 1.2. +// Runs fully offline against in-process HTTPS endpoints with throwaway +// self-signed certificates; no network, database or grid config needed. +using System; +using System.IO; +using System.Net; +using System.Net.Http; +using System.Net.Security; +using System.Net.Sockets; +using System.Reflection; +using System.Security.Authentication; +using System.Security.Cryptography; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using OpenSim.Framework; +using OpenSim.Framework.Servers; + +internal static class Program +{ + private static int s_checks; + + private static void Check(bool condition, string message) + { + if (!condition) + throw new Exception("OGL-006 TLS verification regression: " + message); + s_checks++; + } + + private static X509Certificate2 SelfSigned(string hostName) + { + using RSA rsa = RSA.Create(2048); + var request = new CertificateRequest( + "CN=" + hostName, rsa, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1); + var san = new SubjectAlternativeNameBuilder(); + san.AddDnsName(hostName); + request.CertificateExtensions.Add(san.Build()); + request.CertificateExtensions.Add(new X509EnhancedKeyUsageExtension( + new OidCollection { new Oid("1.3.6.1.5.5.7.3.1") }, false)); + using X509Certificate2 cert = request.CreateSelfSigned( + DateTimeOffset.UtcNow.AddMinutes(-5), DateTimeOffset.UtcNow.AddHours(1)); + // Re-import so SslStream on Linux gets a usable private key. + return X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pkcs12), null); + } + + // Minimal one-shot HTTPS endpoint: accepts connections until stopped and + // answers every request with 200 "ok". + private sealed class HttpsEndpoint : IDisposable + { + private readonly TcpListener m_listener = new(IPAddress.Loopback, 0); + private readonly X509Certificate2 m_cert; + private readonly CancellationTokenSource m_stop = new(); + public int Port { get; } + + public HttpsEndpoint(X509Certificate2 cert) + { + m_cert = cert; + m_listener.Start(); + Port = ((IPEndPoint)m_listener.LocalEndpoint).Port; + _ = Task.Run(AcceptLoop); + } + + private async Task AcceptLoop() + { + while (!m_stop.IsCancellationRequested) + { + TcpClient client; + try { client = await m_listener.AcceptTcpClientAsync(m_stop.Token); } + catch { return; } + _ = Task.Run(() => Serve(client)); + } + } + + private async Task Serve(TcpClient client) + { + using (client) + { + try + { + using var ssl = new SslStream(client.GetStream(), false); + await ssl.AuthenticateAsServerAsync(new SslServerAuthenticationOptions + { + ServerCertificate = m_cert, + EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13, + }); + // Read the request head (until the blank line) before answering. + var head = new StringBuilder(); + var buffer = new byte[4096]; + while (!head.ToString().Contains("\r\n\r\n")) + { + int read = await ssl.ReadAsync(buffer); + if (read == 0) return; + head.Append(Encoding.ASCII.GetString(buffer, 0, read)); + } + byte[] response = Encoding.ASCII.GetBytes( + "HTTP/1.1 200 OK\r\nContent-Length: 2\r\nConnection: close\r\n\r\nok"); + await ssl.WriteAsync(response); + await ssl.FlushAsync(); + } + catch + { + // Expected when the client rejects our certificate. + } + } + } + + public void Dispose() + { + m_stop.Cancel(); + m_listener.Stop(); + m_cert.Dispose(); + } + } + + private static bool Fetch(int port, string host) + { + // Resolve the requested host name to loopback so SNI/hostname checks + // see the name while the request stays on this machine. + using var client = WebUtil.GetNewGlobalHttpClient(10000); + var request = new HttpRequestMessage(HttpMethod.Get, $"https://{host}:{port}/"); + try + { + using HttpResponseMessage response = client.Send(request); + return response.StatusCode == HttpStatusCode.OK; + } + catch (HttpRequestException e) when (e.InnerException is AuthenticationException) + { + return false; + } + } + + private static bool StaticDefault(Type type, string field) + { + FieldInfo info = type.GetField(field, BindingFlags.NonPublic | BindingFlags.Static); + Check(info != null, $"{type.Name}.{field} not found"); + return (bool)info.GetValue(null); + } + + public static int Main() + { + // 1. Secure defaults in the simulator base server (OGL-006 root cause). + Check(!StaticDefault(typeof(BaseOpenSimServer), "m_NoVerifyCertChain"), + "BaseOpenSimServer must verify the certificate chain by default"); + Check(!StaticDefault(typeof(BaseOpenSimServer), "m_NoVerifyCertHostname"), + "BaseOpenSimServer must verify the certificate host name by default"); + + // ROBUST (OpenSim/Server/ServerMain.cs) is an executable that needs + // NuGet packages; guard its defaults at source level instead. + string root = AppContext.BaseDirectory; + while (root != null && !File.Exists(Path.Combine(root, "OpenSim.sln"))) + root = Path.GetDirectoryName(root); + Check(root != null, "repository root not found"); + string serverMain = File.ReadAllText(Path.Combine(root, "OpenSim/Server/ServerMain.cs")); + Check(serverMain.Contains("private static bool m_NoVerifyCertChain = false;") + && serverMain.Contains("private static bool m_NoVerifyCertHostname = false;"), + "ROBUST ServerMain must verify certificates by default"); + + // 2. Protocol floor: shared clients must not offer TLS 1.0/1.1. + WebUtil.SetupHTTPClients(false, false, null, 4); + foreach (var handler in new[] { WebUtil.SharedSocketsHttpHandler, WebUtil.SharedSocketsHttpHandlerNoRedir }) + { + SslProtocols p = handler.SslOptions.EnabledSslProtocols; +#pragma warning disable SYSLIB0039 // checking that the obsolete protocols are absent + Check((p & (SslProtocols.Tls | SslProtocols.Tls11)) == 0, $"TLS < 1.2 enabled: {p}"); +#pragma warning restore SYSLIB0039 + Check((p & SslProtocols.Tls12) != 0, $"TLS 1.2 missing: {p}"); + } + + using var trustedName = new HttpsEndpoint(SelfSigned("localhost")); + using var wrongName = new HttpsEndpoint(SelfSigned("not-this-host.invalid")); + + // 3. Default (verify everything): untrusted self-signed cert is rejected. + WebUtil.SetupHTTPClients(false, false, null, 4); + Check(!Fetch(trustedName.Port, "localhost"), + "default client accepted an untrusted self-signed certificate"); + + // 4. Opt-out of chain only: self-signed accepted, wrong host name rejected. + WebUtil.SetupHTTPClients(true, false, null, 4); + Check(Fetch(trustedName.Port, "localhost"), + "NoVerifyCertChain=true must accept a self-signed certificate for the right host"); + Check(!Fetch(wrongName.Port, "localhost"), + "NoVerifyCertHostname=false must reject a certificate for another host"); + + // 5. Explicit full opt-out keeps the documented legacy behaviour. + WebUtil.SetupHTTPClients(true, true, null, 4); + Check(Fetch(wrongName.Port, "localhost"), + "NoVerifyCertChain=true + NoVerifyCertHostname=true must keep accepting (explicit opt-out)"); + + Console.WriteLine($"OGL-006 outgoing TLS verification defaults: PASS ({s_checks} checks)"); + return 0; + } +}