Skip to content

Security: Room IDs are generated with non-cryptographic randomness#1235

Open
tuanaiseo wants to merge 1 commit intosuitenumerique:mainfrom
tuanaiseo:contribai/fix/security/room-ids-are-generated-with-non-cryptogr
Open

Security: Room IDs are generated with non-cryptographic randomness#1235
tuanaiseo wants to merge 1 commit intosuitenumerique:mainfrom
tuanaiseo:contribai/fix/security/room-ids-are-generated-with-non-cryptogr

Conversation

@tuanaiseo
Copy link
Copy Markdown

Problem

Room identifiers are created with Math.random(), which is predictable and not suitable for security-sensitive identifiers. Predictable room IDs increase the risk of room enumeration and unauthorized access attempts, especially when IDs are part of join URLs.

Severity: medium
File: src/frontend/src/features/rooms/utils/generateRoomId.ts

Solution

Use a cryptographically secure generator (crypto.getRandomValues / crypto.randomUUID) and increase effective entropy of room identifiers. Also enforce server-side authorization regardless of ID secrecy.

Changes

  • src/frontend/src/features/rooms/utils/generateRoomId.ts (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

…c rand

Room identifiers are created with `Math.random()`, which is predictable and not suitable for security-sensitive identifiers. Predictable room IDs increase the risk of room enumeration and unauthorized access attempts, especially when IDs are part of join URLs.

Affected files: generateRoomId.ts

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 3, 2026

@lebaudantoine
Copy link
Copy Markdown
Collaborator

@CodeRabbit full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

✅ Actions performed

Full review triggered.

@lebaudantoine
Copy link
Copy Markdown
Collaborator

I guess this would be more suitable to backport the generation of this id on the server side.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fb2f3ccc-b3ee-4fa3-b5d0-4fe2032ec674

📥 Commits

Reviewing files that changed from the base of the PR and between 6b656ee and 25cf0db.

📒 Files selected for processing (1)
  • src/frontend/src/features/rooms/utils/generateRoomId.ts

Walkthrough

The getRandomChar function in generateRoomId.ts was updated to replace Math.random() with crypto.getRandomValues() for cryptographically secure randomness. The implementation now employs rejection sampling to eliminate modulo bias when selecting characters from the a–z character set. The function signatures and behavior of dependent functions remain unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main security issue being addressed: replacing non-cryptographic randomness with cryptographically secure randomness for room ID generation.
Description check ✅ Passed The description provides comprehensive context about the security problem, solution, and changes made, directly relating to the implementation of cryptographically secure room ID generation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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