Skip to content

fix: teamserver unauthenticated denial of service #547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions teamserver/cmd/server/teamserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,11 @@ func (t *Teamserver) handleRequest(id string) {
if isExist {
return
}



if !t.ClientAuthenticate(pk) {
logger.Error("Client [User: " + pk.Body.Info["User"].(string) + "] failed to Authenticate! (" + colors.Red(client.GlobalIP) + ")")
logger.Error("Client [User: " + pk.Head.User + "] failed to Authenticate! (" + colors.Red(client.GlobalIP) + ")")
err := t.SendEvent(id, events.Authenticated(false))
if err != nil {
logger.Error("client (" + colors.Red(id) + ") error while sending authenticate message: " + colors.Red(err))
Expand All @@ -566,7 +569,7 @@ func (t *Teamserver) handleRequest(id string) {
return
} else {

logger.Good("User <" + colors.Blue(pk.Body.Info["User"].(string)) + "> " + colors.Green("Authenticated"))
logger.Good("User <" + colors.Blue(pk.Head.User) + "> " + colors.Green("Authenticated"))

client.Authenticated = true
client.ClientID = id
Expand All @@ -577,7 +580,7 @@ func (t *Teamserver) handleRequest(id string) {
}
}

client.Username = pk.Body.Info["User"].(string)
client.Username = pk.Head.User
packageNewUser := events.ChatLog.NewUserConnected(client.Username)
t.EventAppend(packageNewUser)
t.EventBroadcast(id, packageNewUser)
Expand Down Expand Up @@ -661,7 +664,7 @@ func (t *Teamserver) ClientAuthenticate(pk packager.Package) bool {

// check if the operator was even found
if UserFound {
if pk.Body.Info["Password"].(string) == UserPassword {
if password, ok := pk.Body.Info["Password"].(string); ok && password == UserPassword {
logger.Debug("User " + colors.Red(UserName) + " is authenticated")
return true
}
Expand All @@ -683,7 +686,11 @@ func (t *Teamserver) ClientAuthenticate(pk packager.Package) bool {
logger.Error("Not a Authenticate request")
}

logger.Error("Client failed to authenticate with password hash :: " + pk.Body.Info["Password"].(string))
if password, ok := pk.Body.Info["Password"].(string); ok {
logger.Error("Client failed to authenticate with password hash :: " + password)
} else {
logger.Error("Client failed to authenticate, password is nil")
}
return false
}

Expand Down