Skip to content
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

GET_PASSWORD_HASH / VERIFY_PASSWORD_HASH slow down the server thread #2660

Open
Korioz opened this issue Jul 21, 2024 · 2 comments
Open

GET_PASSWORD_HASH / VERIFY_PASSWORD_HASH slow down the server thread #2660

Korioz opened this issue Jul 21, 2024 · 2 comments
Assignees
Labels

Comments

@Korioz
Copy link
Contributor

Korioz commented Jul 21, 2024

What happened?

Password hash natives uses bcrypt under the hood, bcrypt is designed to be slow the issue is not that it is slow, the issue is that calling password hashing natives will make the server thread hitch during the operations.

Maybe providing async alternatives natives and executing bcrypt operations in another thread would be a viable solution.

Expected result

No server thread hitch.

Reproduction steps

  1. Execute a server-side script containing this :
RegisterCommand('testpass', function()
    local pass = 'MyVeryStrongPassword123'
    
    local timeNow = GetGameTimer()
    local passHash = GetPasswordHash(pass)
    VerifyPasswordHash(pass, passHash)
    print(('%u ms elapsed during password operations'):format(GetGameTimer() - timeNow))
end, false)
  1. Type testpass in Console and see the output.

Importancy

Slight inconvenience

Area(s)

FXServer, Natives

Specific version(s)

Tested on Server 8867 and olders (this issue has been here for years)

Additional information

No response

@Korioz Korioz added bug triage Needs a preliminary assessment to determine the urgency and required action labels Jul 21, 2024
@Zjarany-Ksiezyc
Copy link

just use

local function getPasswordHash(pass)
    return joaat(pass)
end

local function verifyPasswordHash(pass, hash)
    return getPasswordHash(pass) == hash
end

@CrunchyBadger
Copy link

@Korioz This is a hack workaround till its fixed if you need it.
https://github.com/CrunchyBadger/fivem-bcrypt-async

(Will probably break with different fx server versions, ik it doesn't work on 8981)

Working on latest.

Works same as natives but you need to use exports.

@FabianTerhorst FabianTerhorst self-assigned this Sep 18, 2024
@FabianTerhorst FabianTerhorst removed the triage Needs a preliminary assessment to determine the urgency and required action label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants