-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
Feat/connect: Entropy check workflow in ResetDevice #15887
base: develop
Are you sure you want to change the base?
Conversation
🚀 Expo preview is ready!
|
Buffer.from(options.trezorEntropy, 'hex'), | ||
Buffer.from(options.hostEntropy, 'hex'), | ||
]); | ||
const entropy = crypto.createHash('sha256').update(data).digest(); |
Check failure
Code scanning / CodeQL
Use of password hash with insufficient computational effort
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 16 hours ago
To fix the problem, we should replace the use of crypto.createHash('sha256')
with a more secure password hashing scheme such as bcrypt
. This will ensure that the hashed entropy data is 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 entropy data.
- Install the
bcrypt
library if it is not already installed. - Import the
bcrypt
library in the relevant file. - Replace the
crypto.createHash('sha256')
function withbcrypt.hashSync
to hash the entropy data.
-
Copy modified line R3 -
Copy modified lines R94-R95
@@ -2,2 +2,3 @@ | ||
import crypto from 'crypto'; | ||
import bcrypt from 'bcrypt'; | ||
|
||
@@ -92,3 +93,4 @@ | ||
]); | ||
const entropy = crypto.createHash('sha256').update(data).digest(); | ||
const saltRounds = 10; | ||
const entropy = Buffer.from(bcrypt.hashSync(data.toString('hex'), saltRounds), 'hex'); | ||
const strength = Math.floor(options.strength / 8); |
-
Copy modified lines R89-R90
@@ -88,3 +88,4 @@ | ||
"bs58check": "^4.0.0", | ||
"cross-fetch": "^4.0.0" | ||
"cross-fetch": "^4.0.0", | ||
"bcrypt": "^5.1.1" | ||
}, |
Package | Version | Security advisories |
bcrypt (npm) | 5.1.1 | None |
1f5d46a
to
7030c83
Compare
Description
implementation of entropy check workflow
TODO: