fix(server): refuse planted Windows data, guard new archives, trust only loopback proxies
- Windows data folder: the folder and everything in it must belong to SYSTEM, Administrators or the server's account and hold no link, checked before the ACL is rewritten; otherwise the server stops and names the entry. server.json is read only after its owner is checked on the open handle. Secrets are deleted and created anew with the private ACL, so a planted file's owner loses its rights. - Windows archive: a folder the server creates is changeable only by those accounts (users may read it) and a .titano folder it creates is private; an existing archive others can change is logged as a warning at start. - Proxy mode: only loopback is trusted by default, since LAN clients reach the HTTP port from private addresses; a cookie sign-in that did not come through a trusted proxy over HTTPS answers proxy_untrusted, naming TITANO_TRUSTED_PROXIES. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
11 files changed
+497
-64
No files matched your search
@@ -79,10 +79,12 @@ public sealed class StartupTests(TestContext context)
|
||||
public void TrustedProxiesAreAddressesOrNetworks()
|
||||
{
|
||||
var root = context.CreateTempDirectory("proxies");
|
||||
// Loopback only: machines of the home network reach the HTTP port directly from private addresses.
|
||||
var defaults = ServerOptions.Load(new Dictionary<string, string?> { ["TITANO_DATA_PATH"] = root, ["TITANO_DB"] = "postgres" }).TrustedProxyNetworks();
|
||||
foreach (var address in new[] { "127.0.0.1", "::1", "10.20.30.40", "172.18.0.3", "192.168.1.2", "fd00::7", "::ffff:172.17.0.2" })
|
||||
Assert.True(defaults.Any(n => n.Contains(IPAddress.Parse(address)) || n.Contains(IPAddress.Parse(address).MapToIPv4())), address);
|
||||
Assert.False(defaults.Any(n => n.Contains(IPAddress.Parse("203.0.113.5"))));
|
||||
foreach (var address in new[] { "127.0.0.1", "127.0.0.53", "::1" })
|
||||
Assert.True(defaults.Any(n => n.Contains(IPAddress.Parse(address))), address);
|
||||
foreach (var address in new[] { "10.20.30.40", "172.18.0.3", "192.168.1.2", "fd00::7", "203.0.113.5" })
|
||||
Assert.False(defaults.Any(n => n.Contains(IPAddress.Parse(address))), address);
|
||||
|
||||
var options = ServerOptions.Load(new Dictionary<string, string?>
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user