From 4080dcc60fd006b2e5502a4f47f47869692f6b25 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 08:03:04 -0500 Subject: remove controller-level admin for server --- src/slskd/Core/API/Controllers/ServerController.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Core/API/Controllers/ServerController.cs b/src/slskd/Core/API/Controllers/ServerController.cs index 70adb858..41c1f1b1 100644 --- a/src/slskd/Core/API/Controllers/ServerController.cs +++ b/src/slskd/Core/API/Controllers/ServerController.cs @@ -48,7 +48,6 @@ namespace slskd.Core.API [ApiController] [Produces("application/json")] [Consumes("application/json")] - [Authorize(Roles = AuthRole.AdministratorOnly)] public class ServerController : ControllerBase { public ServerController( -- cgit v1.2.3 From 62cf077ec126089b2a6a1e0c3933167cec4003de Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 09:23:52 -0500 Subject: delete dump file after transmission --- src/slskd/Core/API/Controllers/ApplicationController.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Core/API/Controllers/ApplicationController.cs b/src/slskd/Core/API/Controllers/ApplicationController.cs index c9af1296..fc2e31a7 100644 --- a/src/slskd/Core/API/Controllers/ApplicationController.cs +++ b/src/slskd/Core/API/Controllers/ApplicationController.cs @@ -36,6 +36,7 @@ namespace slskd.Core.API { using System; using System.Diagnostics; + using System.IO; using System.Threading.Tasks; using Asp.Versioning; using Microsoft.AspNetCore.Authorization; @@ -181,7 +182,9 @@ namespace slskd.Core.API Log.Warning("Dump complete"); - return PhysicalFile(file, "application/octet-stream", "slskd.dmp"); + // the dump contains everything in memory, including secrets. delete it once it has been sent + var stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.None, bufferSize: 4096, FileOptions.DeleteOnClose); + return File(stream, "application/octet-stream", "slskd.dmp"); } Log.Warning("Unauthorized attempt to dump application memory; Flags.Dumpable is disabled"); -- cgit v1.2.3 From 08d846f0f59a1922828504781da0612f3cfde3ab Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 09:28:50 -0500 Subject: redact configuration dump when debug is enabled --- src/slskd/Program.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index cdfbbf33..5347e5f5 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -454,7 +454,17 @@ namespace slskd if (OptionsAtStartup.Debug) { - Log.Information($"Configuration:\n{Configuration.GetDebugView()}"); + // redact values for any key matching the name of a property marked [Secret]. keys from YAML may be + // snake or kebab case, so normalize before comparing. this over-redacts, which is fine here + var secretNames = typeof(Options).Assembly.GetTypes() + .Where(t => t == typeof(Options) || (t.FullName?.StartsWith($"{typeof(Options).FullName}+") ?? false)) + .SelectMany(t => t.GetProperties()) + .Where(p => p.GetCustomAttributes(typeof(SecretAttribute), inherit: false).Length > 0) + .Select(p => p.Name.ToLowerInvariant()) + .ToHashSet(); + + Log.Information($"Configuration:\n{Configuration.GetDebugView(context => + secretNames.Contains(context.Key.Replace("_", string.Empty).Replace("-", string.Empty).ToLowerInvariant()) ? "*****" : context.Value)}"); } if (!OptionsAtStartup.TryValidate(out var result)) @@ -465,7 +475,7 @@ namespace slskd } catch (Exception ex) { - Log.Information($"Invalid configuration: {(!OptionsAtStartup.Debug ? ex : ex.Message)}"); + Log.Information($"Invalid configuration: {(OptionsAtStartup.Debug ? ex : ex.Message)}"); return; } -- cgit v1.2.3 From 64ff7f587675b3fe04585339d33416a2d0373453 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 10:46:20 -0500 Subject: allow a reader to get redacted options --- src/slskd/Core/API/Controllers/OptionsController.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/API/Controllers/OptionsController.cs b/src/slskd/Core/API/Controllers/OptionsController.cs index e20017a8..98028c76 100644 --- a/src/slskd/Core/API/Controllers/OptionsController.cs +++ b/src/slskd/Core/API/Controllers/OptionsController.cs @@ -53,7 +53,6 @@ namespace slskd.Core.API [ApiController] [Produces("application/json")] [Consumes("application/json")] - [Authorize(Roles = AuthRole.AdministratorOnly)] public class OptionsController : ControllerBase { public OptionsController( @@ -76,7 +75,7 @@ namespace slskd.Core.API /// /// [HttpGet] - [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.AdministratorOnly)] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(typeof(Options), 200)] public IActionResult Current() { @@ -197,7 +196,7 @@ namespace slskd.Core.API if (!TryValidateYaml(yaml, out var error)) { - Log.Error(error, "Failed to validate YAML configuration"); + Log.Error("Failed to validate YAML configuration: {Error}", error); return BadRequest(error); } -- cgit v1.2.3 From bfd2e97b1a39c3a0b0337f2fe5bd9db167d00f3a Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 14:45:34 -0500 Subject: improve login endpoint --- .../Core/API/Controllers/SessionController.cs | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/API/Controllers/SessionController.cs b/src/slskd/Core/API/Controllers/SessionController.cs index b26dfe6e..1115f46c 100644 --- a/src/slskd/Core/API/Controllers/SessionController.cs +++ b/src/slskd/Core/API/Controllers/SessionController.cs @@ -34,8 +34,11 @@ using Microsoft.Extensions.Options; namespace slskd.Core.API { + using System.Security.Cryptography; + using System.Text; using Asp.Versioning; using Microsoft.AspNetCore.Authorization; + using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Serilog; using slskd.Authentication; @@ -115,13 +118,15 @@ namespace slskd.Core.API { if (OptionsAtStartup.Headless) { - Log.Warning("Login from {User} rejected; web UI is DISABLED when running in headless mode", login.Username); + // if running headless, reject all login attempts and provide no feedback about inputs; there is nothing + // a caller can do to change the outcome, so a 400 is misleading + Log.Warning("Login from {User} rejected; web UI is DISABLED when running in headless mode", login?.Username ?? ""); return Forbid(); } if (login == default) { - return BadRequest(); + return BadRequest("No credentials provided"); } if (string.IsNullOrWhiteSpace(login.Username) || string.IsNullOrWhiteSpace(login.Password)) @@ -129,8 +134,24 @@ namespace slskd.Core.API return BadRequest("Username and/or Password missing or invalid"); } + Options.WebOptions.WebAuthenticationOptions options = OptionsSnapshot.Value.Web.Authentication; + + if (string.IsNullOrEmpty(options.Username) || string.IsNullOrEmpty(options.Password)) + { + // validation within the Options class should prevent this, but confirm in case of regression + Log.Error("Authentication is misconfigured; when enabled, username and password must be at least one character. Login is disabled."); + return StatusCode(StatusCodes.Status500InternalServerError, "Login disabled, check application logs for details"); + } + + // compare in constant time to avoid timing attacks + static bool ParanoidEquals(string left, string right) + => CryptographicOperations.FixedTimeEquals(Encoding.UTF8.GetBytes(left), Encoding.UTF8.GetBytes(right)); + // only admin login for now - if (OptionsSnapshot.Value.Web.Authentication.Username == login.Username && OptionsSnapshot.Value.Web.Authentication.Password == login.Password) + var usernameMatches = ParanoidEquals(options.Username, login.Username); + var passwordMatches = ParanoidEquals(options.Password, login.Password); + + if (usernameMatches & passwordMatches) { return Ok(new TokenResponse(Security.GenerateJwt(login.Username, Role.Administrator))); } -- cgit v1.2.3 From c5cad816171b7764bbdcf1c7c94622e1bc483e1b Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 14:47:01 -0500 Subject: require r/w to raise events --- src/slskd/Events/API/EventsController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Events/API/EventsController.cs b/src/slskd/Events/API/EventsController.cs index e031498c..5381f513 100644 --- a/src/slskd/Events/API/EventsController.cs +++ b/src/slskd/Events/API/EventsController.cs @@ -123,7 +123,7 @@ public class EventsController : ControllerBase /// An unexpected error is encountered. /// The request completed successfully. [HttpPost("{type}", Name = nameof(RaiseEvent))] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(typeof(string), 400)] [ProducesResponseType(401)] [ProducesResponseType(403)] @@ -131,7 +131,7 @@ public class EventsController : ControllerBase [ProducesResponseType(typeof(Event), 201)] public IActionResult RaiseEvent([FromRoute] string type, [FromBody] string disambiguator) { - if (!Enum.TryParse(type, ignoreCase: true, out var eventType)) + if (!Enum.TryParse(type, ignoreCase: true, out var eventType) || !Enum.IsDefined(eventType)) { var names = Enum.GetNames(typeof(EventType)) .Where(n => n != EventType.Any.ToString() && n != EventType.None.ToString()); -- cgit v1.2.3 From e58f2e59adab312f9e18a13e00519783dca661ed Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 14:48:00 -0500 Subject: require r/w for file manipulation --- src/slskd/Files/API/FilesController.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/slskd/Files/API/FilesController.cs b/src/slskd/Files/API/FilesController.cs index 5f30f325..68898eaf 100644 --- a/src/slskd/Files/API/FilesController.cs +++ b/src/slskd/Files/API/FilesController.cs @@ -95,7 +95,7 @@ namespace slskd.Files.API [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] - public Task GetDownloadSubdirectoryContentsAsync([FromRoute] string base64SubdirectoryName, [FromQuery] bool recursive = false) + public Task GetDownloadSubdirectoryContentsAsync([FromRoute, UrlEncoded] string base64SubdirectoryName, [FromQuery] bool recursive = false) => ListDirectoryAsync(rootDirectory: OptionsSnapshot.Value.Directories.Downloads, base64SubdirectoryName, recursive); /// @@ -108,9 +108,9 @@ namespace slskd.Files.API /// Access to the specified subdirectory was denied. /// The specified subdirectory does not exist. [HttpDelete("downloads/directories/{base64SubdirectoryName}")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(204)] - public Task DeleteDownloadSubdirectoryAsync([FromRoute] string base64SubdirectoryName) + public Task DeleteDownloadSubdirectoryAsync([FromRoute, UrlEncoded] string base64SubdirectoryName) => DeleteSubdirectoryAsync(rootDirectory: OptionsSnapshot.Value.Directories.Downloads, base64SubdirectoryName); /// @@ -123,9 +123,9 @@ namespace slskd.Files.API /// Access to the specified subdirectory was denied. /// The specified subdirectory does not exist. [HttpDelete("downloads/files/{base64FileName}")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(204)] - public Task DeleteDownloadFileAsync([FromRoute] string base64FileName) + public Task DeleteDownloadFileAsync([FromRoute, UrlEncoded] string base64FileName) => DeleteFileAsync(rootDirectory: OptionsSnapshot.Value.Directories.Downloads, base64FileName); /// @@ -154,7 +154,7 @@ namespace slskd.Files.API [HttpGet("incomplete/directories/{base64SubdirectoryName}")] [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(typeof(FilesystemDirectory), 200)] - public Task GetIncompleteSubdirectoryContentsAsync([FromRoute, Required] string base64SubdirectoryName, [FromQuery] bool recursive = false) + public Task GetIncompleteSubdirectoryContentsAsync([FromRoute, UrlEncoded, Required] string base64SubdirectoryName, [FromQuery] bool recursive = false) => ListDirectoryAsync(rootDirectory: OptionsSnapshot.Value.Directories.Incomplete, base64SubdirectoryName, recursive); /// @@ -167,9 +167,9 @@ namespace slskd.Files.API /// Access to the specified subdirectory was denied. /// The specified subdirectory does not exist. [HttpDelete("incomplete/directories/{base64SubdirectoryName}")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(204)] - public Task DeleteIncompleteSubdirectoryAsync([FromRoute] string base64SubdirectoryName) + public Task DeleteIncompleteSubdirectoryAsync([FromRoute, UrlEncoded] string base64SubdirectoryName) => DeleteSubdirectoryAsync(rootDirectory: OptionsSnapshot.Value.Directories.Incomplete, base64SubdirectoryName); /// @@ -182,9 +182,9 @@ namespace slskd.Files.API /// Access to the specified subdirectory was denied. /// The specified subdirectory does not exist. [HttpDelete("incomplete/files/{base64FileName}")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(204)] - public Task DeleteIncompleteFileAsync([FromRoute] string base64FileName) + public Task DeleteIncompleteFileAsync([FromRoute, UrlEncoded] string base64FileName) => DeleteFileAsync(rootDirectory: OptionsSnapshot.Value.Directories.Incomplete, base64FileName); private async Task ListDirectoryAsync(string rootDirectory, string base64SubdirectoryName = null, bool recursive = false) -- cgit v1.2.3 From 3c34fcc3bde265d8c98792a8b7d00c61c4bd06e6 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 14:50:57 -0500 Subject: require r/w for conversations --- .../Messaging/API/Controllers/ConversationsController.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/slskd/Messaging/API/Controllers/ConversationsController.cs b/src/slskd/Messaging/API/Controllers/ConversationsController.cs index 7ed0a92c..a1c6038f 100644 --- a/src/slskd/Messaging/API/Controllers/ConversationsController.cs +++ b/src/slskd/Messaging/API/Controllers/ConversationsController.cs @@ -87,7 +87,7 @@ namespace slskd.Messaging.API /// A conversation with the specified username, or a message matching the specified id could not be found. /// [HttpPut("{username}/{id}")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(200)] [ProducesResponseType(404)] public async Task Acknowledge([FromRoute, UrlEncoded] string username, [FromRoute] int id) @@ -97,7 +97,7 @@ namespace slskd.Messaging.API return Forbid(); } - var message = Messages.Conversations.FindMessageAsync(username, id); + var message = await Messages.Conversations.FindMessageAsync(username, id); if (message == default) { @@ -117,7 +117,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// A conversation with the specified username could not be found. [HttpPut("{username}")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(200)] [ProducesResponseType(404)] public async Task AcknowledgeAll([FromRoute, UrlEncoded] string username) @@ -127,7 +127,7 @@ namespace slskd.Messaging.API return Forbid(); } - var conversation = Messages.Conversations.FindAsync(username); + var conversation = await Messages.Conversations.FindAsync(username); if (conversation == default) { @@ -146,7 +146,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// A conversation with the specified username could not be found. [HttpDelete("{username}")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(404)] [ProducesResponseType(204)] public async Task Close([FromRoute, UrlEncoded] string username) @@ -156,7 +156,7 @@ namespace slskd.Messaging.API return Forbid(); } - var conversation = Messages.Conversations.FindAsync(username, includeInactive: false); + var conversation = await Messages.Conversations.FindAsync(username, includeInactive: false); if (conversation == default) { @@ -259,7 +259,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The specified message is null or empty. [HttpPost("{username}")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(201)] [ProducesResponseType(400)] public async Task Send([FromRoute, UrlEncoded] string username, [FromBody] string message) -- cgit v1.2.3 From d4447890e5fad1cd942affe051c9479385667465 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 14:54:37 -0500 Subject: perms for more controllers, use paranoid check of api keys --- src/slskd/Core/Security/SecurityService.cs | 7 +++++-- src/slskd/Messaging/API/Controllers/RoomsController.cs | 10 +++++----- src/slskd/Shares/API/Controllers/SharesController.cs | 4 ++-- src/slskd/Transfers/API/Controllers/TransfersController.cs | 14 +++++++------- 4 files changed, 19 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/Security/SecurityService.cs b/src/slskd/Core/Security/SecurityService.cs index 790f5806..26ed49d2 100644 --- a/src/slskd/Core/Security/SecurityService.cs +++ b/src/slskd/Core/Security/SecurityService.cs @@ -40,6 +40,8 @@ using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Net; using System.Security.Claims; +using System.Security.Cryptography; +using System.Text; using Microsoft.IdentityModel.Tokens; using NetTools; using Serilog; @@ -121,11 +123,12 @@ public class SecurityService keys = keys.Prepend(new KeyValuePair(nameof(PrimaryApiKey), PrimaryApiKey)); } - var record = keys.FirstOrDefault(k => k.Value.Key == key); + var keyBytes = Encoding.UTF8.GetBytes(key ?? string.Empty); + var record = keys.FirstOrDefault(k => k.Value.Key is not null && CryptographicOperations.FixedTimeEquals(Encoding.UTF8.GetBytes(k.Value.Key), keyBytes)); if (record.Key == null) { - throw new NotFoundException($"Unknown API key beginning with: {key.Substring(0, 4)}"); + throw new NotFoundException("Unknown API key"); } // looks like '::ffff:127.0.0.1'; not compatible with CIDR.Contains(), so convert it back to IPv4 diff --git a/src/slskd/Messaging/API/Controllers/RoomsController.cs b/src/slskd/Messaging/API/Controllers/RoomsController.cs index 3b2fe568..57d3b742 100644 --- a/src/slskd/Messaging/API/Controllers/RoomsController.cs +++ b/src/slskd/Messaging/API/Controllers/RoomsController.cs @@ -127,7 +127,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The specified roomName could not be found. [HttpPost("joined/{roomName}/messages")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(201)] [ProducesResponseType(404)] public async Task SendMessage([FromRoute, UrlEncoded] string roomName, [FromBody] string message) @@ -155,7 +155,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The specified roomName could not be found. [HttpPost("joined/{roomName}/ticker")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(201)] [ProducesResponseType(404)] public async Task SetTicker([FromRoute, UrlEncoded] string roomName, [FromBody] string message) @@ -183,7 +183,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The specified roomName could not be found. [HttpPost("joined/{roomName}/members")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(201)] [ProducesResponseType(404)] public async Task AddRoomMember([FromRoute, UrlEncoded] string roomName, [FromBody] string username) @@ -298,7 +298,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The room has already been joined. [HttpPost("joined")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(typeof(Room), 201)] [ProducesResponseType(304)] public async Task JoinRoom([FromBody] string roomName) @@ -339,7 +339,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The room has not been joined. [HttpDelete("joined/{roomName}")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(204)] [ProducesResponseType(404)] public async Task LeaveRoom([FromRoute, UrlEncoded] string roomName) diff --git a/src/slskd/Shares/API/Controllers/SharesController.cs b/src/slskd/Shares/API/Controllers/SharesController.cs index 76ec4643..64d703bd 100644 --- a/src/slskd/Shares/API/Controllers/SharesController.cs +++ b/src/slskd/Shares/API/Controllers/SharesController.cs @@ -148,7 +148,7 @@ namespace slskd.Shares.API /// A share scan is already in progress. [HttpPut] [Route("")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(204)] [ProducesResponseType(409)] public IActionResult RescanSharesAsync() @@ -173,7 +173,7 @@ namespace slskd.Shares.API /// A share scan was not in progress. [HttpDelete] [Route("")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(204)] [ProducesResponseType(404)] public IActionResult CancelShareScan() diff --git a/src/slskd/Transfers/API/Controllers/TransfersController.cs b/src/slskd/Transfers/API/Controllers/TransfersController.cs index 3dd2f124..b3453530 100644 --- a/src/slskd/Transfers/API/Controllers/TransfersController.cs +++ b/src/slskd/Transfers/API/Controllers/TransfersController.cs @@ -89,7 +89,7 @@ namespace slskd.Transfers.API /// The download was cancelled successfully. /// The specified download was not found. [HttpDelete("downloads/{username}/{id}")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(204)] [ProducesResponseType(404)] public IActionResult CancelDownloadAsync([FromRoute, UrlEncoded, Required] string username, [FromRoute, Required] string id, [FromQuery] bool remove = false) @@ -127,7 +127,7 @@ namespace slskd.Transfers.API /// /// The downloads were removed successfully. [HttpDelete("downloads/all/completed")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(204)] public IActionResult ClearCompletedDownloads() { @@ -158,7 +158,7 @@ namespace slskd.Transfers.API /// The upload was cancelled successfully. /// The specified upload was not found. [HttpDelete("uploads/{username}/{id}")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(204)] [ProducesResponseType(404)] public IActionResult CancelUpload([FromRoute, UrlEncoded, Required] string username, [FromRoute, Required] string id, [FromQuery] bool remove = false) @@ -196,7 +196,7 @@ namespace slskd.Transfers.API /// /// The uploads were removed successfully. [HttpDelete("uploads/all/completed")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(204)] public IActionResult ClearCompletedUploads() { @@ -228,7 +228,7 @@ namespace slskd.Transfers.API /// An unexpected error was encountered. [Obsolete("Will be phased out in future versions; use batches")] [HttpPost("downloads/{username}")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(201)] [ProducesResponseType(typeof(string), 403)] [ProducesResponseType(typeof(string), 500)] @@ -302,7 +302,7 @@ namespace slskd.Transfers.API /// Request throttled. /// An unexpected error was encountered. [HttpPost("downloads/batches")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(typeof(EnqueueDownloadBatchResponse), StatusCodes.Status200OK)] [ProducesResponseType(typeof(EnqueueDownloadBatchResponse), StatusCodes.Status201Created)] [ProducesResponseType(typeof(EnqueueDownloadBatchResponse), StatusCodes.Status207MultiStatus)] @@ -582,7 +582,7 @@ namespace slskd.Transfers.API /// The request completed successfully. /// The specified download was not found. [HttpGet("downloads/{username}/{id}/position")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(typeof(Transfer), 200)] [ProducesResponseType(404)] public async Task GetPlaceInQueueAsync([FromRoute, UrlEncoded, Required] string username, [FromRoute, Required] string id) -- cgit v1.2.3 From a3efee00cc7a269f23b6f71564cc577e83533519 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 14:57:54 -0500 Subject: 24 hour clock --- src/slskd/Core/Data/Migrator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Core/Data/Migrator.cs b/src/slskd/Core/Data/Migrator.cs index d53d7c8c..332077a9 100644 --- a/src/slskd/Core/Data/Migrator.cs +++ b/src/slskd/Core/Data/Migrator.cs @@ -133,7 +133,7 @@ public class Migrator */ Log.Warning("{Count} outstanding database migration(s) to apply. This operation must be completed before the application can start.", migrationsToApply.Count()); - var migrationId = DateTime.UtcNow.ToString("MMddyy_hhmmss"); + var migrationId = DateTime.UtcNow.ToString("MMddyy_HHmmss"); Log.Warning("--> The ID for this migration is {MigrationId}. Use it to locate pre-migration database backups, should manual cleanup be needed. <--", migrationId); -- cgit v1.2.3 From 376b2378380b7d39fd0947c35cab0a636662b372 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 14:59:10 -0500 Subject: couple of tweaks --- src/slskd/Common/Dumper.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Common/Dumper.cs b/src/slskd/Common/Dumper.cs index 27304873..8797d040 100644 --- a/src/slskd/Common/Dumper.cs +++ b/src/slskd/Common/Dumper.cs @@ -86,10 +86,10 @@ namespace slskd if (!System.OperatingSystem.IsWindows()) { - await ExecAsync("/bin/sh", $"-c \"chmod +x {BinFile}\""); + await ExecAsync("/bin/chmod", $"+x \"{BinFile}\""); } - await ExecAsync(BinFile, $"collect --process-id {Environment.ProcessId} --type full --output {outputFile}"); + await ExecAsync(BinFile, $"collect --process-id {Environment.ProcessId} --type full --output \"{outputFile}\""); return outputFile; } @@ -124,6 +124,11 @@ namespace slskd process.StartInfo.Arguments = args; process.Start(); await process.WaitForExitAsync(); + + if (process.ExitCode != 0) + { + throw new SlskdException($"'{bin}' exited with code {process.ExitCode}"); + } } private string GetRID() -- cgit v1.2.3 From aeb702dcd13715ea868456ee7470e753a2a305d3 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 15:00:28 -0500 Subject: handle ipv6 --- src/slskd/Core/Blacklist.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/slskd/Core/Blacklist.cs b/src/slskd/Core/Blacklist.cs index 517b5e4b..6f25b93c 100644 --- a/src/slskd/Core/Blacklist.cs +++ b/src/slskd/Core/Blacklist.cs @@ -39,6 +39,7 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Net; +using System.Net.Sockets; using System.Threading.Tasks; using NetTools; using Serilog; @@ -315,6 +316,18 @@ public class Blacklist /// A value indicating whether the specified IP is contained within the blacklist. public virtual bool Contains(IPAddress ip) { + // looks like '::ffff:1.2.3.4'; convert it back to IPv4 so the lookup below works + if (ip.IsIPv4MappedToIPv6) + { + ip = ip.MapToIPv4(); + } + + // only IPv4 ranges are supported + if (ip.AddressFamily != AddressFamily.InterNetwork) + { + return false; + } + // grab the first octet int first = ip.GetAddressBytes()[0]; -- cgit v1.2.3 From 62e2ede877fcc7e91d4c2fe7969f34c9ae818e4d Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 15:01:18 -0500 Subject: limit real time logs to admin --- src/slskd/Core/API/Hubs/LogsHub.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Core/API/Hubs/LogsHub.cs b/src/slskd/Core/API/Hubs/LogsHub.cs index bec12d6a..0697f5ef 100644 --- a/src/slskd/Core/API/Hubs/LogsHub.cs +++ b/src/slskd/Core/API/Hubs/LogsHub.cs @@ -62,7 +62,7 @@ namespace slskd.Core.API /// /// The logs SignalR hub. /// - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.AdministratorOnly)] public class LogsHub : Hub { public override async Task OnConnectedAsync() -- cgit v1.2.3 From 8ba47ff14c2d65623f98a9d590ff17d97daee88e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 15:15:33 -0500 Subject: don't send a challenge if relay is disabled --- src/slskd/Relay/API/Hubs/RelayHub.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/slskd/Relay/API/Hubs/RelayHub.cs b/src/slskd/Relay/API/Hubs/RelayHub.cs index 8430164c..210f50d0 100644 --- a/src/slskd/Relay/API/Hubs/RelayHub.cs +++ b/src/slskd/Relay/API/Hubs/RelayHub.cs @@ -120,6 +120,7 @@ namespace slskd.Relay { Log.Debug("Agent connection {Id} from {IP} aborted; Relay is not enabled, or is not in Controller mode", Context.ConnectionId, GetRemoteIPAddress()); Context.Abort(); + return; } var token = Relay.GenerateAuthenticationChallengeToken(Context.ConnectionId); -- cgit v1.2.3 From 33110721157f48183ebac1161896ca0a4f7af196 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 15:17:45 -0500 Subject: halt processing if given a path with traversal --- src/slskd/Relay/RelayClient.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Relay/RelayClient.cs b/src/slskd/Relay/RelayClient.cs index fef16573..9a587d5e 100644 --- a/src/slskd/Relay/RelayClient.cs +++ b/src/slskd/Relay/RelayClient.cs @@ -375,6 +375,7 @@ namespace slskd.Relay { Log.Warning("Suspicious attempt to request file info containing unsafe path segments (one or more of path traversal characters '.' and '..'). Requested file: {filename}", filename); await HubConnection.InvokeAsync(nameof(RelayHub.ReturnFileInfo), id, false, 0); + return; } Log.Information("Relay controller requested file info for {Filename} with ID {Id}", filename, id); @@ -399,7 +400,8 @@ namespace slskd.Relay if (FileSafety.ContainsTraversalSegments(filename)) { Log.Warning("Suspicious attempt to request a file upload containing unsafe path segments (one or more of path traversal characters '.' and '..'). Requested file: {filename}", filename); - await HubConnection.InvokeAsync(nameof(RelayHub.NotifyFileUploadFailed), token); + await HubConnection.InvokeAsync(nameof(RelayHub.NotifyFileUploadFailed), token, "Requested filename contains unsafe path segments"); + return; } _ = Task.Run(async () => -- cgit v1.2.3 From df289696a24efd01a070e0b92b08f2d9f293c2b3 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 15:19:13 -0500 Subject: throw logged in tcs on exception --- src/slskd/Relay/RelayClient.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/slskd/Relay/RelayClient.cs b/src/slskd/Relay/RelayClient.cs index 9a587d5e..ebb4eb52 100644 --- a/src/slskd/Relay/RelayClient.cs +++ b/src/slskd/Relay/RelayClient.cs @@ -366,6 +366,7 @@ namespace slskd.Relay catch (Exception ex) { Log.Error(ex, "Failed to handle authentication challenge: {Message}", ex.Message); + LoggedInTaskCompletionSource.TrySetException(ex); } } -- cgit v1.2.3 From 3f117404a2e12158803e90637cf0f83ae570837f Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 15:21:26 -0500 Subject: stop following a login failure --- src/slskd/Relay/RelayClient.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Relay/RelayClient.cs b/src/slskd/Relay/RelayClient.cs index ebb4eb52..cbcde3c4 100644 --- a/src/slskd/Relay/RelayClient.cs +++ b/src/slskd/Relay/RelayClient.cs @@ -148,7 +148,15 @@ namespace slskd.Relay // the controller will send an authentication challenge immediately after connection // wait for the auth handler to log in before proceeding with the initial share upload - await LoggedInTaskCompletionSource.Task; + try + { + await LoggedInTaskCompletionSource.Task; + } + catch (Exception) + { + await StopAsync(cancellationToken); + throw; + } Log.Information("Uploading shares..."); -- cgit v1.2.3 From e2d08d3f96f10994882e35fc4ece9e146d673e2f Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 15:24:14 -0500 Subject: set policy --- src/slskd/Relay/API/Hubs/RelayHub.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Relay/API/Hubs/RelayHub.cs b/src/slskd/Relay/API/Hubs/RelayHub.cs index 210f50d0..e839cd1a 100644 --- a/src/slskd/Relay/API/Hubs/RelayHub.cs +++ b/src/slskd/Relay/API/Hubs/RelayHub.cs @@ -85,7 +85,7 @@ namespace slskd.Relay /// /// The relay SignalR hub. /// - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] public class RelayHub : Hub { /// -- cgit v1.2.3 From 3db630bb3bd862be6df6cfc87ea70cfc5a2ea14c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 15:25:05 -0500 Subject: r/w for search starts and stops --- src/slskd/Search/API/Controllers/SearchesController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/slskd/Search/API/Controllers/SearchesController.cs b/src/slskd/Search/API/Controllers/SearchesController.cs index 99214410..a573c1e0 100644 --- a/src/slskd/Search/API/Controllers/SearchesController.cs +++ b/src/slskd/Search/API/Controllers/SearchesController.cs @@ -78,7 +78,7 @@ namespace slskd.Search.API /// The specified was malformed. /// The search terminated abnormally. [HttpPost("")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] public async Task Post([FromBody] SearchRequest request) { if (Program.IsRelayAgent) @@ -207,7 +207,7 @@ namespace slskd.Search.API /// The search was not in progress. /// [HttpPut("{id}")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(200)] [ProducesResponseType(304)] public async Task Cancel([FromRoute] Guid id) @@ -236,7 +236,7 @@ namespace slskd.Search.API /// A search with the specified id could not be found. /// [HttpDelete("{id}")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(204)] [ProducesResponseType(404)] public async Task Delete([FromRoute] Guid id) -- cgit v1.2.3 From d796445484f0a36a67627f9c98630c7f1755233f Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Oct 2026 20:56:56 -0500 Subject: r/w for user actions --- src/slskd/Users/API/Controllers/UsersController.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/slskd/Users/API/Controllers/UsersController.cs b/src/slskd/Users/API/Controllers/UsersController.cs index 8029b5e0..41d2db6a 100644 --- a/src/slskd/Users/API/Controllers/UsersController.cs +++ b/src/slskd/Users/API/Controllers/UsersController.cs @@ -42,7 +42,6 @@ namespace slskd.Users.API using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Serilog; - using Soulseek; /// @@ -83,7 +82,7 @@ namespace slskd.Users.API /// /// The request completed successfully. [HttpGet("{username}/endpoint")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(typeof(IPEndPoint), 200)] [ProducesResponseType(404)] public async Task Endpoint([FromRoute, UrlEncoded, Required] string username) @@ -115,7 +114,7 @@ namespace slskd.Users.API /// The username of the user. /// [HttpGet("{username}/browse")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(typeof(IEnumerable), 200)] [ProducesResponseType(404)] public async Task Browse([FromRoute, UrlEncoded, Required] string username) @@ -179,7 +178,7 @@ namespace slskd.Users.API /// The directory contents request. /// [HttpPost("{username}/directory")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(typeof(IEnumerable), 200)] [ProducesResponseType(404)] public async Task Directory([FromRoute, UrlEncoded, Required] string username, [FromBody, Required] DirectoryContentsRequest request) @@ -219,7 +218,7 @@ namespace slskd.Users.API /// The username of the user. /// [HttpGet("{username}/info")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(typeof(Info), 200)] [ProducesResponseType(404)] public async Task Info([FromRoute, UrlEncoded, Required] string username) @@ -251,7 +250,7 @@ namespace slskd.Users.API /// The username of the user. /// [HttpGet("{username}/status")] - [Authorize(Policy = AuthPolicy.Any)] + [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)] [ProducesResponseType(typeof(Status), 200)] [ProducesResponseType(404)] public async Task Status([FromRoute, UrlEncoded, Required] string username) -- cgit v1.2.3 From 8b68a8ea7733ad1a4a9e85f296d9f628b71d3e64 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Oct 2026 20:59:38 -0500 Subject: mark props that might contain secrets as secret --- src/slskd/Core/Options.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index d2aba37f..9119a8fe 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1466,6 +1466,7 @@ namespace slskd [EnvironmentVariable("LOKI")] [Description("optional; url to a Grafana Loki instance to which to log")] [RequiresRestart] + [Secret] public string Loki { get; init; } = null; /// @@ -2585,6 +2586,7 @@ namespace slskd /// Gets the fully qualified URL for the webhook. /// [NotNullOrWhiteSpace] + [Secret] public string Url { get; init; } /// @@ -2621,6 +2623,7 @@ namespace slskd /// /// Gets the header's value. /// + [Secret] public string Value { get; init; } } @@ -2661,6 +2664,7 @@ namespace slskd /// /// Gets the shell command to run. /// + [Secret] public string Command { get; init; } /// @@ -2674,6 +2678,7 @@ namespace slskd /// /// Mutually exclusive with . /// + [Secret] public string Args { get; init; } /// -- cgit v1.2.3 From 9825056ce0caa8df47707807a0943a834161eae1 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Oct 2026 21:17:23 -0500 Subject: escape sqlite characters --- src/slskd/Shares/SqliteShareRepository.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/slskd/Shares/SqliteShareRepository.cs b/src/slskd/Shares/SqliteShareRepository.cs index 6d84308a..a6407ec8 100644 --- a/src/slskd/Shares/SqliteShareRepository.cs +++ b/src/slskd/Shares/SqliteShareRepository.cs @@ -157,8 +157,8 @@ namespace slskd.Shares } else { - cmd = new SqliteCommand("SELECT COUNT(*) FROM directories WHERE name LIKE @prefix || '%'", conn); - cmd.Parameters.AddWithValue("prefix", parentDirectory); + cmd = new SqliteCommand("SELECT COUNT(*) FROM directories WHERE name LIKE @prefix || '%' ESCAPE '^'", conn); + cmd.Parameters.AddWithValue("prefix", parentDirectory.Replace("^", "^^").Replace("%", "^%").Replace("_", "^_")); } var reader = cmd.ExecuteReader(); @@ -190,8 +190,8 @@ namespace slskd.Shares } else { - cmd = new SqliteCommand("SELECT COUNT(*) FROM files WHERE maskedFilename LIKE @prefix || '%'", conn); - cmd.Parameters.AddWithValue("prefix", parentDirectory); + cmd = new SqliteCommand("SELECT COUNT(*) FROM files WHERE maskedFilename LIKE @prefix || '%' ESCAPE '^'", conn); + cmd.Parameters.AddWithValue("prefix", parentDirectory.Replace("^", "^^").Replace("%", "^%").Replace("_", "^_")); } var reader = cmd.ExecuteReader(); @@ -414,8 +414,8 @@ namespace slskd.Shares } else { - cmd = new SqliteCommand("SELECT name from directories WHERE name LIKE @prefix || '%' ORDER BY name ASC;", conn); - cmd.Parameters.AddWithValue("prefix", parentDirectory); + cmd = new SqliteCommand("SELECT name from directories WHERE name LIKE @prefix || '%' ESCAPE '^' ORDER BY name ASC;", conn); + cmd.Parameters.AddWithValue("prefix", parentDirectory.Replace("^", "^^").Replace("%", "^%").Replace("_", "^_")); } var reader = cmd.ExecuteReader(); @@ -454,8 +454,8 @@ namespace slskd.Shares } else { - cmd = new SqliteCommand("SELECT maskedFilename, code, size, extension, attributeJson FROM files WHERE maskedFilename LIKE @match ORDER BY maskedFilename ASC;", conn); - cmd.Parameters.AddWithValue("match", parentDirectory + '%'); + cmd = new SqliteCommand("SELECT maskedFilename, code, size, extension, attributeJson FROM files WHERE maskedFilename LIKE @match ESCAPE '^' ORDER BY maskedFilename ASC;", conn); + cmd.Parameters.AddWithValue("match", parentDirectory.Replace("^", "^^").Replace("%", "^%").Replace("_", "^_") + '%'); } var reader = cmd.ExecuteReader(); -- cgit v1.2.3 From 73575578f632651b5e8eaa05d228d34286977ab3 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 Oct 2026 10:31:15 -0500 Subject: small tweaks --- src/slskd/Shares/SqliteShareRepository.cs | 1 + src/slskd/Users/UserService.cs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Shares/SqliteShareRepository.cs b/src/slskd/Shares/SqliteShareRepository.cs index a6407ec8..d42a9385 100644 --- a/src/slskd/Shares/SqliteShareRepository.cs +++ b/src/slskd/Shares/SqliteShareRepository.cs @@ -753,6 +753,7 @@ namespace slskd.Shares { if (disposing) { + KeepaliveTimer.Dispose(); KeepaliveConnection.Dispose(); } diff --git a/src/slskd/Users/UserService.cs b/src/slskd/Users/UserService.cs index 3ce827c8..51b47d5b 100644 --- a/src/slskd/Users/UserService.cs +++ b/src/slskd/Users/UserService.cs @@ -325,7 +325,15 @@ namespace slskd.Users { ArgumentNullException.ThrowIfNull(username); - if (BlacklistDecisionCache.TryGetValue(username, out var cached)) + // looks like '::ffff:1.2.3.4'; convert it back to IPv4 so CIDR checks work + if (ipAddress is not null && ipAddress.IsIPv4MappedToIPv6) + { + ipAddress = ipAddress.MapToIPv4(); + } + + var cacheKey = ipAddress is null ? username : $"{username}@{ipAddress}"; + + if (BlacklistDecisionCache.TryGetValue(cacheKey, out var cached)) { return cached; } @@ -343,7 +351,7 @@ namespace slskd.Users var blacklisted = IsBlacklistedInternal(username, ipAddress); BlacklistDecisionCache.Set( - key: username, + key: cacheKey, value: blacklisted, options: new MemoryCacheEntryOptions { -- cgit v1.2.3 From 1cc109a40d1b1d2a8c023c70b44621916641f991 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 Oct 2026 11:09:52 -0500 Subject: fix mistake with minimum value --- src/slskd/Core/Options.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 9119a8fe..3a111a99 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -2256,7 +2256,7 @@ namespace slskd [Argument(default, "jwt-ttl")] [EnvironmentVariable("JWT_TTL")] [Description("TTL for JWTs")] - [Range(3600, int.MaxValue)] + [Range(3600000, int.MaxValue)] [RequiresRestart] public int Ttl { get; init; } = 604800000; } -- cgit v1.2.3 From 4ce05449570276bf00ba3be4f7e747d268fa9ebf Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 Oct 2026 15:12:55 -0500 Subject: use existing enum validation for envar api keys --- src/slskd/Core/Options.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 3a111a99..dd9c3d02 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -2199,9 +2199,12 @@ namespace slskd { var role = tuple.Split('=').LastOrDefault(); - if (!Enum.TryParse(typeof(Role), value: role, ignoreCase: true, out _)) + var roleResult = new EnumAttribute(typeof(Role), ignoreCase: true) + .GetValidationResult(role, new ValidationContext(this) { MemberName = nameof(ApiKey), DisplayName = "API key role" }); + + if (roleResult != ValidationResult.Success) { - results.Add(new ValidationResult($"API key role must be one of: {string.Join(", ", Enum.GetNames(typeof(Role)))}")); + results.Add(new ValidationResult(roleResult.ErrorMessage)); } } else if (tuple.StartsWith("cidr=", StringComparison.OrdinalIgnoreCase)) -- cgit v1.2.3 From 466b56016c73f77ee709d988ff37569b61d29054 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 Oct 2026 15:13:46 -0500 Subject: parameterize search expression --- src/slskd/Shares/SqliteShareRepository.cs | 3 +- .../Shares/SqliteShareRepositoryTests.cs | 368 +++++++++++++++++++++ 2 files changed, 370 insertions(+), 1 deletion(-) create mode 100644 tests/slskd.Tests.Unit/Shares/SqliteShareRepositoryTests.cs (limited to 'src') diff --git a/src/slskd/Shares/SqliteShareRepository.cs b/src/slskd/Shares/SqliteShareRepository.cs index d42a9385..75d3064e 100644 --- a/src/slskd/Shares/SqliteShareRepository.cs +++ b/src/slskd/Shares/SqliteShareRepository.cs @@ -591,7 +591,7 @@ namespace slskd.Shares var sql = $"SELECT files.maskedFilename, files.code, files.size, files.extension, files.attributeJson FROM filenames " + "INNER JOIN files ON filenames.maskedFilename = files.maskedFilename " + - $"WHERE filenames MATCH '({match}) {(query.Exclusions.Any() ? $"NOT ({exclusions})" : string.Empty)}' " + + "WHERE filenames MATCH @match " + $"ORDER BY filenames.maskedFilename ASC {(limit.HasValue ? $"LIMIT {limit.Value}" : string.Empty)};"; var results = new List(); @@ -600,6 +600,7 @@ namespace slskd.Shares { using var conn = GetConnection(); using var cmd = new SqliteCommand(sql, conn); + cmd.Parameters.AddWithValue("match", $"({match}) {(query.Exclusions.Any() ? $"NOT ({exclusions})" : string.Empty)}"); using var reader = cmd.ExecuteReader(); while (reader.Read()) diff --git a/tests/slskd.Tests.Unit/Shares/SqliteShareRepositoryTests.cs b/tests/slskd.Tests.Unit/Shares/SqliteShareRepositoryTests.cs new file mode 100644 index 00000000..2624582c --- /dev/null +++ b/tests/slskd.Tests.Unit/Shares/SqliteShareRepositoryTests.cs @@ -0,0 +1,368 @@ +namespace slskd.Tests.Unit.Shares +{ + using System; + using System.Collections.Generic; + using System.Linq; + using slskd.Shares; + using Soulseek; + using Xunit; + + public class SqliteShareRepositoryTests + { + public class Search + { + [Fact] + public void Returns_Only_Files_Matching_All_Terms() + { + var (a, b, c, d, e) = (Random(), Random(), Random(), Random(), Random()); + + string[] expected = + [ + $@"@@share\{a}\{b}.dat", + $@"@@share\{a}\{c}\{b}.dat", + $@"@@share\{c}\{b} {a}.dat", + ]; + + using var repository = GetRepository( + [ + .. expected, + $@"@@share\{a}\{c}.dat", + $@"@@share\{d}\{b}.dat", + $@"@@share\{a}{b}.dat", + $@"@@share\{c}\{a}{e}\{b}{e}.dat", + $@"@@share\{e}\{d}.dat", + ]); + + var results = repository.Search(new SearchQuery(terms: [a, b], exclusions: [])); + + Assert.Equal(expected.Order(StringComparer.Ordinal), results.Select(f => f.Filename)); + } + + [Fact] + public void Returns_Nothing_When_No_File_Matches_All_Terms() + { + var (a, b, c, d) = (Random(), Random(), Random(), Random()); + + using var repository = GetRepository( + [ + $@"@@share\{a}\{c}.dat", + $@"@@share\{a}\{d}.dat", + $@"@@share\{b}\{c}.dat", + $@"@@share\{b}\{d}.dat", + $@"@@share\{a}{b}.dat", + $@"@@share\{c}\{d}.dat", + ]); + + // make sure the files are searchable, so an empty result below means something + Assert.Equal(2, repository.Search(new SearchQuery(terms: [a], exclusions: [])).Count()); + + var results = repository.Search(new SearchQuery(terms: [a, b], exclusions: [])); + + Assert.Empty(results); + } + + [Fact] + public void Excludes_Files_Matching_Exclusion() + { + var (a, b, c, x, y) = (Random(), Random(), Random(), Random(), Random()); + + string[] expected = + [ + $@"@@share\{a}\{b}.dat", + $@"@@share\{a}\{c}.dat", + $@"@@share\{a}\{b}\{c}.dat", + ]; + + using var repository = GetRepository( + [ + .. expected, + $@"@@share\{a}\{x}.dat", + $@"@@share\{a}\{x}\{b}.dat", + $@"@@share\{a}\{c}{x}.dat", + $@"@@share\{y}\{b}.dat", + $@"@@share\{y}\{x}.dat", + ]); + + var results = repository.Search(new SearchQuery(terms: [a], exclusions: [x])); + + Assert.Equal(expected.Order(StringComparer.Ordinal), results.Select(f => f.Filename)); + } + + [Fact] + public void Excludes_Files_Matching_Any_Of_Several_Exclusions() + { + var (a, b, c, x, y, z) = (Random(), Random(), Random(), Random(), Random(), Random()); + + string[] expected = + [ + $@"@@share\{a}\{b}.dat", + $@"@@share\{a}\{c}.dat", + $@"@@share\{a}\{b}\{c}.dat", + ]; + + using var repository = GetRepository( + [ + .. expected, + $@"@@share\{a}\{x}.dat", + $@"@@share\{a}\{y}.dat", + $@"@@share\{a}\{x}\{y}.dat", + $@"@@share\{a}\{b}{y}.dat", + $@"@@share\{a}\{z}\{x}.dat", + $@"@@share\{z}\{b}.dat", + ]); + + var results = repository.Search(new SearchQuery(terms: [a], exclusions: [x, y])); + + Assert.Equal(expected.Order(StringComparer.Ordinal), results.Select(f => f.Filename)); + } + + [Fact] + public void Matches_Term_Containing_Single_Quote() + { + var (a, b, c, d) = (Random(), Random(), Random(), Random()); + + string[] expected = + [ + $@"@@share\{a}\{b}'{c}.dat", + $@"@@share\{d}\{b}'{c} {a}.dat", + ]; + + using var repository = GetRepository( + [ + .. expected, + $@"@@share\{a}\{b}.dat", + $@"@@share\{a}\{c}.dat", + $@"@@share\{a}\{c}'{b}.dat", + $@"@@share\{a}\{b}\{d}\{c}.dat", + $@"@@share\{d}\{a}.dat", + ]); + + var results = repository.Search(new SearchQuery(terms: [$"{b}'{c}"], exclusions: [])); + + Assert.Equal(expected.Order(StringComparer.Ordinal), results.Select(f => f.Filename)); + } + + [Fact] + public void Excludes_Files_Matching_Exclusion_Containing_Single_Quote() + { + var (a, b, c, d, e) = (Random(), Random(), Random(), Random(), Random()); + + string[] expected = + [ + $@"@@share\{a}\{b}.dat", + $@"@@share\{a}\{c}.dat", + $@"@@share\{a}\{c}'{b}.dat", + ]; + + using var repository = GetRepository( + [ + .. expected, + $@"@@share\{a}\{b}'{c}.dat", + $@"@@share\{a}\{d}\{b}'{c}.dat", + $@"@@share\{a}\{d}{b}'{c}{e}.dat", + $@"@@share\{e}\{b}.dat", + ]); + + var results = repository.Search(new SearchQuery(terms: [a], exclusions: [$"{b}'{c}"])); + + Assert.Equal(expected.Order(StringComparer.Ordinal), results.Select(f => f.Filename)); + } + + [Theory] + [InlineData("\"{0} {1}\"")] + [InlineData("{0}\"{1}")] + [InlineData("\"{0}\"{1}\"")] + [InlineData("{0} \"{1}")] + public void Matches_Term_Containing_Double_Quotes(string template) + { + var (a, b, c, d) = (Random(), Random(), Random(), Random()); + var term = string.Format(template, a, b); + + // a double quote in a term must be treated as a separator. if it were left in place it would end the + // phrase early, either breaking the query or splitting the term into separate words that match the + // decoys below. if it were removed instead, '{0}"{1}' would become a single word and match nothing + string[] expected = + [ + $@"@@share\{c}\{a}\{b}.dat", + $@"@@share\{a} {b}\{d}.dat", + ]; + + using var repository = GetRepository( + [ + .. expected, + $@"@@share\{b}\{a}.dat", + $@"@@share\{a}\{c}\{b}.dat", + $@"@@share\{a}{b}.dat", + $@"@@share\{a}\{d}.dat", + $@"@@share\{c}\{b}.dat", + ]); + + var results = repository.Search(new SearchQuery(terms: [term], exclusions: [])); + + Assert.Equal(expected.Order(StringComparer.Ordinal), results.Select(f => f.Filename)); + } + + [Theory] + [InlineData("\\")] + [InlineData("/")] + [InlineData(":")] + public void Matches_Term_Containing_Separator(string separator) + { + var (a, b, c, d) = (Random(), Random(), Random(), Random()); + + string[] expected = + [ + $@"@@share\{a}\{b}.dat", + $@"@@share\{c}\{a}\{b}\{d}.dat", + ]; + + using var repository = GetRepository( + [ + .. expected, + $@"@@share\{b}\{a}.dat", + $@"@@share\{a}\{c}\{b}.dat", + $@"@@share\{a}\{d}.dat", + $@"@@share\{c}\{b}.dat", + ]); + + var results = repository.Search(new SearchQuery(terms: [$"{a}{separator}{b}"], exclusions: [])); + + Assert.Equal(expected.Order(StringComparer.Ordinal), results.Select(f => f.Filename)); + } + + [Theory] + [InlineData("{0}') OR 1=1 --{1}")] + [InlineData("{0}' UNION SELECT maskedFilename, code, size, extension, attributeJson FROM files --{1}")] + [InlineData("{0}\" OR \"{1}")] + [InlineData("{0} OR {1}")] + [InlineData("{0} AND {1}")] + [InlineData("{0} NOT {1}")] + [InlineData("NEAR({0} {1})")] + [InlineData("maskedFilename:{0} {1}")] + public void Treats_Query_Syntax_In_Term_As_Text(string template) + { + var (a, b, c, d) = (Random(), Random(), Random(), Random()); + var term = string.Format(template, a, b); + + // only the file containing the literal term should match. if the term were interpreted as SQL or FTS + // syntax, either the query would fail and nothing would match, or some of the other files would match + string[] expected = + [ + $@"@@share\{c}\{term}.dat", + ]; + + using var repository = GetRepository( + [ + .. expected, + $@"@@share\{c}\{a}.dat", + $@"@@share\{c}\{b}.dat", + $@"@@share\{c}\{a} {b}.dat", + $@"@@share\{c}\{b} {a}.dat", + $@"@@share\{c}\{a}\{d}.dat", + $@"@@share\{d}\{c}.dat", + ]); + + var results = repository.Search(new SearchQuery(terms: [term], exclusions: [])); + + Assert.Equal(expected, results.Select(f => f.Filename)); + } + + [Fact] + public void Does_Not_Treat_Asterisk_As_Prefix_Wildcard() + { + var (a, b, c, d) = (Random(), Random(), Random(), Random()); + + string[] expected = + [ + $@"@@share\{c}\{a}.dat", + $@"@@share\{d}\{a}\{b}.dat", + ]; + + using var repository = GetRepository( + [ + .. expected, + $@"@@share\{c}\{a}{b}.dat", + $@"@@share\{c}\{a}{d}\{b}.dat", + $@"@@share\{c}\{b}.dat", + $@"@@share\{d}\{c}.dat", + ]); + + var results = repository.Search(new SearchQuery(terms: [$"{a}*"], exclusions: [])); + + Assert.Equal(expected.Order(StringComparer.Ordinal), results.Select(f => f.Filename)); + } + + [Fact] + public void Returns_First_Matches_Up_To_Limit() + { + var (a, b, c) = (Random(), Random(), Random()); + + string[] matching = + [ + $@"@@share\{a}\{Random()}.dat", + $@"@@share\{a}\{Random()}.dat", + $@"@@share\{a}\{Random()}.dat", + $@"@@share\{a}\{Random()}.dat", + $@"@@share\{a}\{Random()}.dat", + ]; + + using var repository = GetRepository( + [ + .. matching, + $@"@@share\{b}\{Random()}.dat", + $@"@@share\{b}\{Random()}.dat", + $@"@@share\{c}\{Random()}.dat", + ]); + + var results = repository.Search(new SearchQuery(terms: [a], exclusions: []), limit: 3); + + Assert.Equal(matching.Order(StringComparer.Ordinal).Take(3), results.Select(f => f.Filename)); + } + + [Fact] + public void Returns_Details_Of_Matching_File() + { + var (a, b, c) = (Random(), Random(), Random()); + var filename = $@"@@share\{a}\{b}.dat"; + + using var repository = GetRepository( + [ + $@"@@share\{a}\{c}.dat", + $@"@@share\{c}\{b}.dat", + $@"@@share\{c}\{a}.dat", + ]); + + var attributes = new List() { new(FileAttributeType.BitRate, 320), new(FileAttributeType.Length, 180) }; + repository.InsertFile(filename, originalFilename: filename, touchedAt: DateTime.UtcNow, new File(1, filename, 12345, "dat", attributes), timestamp: 1); + repository.RebuildFilenameIndex(); + + var result = Assert.Single(repository.Search(new SearchQuery(terms: [a, b], exclusions: []))); + + Assert.Equal(filename, result.Filename); + Assert.Equal(1, result.Code); + Assert.Equal(12345, result.Size); + Assert.Equal("dat", result.Extension); + Assert.Equal(320, result.BitRate); + Assert.Equal(180, result.Length); + } + } + + private static string Random() => Guid.NewGuid().ToString("N"); + + private static SqliteShareRepository GetRepository(string[] maskedFilenames) + { + var repository = new SqliteShareRepository($"Data Source=file:shares.test_{Guid.NewGuid():N}?mode=memory;Cache=shared"); + repository.Create(); + + foreach (var maskedFilename in maskedFilenames) + { + var file = new File(1, maskedFilename, 42, "dat", new List()); + repository.InsertFile(maskedFilename, originalFilename: maskedFilename, touchedAt: DateTime.UtcNow, file, timestamp: 1); + } + + repository.RebuildFilenameIndex(); + + return repository; + } + } +} -- cgit v1.2.3 From 00553595b561fbec0df272396a13c8dffb41dd2d Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 Oct 2026 15:57:54 -0500 Subject: fix error handling in files controller --- src/slskd/Files/API/FilesController.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/slskd/Files/API/FilesController.cs b/src/slskd/Files/API/FilesController.cs index 68898eaf..170ff26e 100644 --- a/src/slskd/Files/API/FilesController.cs +++ b/src/slskd/Files/API/FilesController.cs @@ -210,11 +210,16 @@ namespace slskd.Files.API return Ok(response); } - catch (SecurityException) + catch (UnauthorizedException) { Log.Warning("Directory listing of '{Directory}' forbidden", requestedDir); return Forbid(); } + catch (ArgumentException ex) + { + Log.Warning("Bad request: {Message}", ex.Message); + return BadRequest(ex.Message); + } catch (NotFoundException) { Log.Debug("Directory '{Directory}' not found", requestedDir); @@ -247,11 +252,16 @@ namespace slskd.Files.API success => NoContent(), failure => throw failure); } - catch (SecurityException) + catch (UnauthorizedException) { Log.Warning("Directory deletion of '{Directory}' forbidden", requestedDir); return Forbid(); } + catch (ArgumentException ex) + { + Log.Warning("Bad request: {Message}", ex.Message); + return BadRequest(ex.Message); + } catch (NotFoundException) { Log.Information("Directory '{Directory}' not found", requestedDir); @@ -284,11 +294,16 @@ namespace slskd.Files.API success => NoContent(), failure => throw failure); } - catch (SecurityException) + catch (UnauthorizedException) { Log.Warning("File deletion of '{File}' forbidden", requestedFilename); return Forbid(); } + catch (ArgumentException ex) + { + Log.Warning("Bad request: {Message}", ex.Message); + return BadRequest(ex.Message); + } catch (NotFoundException) { Log.Information("File '{File}' not found", requestedFilename); -- cgit v1.2.3 From b51f789bc3f15d5d8f9424f58f50014fbc58391a Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 Oct 2026 15:59:02 -0500 Subject: preemptively reject absolute file requests --- src/slskd/Files/API/FilesController.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Files/API/FilesController.cs b/src/slskd/Files/API/FilesController.cs index 170ff26e..8954c1ac 100644 --- a/src/slskd/Files/API/FilesController.cs +++ b/src/slskd/Files/API/FilesController.cs @@ -34,9 +34,9 @@ using Microsoft.Extensions.Options; namespace slskd.Files.API { + using System; using System.ComponentModel.DataAnnotations; using System.IO; - using System.Security; using System.Threading.Tasks; using Asp.Versioning; using Microsoft.AspNetCore.Authorization; @@ -192,7 +192,13 @@ namespace slskd.Files.API var requestedDir = (base64SubdirectoryName ?? string.Empty) .FromBase64() .Replace('\\', Path.DirectorySeparatorChar) - .Replace('/', Path.DirectorySeparatorChar); + .Replace('/', Path.DirectorySeparatorChar) + .TrimStart(Path.DirectorySeparatorChar); + + if (!FileSafety.IsPathRelative(requestedDir)) + { + return BadRequest("Path must be relative"); + } requestedDir = Path.GetFullPath(Path.Combine(rootDirectory, requestedDir)); @@ -240,6 +246,11 @@ namespace slskd.Files.API .Replace('/', Path.DirectorySeparatorChar) .TrimStart(Path.DirectorySeparatorChar); + if (!FileSafety.IsPathRelative(requestedDir)) + { + return BadRequest("Path must be relative"); + } + requestedDir = Path.GetFullPath(Path.Combine(rootDirectory, requestedDir)); Log.Information("Deleting directory '{Directory}'", requestedDir); @@ -282,6 +293,11 @@ namespace slskd.Files.API .Replace('/', Path.DirectorySeparatorChar) .TrimStart(Path.DirectorySeparatorChar); + if (!FileSafety.IsPathRelative(requestedFilename)) + { + return BadRequest("Path must be relative"); + } + requestedFilename = Path.GetFullPath(Path.Combine(rootDirectory, requestedFilename)); Log.Information("Deleting file '{File}'", requestedFilename); -- cgit v1.2.3 From 202a1ea1b57774c4d53605d3a26fa0bd0530165e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 Oct 2026 16:12:34 -0500 Subject: extraneous using --- src/slskd/Core/API/Controllers/ApplicationController.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Core/API/Controllers/ApplicationController.cs b/src/slskd/Core/API/Controllers/ApplicationController.cs index b90655aa..e015e612 100644 --- a/src/slskd/Core/API/Controllers/ApplicationController.cs +++ b/src/slskd/Core/API/Controllers/ApplicationController.cs @@ -36,7 +36,6 @@ namespace slskd.Core.API { using System; using System.Diagnostics; - using System.IO; using System.Threading.Tasks; using Asp.Versioning; using Microsoft.AspNetCore.Authorization; -- cgit v1.2.3 From be81b3b85b21d502feaf4918a0da92f445f7c2ab Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 Oct 2026 16:14:30 -0500 Subject: revert log tweak --- src/slskd/Core/API/Controllers/OptionsController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Core/API/Controllers/OptionsController.cs b/src/slskd/Core/API/Controllers/OptionsController.cs index 98028c76..e8769ca9 100644 --- a/src/slskd/Core/API/Controllers/OptionsController.cs +++ b/src/slskd/Core/API/Controllers/OptionsController.cs @@ -196,7 +196,7 @@ namespace slskd.Core.API if (!TryValidateYaml(yaml, out var error)) { - Log.Error("Failed to validate YAML configuration: {Error}", error); + Log.Error(error, "Failed to validate YAML configuration"); return BadRequest(error); } -- cgit v1.2.3