diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-11-15 18:37:10 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-11-15 18:37:10 -0600 |
| commit | abffd0c9c24a7b5d20962fc979c6eb581dcad9dd (patch) | |
| tree | 0790a182f4404676667261c56be0e7ab52f0044a | |
| parent | 5da8ec43e7369656781df3bac8f894167529a50e (diff) | |
| download | slskd-abffd0c9c24a7b5d20962fc979c6eb581dcad9dd.tar.gz | |
use fixedtimeequals when validating creds
| -rw-r--r-- | src/slskd/Relay/RelayService.cs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/slskd/Relay/RelayService.cs b/src/slskd/Relay/RelayService.cs index c063ceb2..c6c1f5d0 100644 --- a/src/slskd/Relay/RelayService.cs +++ b/src/slskd/Relay/RelayService.cs @@ -934,7 +934,9 @@ namespace slskd.Relay var tokenBytes = System.Text.Encoding.UTF8.GetBytes(token); var expectedCredential = Aes.Encrypt(tokenBytes, key).ToBase62(); - if (expectedCredential != credential) + if (!System.Security.Cryptography.CryptographicOperations.FixedTimeEquals( + left: System.Text.Encoding.UTF8.GetBytes(expectedCredential), + right: System.Text.Encoding.UTF8.GetBytes(credential ?? string.Empty))) { Log.Debug("Validation failed: Supplied credential {Credential} does not match expected credential {Expected}", credential, expectedCredential); return false; |
