Conversation
…h insufficient computational effort Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Potential fix for https://github.com/Tanker187/firebase-admin-node/security/code-scanning/8
In general, the problem occurs because a password is hashed using a fast, single-iteration HMAC-SHA256, which does not provide the computational hardness required for password storage. To fix this, we should use a dedicated password hashing function, such as bcrypt, PBKDF2, scrypt, or Argon2. In Node’s standard library,
crypto.pbkdf2/pbkdf2Syncis the readily available KDF; the file already importsbcryptas well, butpbkdf2will integrate more naturally with existing Buffer-based code and allows us to avoid changingimportOptionssemantics too much.The single best fix here is to replace the direct HMAC-SHA256 computation on line 1951 with a PBKDF2-based derivation that uses the password and salt as separate parameters, with an adequate iteration count and key length. Since this is a test file and we must not alter behavior outside the shown snippet, we will:
crypto.createHmac('sha256', currentHashKey).update(rawPassword + rawSalt).digest();crypto.pbkdf2Sync(rawPassword, rawSalt, 100000, 32, 'sha256');This keeps
passwordHashas aBuffer, matching the previous type, and remains compatible with the surrounding test logic (which only checks that the user can be imported and retrieved). All changes occur intest/integration/auth.spec.tsaround theimportUsers() should upload a user to the specified tenanttest. No new imports are necessary, sincecryptois already imported. We won’t modifyimportOptions.hashitself, as it’s not shown and may be used elsewhere in the tests.Suggested fixes powered by Copilot Autofix. Review carefully before merging.