Skip to content

Conversation

@ric-v
Copy link
Member

@ric-v ric-v commented Dec 14, 2025

Potential fix for https://github.com/dev-asterix/PgStudio/security/code-scanning/2

To fix this issue, we should replace the use of Math.random() for generating session IDs with a cryptographically secure random value source. In Node.js (including VSCode extensions), this is best achieved with the crypto module's randomBytes() function, which provides CSPRNG output. We'll import crypto at the top, and update the generateSessionId method to use crypto.randomBytes(), base64-encoded (or hex-encoded) for the unique suffix, in place of the insecure Math.random(). No other code changes are needed, as the functionality of generating a unique session ID with a timestamp and random suffix remains identical.


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>
@ric-v ric-v marked this pull request as ready for review December 14, 2025 05:30
@ric-v ric-v merged commit 8e2f476 into main Dec 14, 2025
5 checks passed
@ric-v ric-v deleted the alert-autofix-2 branch December 14, 2025 05:31
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.

2 participants