Skip to content

Potential fix for code scanning alert no. 25: Insecure randomness - #14

Merged
htomasz merged 1 commit into
mainfrom
alert-autofix-25
Apr 8, 2026
Merged

Potential fix for code scanning alert no. 25: Insecure randomness#14
htomasz merged 1 commit into
mainfrom
alert-autofix-25

Conversation

@htomasz

@htomasz htomasz commented Apr 8, 2026

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/htomasz/vultron/security/code-scanning/25

Use a cryptographically secure random source for _uid generation in the constructor, instead of Math.random().

Best fix in this file: replace line 4 with a Web Crypto API-based UUID when available (globalThis.crypto.randomUUID()), with a secure fallback using crypto.getRandomValues to create a hex suffix. This keeps functionality (unique per-instance string ID prefixed with vz-) while removing insecure randomness.

Change needed in vultron/vultron-zebrania-card.js:

  • In constructor(), replace:
    • this._uid = 'vz-' + Math.random().toString(36).substr(2, 9);
  • With a CSPRNG-backed assignment:
    • Prefer globalThis.crypto.randomUUID()
    • Fallback to globalThis.crypto.getRandomValues(new Uint8Array(16)) + hex encoding

No new imports are required.

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

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

@htomasz htomasz left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@htomasz htomasz left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@htomasz
htomasz marked this pull request as ready for review April 8, 2026 18:56
@htomasz
htomasz merged commit 0952d6d into main Apr 8, 2026
15 checks passed
@htomasz
htomasz deleted the alert-autofix-25 branch April 8, 2026 18:59
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