Skip to content

Commit 4662be4

Browse files
Potential fix for code scanning alert no. 14: Use of password hash with insufficient computational effort
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent f7b9b05 commit 4662be4

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)