Skip to content

security: replace Math.random with crypto.randomUUID in structuredLogger (#443)#544

Open
davidsoniaudin2-oss wants to merge 1 commit into
MettaChain:mainfrom
davidsoniaudin2-oss:security/crypto-randomuuid
Open

security: replace Math.random with crypto.randomUUID in structuredLogger (#443)#544
davidsoniaudin2-oss wants to merge 1 commit into
MettaChain:mainfrom
davidsoniaudin2-oss:security/crypto-randomuuid

Conversation

@davidsoniaudin2-oss

Copy link
Copy Markdown

Description

Replaces insecure \Math.random()\ usage with \crypto.randomUUID()\ in the structured logger for session ID and error ID generation.

Changes

  • Replace \Math.random().toString(36).substring(2, 9)\ with \crypto.randomUUID()\ in sessionId generation
  • Replace \Math.random().toString(36).substring(2, 9)\ with \crypto.randomUUID()\ in error ID generation
  • Add structuredLogger tests asserting crypto.randomUUID usage and non-predictability
  • Add crypto.randomUUID polyfill to jest.setup.js for jsdom compatibility

Related Issues

Closes #443 - Math.random used for structured logger sessionId

…ger (MettaChain#443)

- Replace Math.random-based sessionId generation with crypto.randomUUID()
- Replace Math.random-based error ID generation with crypto.randomUUID()
- Add structuredLogger tests asserting crypto.randomUUID usage
- Add crypto.randomUUID polyfill to jest.setup.js for jsdom environment
- Remove unpredictable Math.random usage from security-sensitive ID generation
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@davidsoniaudin2-oss Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

security: Math.random used for structured logger sessionId

2 participants