Skip to content

Potential fix for code scanning alert no. 14: Use of password hash with insufficient computational effort#105

Merged
zeroc0d3 merged 1 commit into
mainfrom
alert-autofix-14
May 25, 2026
Merged

Potential fix for code scanning alert no. 14: Use of password hash with insufficient computational effort#105
zeroc0d3 merged 1 commit into
mainfrom
alert-autofix-14

Conversation

@zeroc0d3
Copy link
Copy Markdown
Member

Potential fix for https://github.com/telemetryflow/telemetryflow-core/security/code-scanning/14

Use a memory/CPU-hard password hashing function instead of raw SHA-256 for apiKeySecret. Since this file already imports Node crypto, the best minimal fix is to switch to crypto.scryptSync(...) with a per-key random salt, and store the result in a parseable format (e.g., salt:hash). This avoids adding external dependencies and keeps behavior (store derived secret string, return raw key once) unchanged.

What to change (in backend/src/modules/api-keys/domain/aggregates/ApiKey.ts):

  • In rotate(...), replace:
    • const apiKeySecret = crypto.createHash('sha256').update(rawKeySecret).digest('hex');
  • With:
    • generate random salt via crypto.randomBytes(16).toString('hex')
    • derive hash via crypto.scryptSync(rawKeySecret, salt, 64).toString('hex')
    • store as ${salt}:${derivedKey} in apiKeySecret

No new imports are needed (already using crypto).

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…th insufficient computational effort

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@zeroc0d3 zeroc0d3 marked this pull request as ready for review May 25, 2026 16:38
@zeroc0d3 zeroc0d3 merged commit e6729bf into main May 25, 2026
7 checks passed
@zeroc0d3 zeroc0d3 deleted the alert-autofix-14 branch May 25, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant