Skip to content

Commit e6729bf

Browse files
authored
Merge pull request #105 from telemetryflow/alert-autofix-14
Potential fix for code scanning alert no. 14: Use of password hash with insufficient computational effort
2 parents f7b9b05 + 4662be4 commit e6729bf

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • backend/src/modules/api-keys/domain/aggregates

backend/src/modules/api-keys/domain/aggregates/ApiKey.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ export class ApiKey extends AggregateRoot<ApiKeyId> {
268268
const rawKeySecret = ApiKey.generateApiKeySecret();
269269
const rawEncryptionKey = ApiKey.generateEncryptKey();
270270
const keyHint = rawKeySecret.slice(-4);
271-
const apiKeySecret = crypto.createHash('sha256').update(rawKeySecret).digest('hex');
271+
const salt = crypto.randomBytes(16).toString('hex');
272+
const derivedKey = crypto.scryptSync(rawKeySecret, salt, 64).toString('hex');
273+
const apiKeySecret = `${salt}:${derivedKey}`;
272274

273275
this.props.apiKeySecret = apiKeySecret;
274276
this.props.keyHint = keyHint;

0 commit comments

Comments
 (0)