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
@@ -33,7 +33,7 @@ public static class ServerHost
|
||||
DataFolderAccess.Restrict(options.DataPath);
|
||||
Directory.CreateDirectory(options.LogPath);
|
||||
Directory.CreateDirectory(options.UploadsPath);
|
||||
Directory.CreateDirectory(options.ArchivePath);
|
||||
var archiveOpenToOthers = DataFolderAccess.PrepareArchive(options.ArchivePath);
|
||||
|
||||
var builder = WebApplication.CreateSlimBuilder(new WebApplicationOptions { Args = args, ContentRootPath = AppContext.BaseDirectory });
|
||||
builder.Logging.ClearProviders();
|
||||
@@ -82,6 +82,12 @@ public static class ServerHost
|
||||
app.Logger.LogInformation("Titano Server {Version} · archive {Archive} · data {Data} · {Database} · TLS {Tls}{Fingerprint}",
|
||||
SystemEndpoints.Version, options.ArchivePath, options.DataPath, state.Database, options.TlsMode,
|
||||
state.TlsFingerprint is null ? string.Empty : " · SHA-256 " + state.TlsFingerprint);
|
||||
if (archiveOpenToOthers)
|
||||
{
|
||||
app.Logger.LogWarning("Accounts other than SYSTEM, Administrators and the one Titano Server runs as can change the archive {Archive}: "
|
||||
+ "they could put a link in place of a folder and redirect the files the server moves. Let only those accounts change it (others may read it).",
|
||||
options.ArchivePath);
|
||||
}
|
||||
app.Lifetime.ApplicationStopping.Register(() => app.Logger.LogInformation("Titano Server stopping"));
|
||||
app.Lifetime.ApplicationStopped.Register(() => database.DisposeAsync().AsTask().GetAwaiter().GetResult());
|
||||
return app;
|
||||
|
||||
Reference in new issue
Block a user