Skip to content

Commit 69aeedc

Browse files
committed
refactor(timing-attack): simplify by removing configurable delay
- Remove GOTRUE_SECURITY_TIMING_OBFUSCATION_DELAY config option - Keep bcrypt-based timing obfuscation (provides ~100ms constant time) - Simplify implementation while maintaining protection against basic timing attacks
1 parent 4626701 commit 69aeedc

File tree

3 files changed

+1
-6
lines changed

3 files changed

+1
-6
lines changed

example.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ GOTRUE_LOG_LEVEL="debug"
244244
GOTRUE_SECURITY_REFRESH_TOKEN_ROTATION_ENABLED="false"
245245
GOTRUE_SECURITY_REFRESH_TOKEN_REUSE_INTERVAL="0"
246246
GOTRUE_SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION="false"
247-
GOTRUE_SECURITY_TIMING_OBFUSCATION_DELAY="0"
248247
GOTRUE_SECURITY_UPDATE_PASSWORD_REQUIRE_CURRENT_PASSWORD="false"
249248
GOTRUE_OPERATOR_TOKEN="unused-operator-token"
250249
GOTRUE_RATE_LIMIT_HEADER="X-Forwarded-For"

internal/api/token.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package api
33
import (
44
"context"
55
"net/http"
6-
"time"
76

87
"github.com/gofrs/uuid"
98

@@ -40,11 +39,9 @@ const InvalidLoginMessage = "Invalid login credentials"
4039
const dummyPasswordHash = "$2a$10$JUbiChr4qVqzEEHDLbRmgOvGTUajEl0g6JJjOzN.drbF9oX.iL/sq"
4140

4241
// performDummyPasswordVerification prevents user enumeration via timing attacks
42+
// by performing a bcrypt comparison even when user is not found
4343
func (a *API) performDummyPasswordVerification(ctx context.Context, password string) {
4444
_ = crypto.CompareHashAndPassword(ctx, dummyPasswordHash, password)
45-
if delayMs := a.config.Security.TimingObfuscationDelay; delayMs > 0 {
46-
time.Sleep(time.Duration(delayMs) * time.Millisecond)
47-
}
4845
}
4946

5047
// Token is the endpoint for OAuth access token requests

internal/conf/configuration.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,6 @@ type SecurityConfiguration struct {
731731
UpdatePasswordRequireReauthentication bool `json:"update_password_require_reauthentication" split_words:"true"`
732732
UpdatePasswordRequireCurrentPassword bool `json:"update_password_require_current_password" split_words:"true" default:"false"`
733733
ManualLinkingEnabled bool `json:"manual_linking_enabled" split_words:"true" default:"false"`
734-
TimingObfuscationDelay int `json:"timing_obfuscation_delay" split_words:"true" default:"0"`
735734

736735
DBEncryption DatabaseEncryptionConfiguration `json:"database_encryption" split_words:"true"`
737736
}

0 commit comments

Comments
 (0)