Skip to content

Commit fc260b2

Browse files
tuanaiseolebaudantoine
authored andcommitted
🔒️(frontend) room ids are generated with non-cryptographic 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>
1 parent cd77999 commit fc260b2

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to
1616

1717
- ♻(frontend) standardize role terminology across localizations
1818
- 🐛(backend) make start-recording atomic and fault-tolerant
19+
- 🔒️(frontend) room ids are generated with non-cryptographic rand
1920

2021
## [1.15.0] - 2026-04-30
2122

src/frontend/src/features/rooms/utils/generateRoomId.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
// Google Meet uses only letters in a room identifier
22
const ROOM_ID_ALLOWED_CHARACTERS = 'abcdefghijklmnopqrstuvwxyz'
33

4-
const getRandomChar = () =>
5-
ROOM_ID_ALLOWED_CHARACTERS[
6-
Math.floor(Math.random() * ROOM_ID_ALLOWED_CHARACTERS.length)
4+
const getRandomChar = () => {
5+
const maxValue =
6+
Math.floor(0x100000000 / ROOM_ID_ALLOWED_CHARACTERS.length) *
7+
ROOM_ID_ALLOWED_CHARACTERS.length
8+
const randomValue = new Uint32Array(1)
9+
10+
do {
11+
crypto.getRandomValues(randomValue)
12+
} while (randomValue[0] >= maxValue)
13+
14+
return ROOM_ID_ALLOWED_CHARACTERS[
15+
randomValue[0] % ROOM_ID_ALLOWED_CHARACTERS.length
716
]
17+
}
818

919
const generateSegment = (length: number): string =>
1020
Array.from(Array(length), getRandomChar).join('')

0 commit comments

Comments
 (0)