-
Notifications
You must be signed in to change notification settings - Fork 127
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
Kubero V3 refactoring #619
base: main
Are you sure you want to change the base?
Conversation
…ith kubero v2.
(WIP) add initial auth function
… in path expression Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…ain-refactored
|
||
const password = crypto | ||
.createHmac('sha256', process.env.KUBERO_SESSION_KEY) | ||
.update(pass) |
Check failure
Code scanning / CodeQL
Use of password hash with insufficient computational effort High
an access to password
Password from
an access to password
Password from
an access to password
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 11 hours ago
To fix the problem, we need to replace the current password hashing method with a more secure one, such as bcrypt
. This will involve:
- Importing the
bcrypt
library. - Updating the
validateUser
method to usebcrypt
for password comparison. - Ensuring that the
bcrypt
library is installed as a dependency.
-
Copy modified line R14 -
Copy modified lines R37-R38
@@ -13,3 +13,3 @@ | ||
import { JwtService } from '@nestjs/jwt'; | ||
import * as crypto from 'crypto'; | ||
import * as bcrypt from 'bcrypt'; | ||
|
||
@@ -36,7 +36,4 @@ | ||
|
||
const password = crypto | ||
.createHmac('sha256', process.env.KUBERO_SESSION_KEY) | ||
.update(pass) | ||
.digest('hex'); | ||
if (user.password === password) { | ||
const passwordMatch = await bcrypt.compare(pass, user.password); | ||
if (passwordMatch) { | ||
const { password, ...result } = user; |
); | ||
password = crypto | ||
.createHmac('sha256', process.env.KUBERO_SESSION_KEY) | ||
.update(password) |
Check failure
Code scanning / CodeQL
Use of password hash with insufficient computational effort High
an access to password
Password from
an access to password
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 24 days ago
To fix the problem, we should replace the use of crypto.createHmac('sha256', ...)
with a more secure password hashing scheme such as bcrypt
. This will ensure that the password hashing process requires significant computational effort, making it more resistant to brute-force attacks.
The best way to fix the problem without changing existing functionality is to use the bcrypt
library to hash the passwords. We will need to import the bcrypt
library, update the password hashing logic to use bcrypt.hashSync
, and ensure that the salt is properly generated and used.
-
Copy modified line R4 -
Copy modified lines R46-R47
@@ -3,3 +3,3 @@ | ||
dotenv.config(); | ||
import * as crypto from 'crypto'; | ||
import * as bcrypt from 'bcrypt'; | ||
|
||
@@ -45,6 +45,4 @@ | ||
); | ||
password = crypto | ||
.createHmac('sha256', process.env.KUBERO_SESSION_KEY) | ||
.update(password) | ||
.digest('hex'); | ||
const saltRounds = 10; | ||
password = bcrypt.hashSync(password, saltRounds); | ||
} |
Description
Fixes # (issue)
Type of change
How Has This Been Tested?
Test Configuration:
Checklist: