Skip to content

Commit 692999f

Browse files
[mirotalkc2c] - fix(server): prevent cross-room signaling injection in relaySDP/relayICE
1 parent b8f7039 commit 692999f

5 files changed

Lines changed: 32 additions & 14 deletions

File tree

‎.env.template‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ====================================================
2-
# MiroTalk C2C v.1.3.02 - Environment Configuration
2+
# MiroTalk C2C v.1.3.03 - Environment Configuration
33
# ====================================================
44

55
# App environment

‎backend/server.js‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @license For private project or commercial purposes contact us at: license.mirotalk@gmail.com or purchase it directly via Code Canyon:
1010
* @license https://codecanyon.net/item/mirotalk-c2c-webrtc-real-time-cam-2-cam-video-conferences-and-screen-sharing/43383005
1111
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
12-
* @version 1.3.02
12+
* @version 1.3.03
1313
*/
1414

1515
require('dotenv').config();
@@ -464,9 +464,23 @@ io.sockets.on('connect', (socket) => {
464464
}
465465
});
466466

467+
function peersShareRoom(peerId) {
468+
if (typeof peerId !== 'string' || !peerId) return false;
469+
for (const channel in socket.channels) {
470+
if (channels[channel] && channels[channel][peerId]) {
471+
return true;
472+
}
473+
}
474+
return false;
475+
}
476+
467477
socket.on('relaySDP', (config) => {
468478
const { peerId, sessionDescription } = config;
469479

480+
if (!peersShareRoom(peerId)) {
481+
return log.warn('[' + socket.id + '] relaySDP blocked: no shared room with [' + peerId + ']');
482+
}
483+
470484
sendToPeer(peerId, sockets, 'sessionDescription', {
471485
peerId: socket.id,
472486
sessionDescription: sessionDescription,
@@ -479,6 +493,10 @@ io.sockets.on('connect', (socket) => {
479493
socket.on('relayICE', (config) => {
480494
const { peerId, iceCandidate } = config;
481495

496+
if (!peersShareRoom(peerId)) {
497+
return log.warn('[' + socket.id + '] relayICE blocked: no shared room with [' + peerId + ']');
498+
}
499+
482500
sendToPeer(peerId, sockets, 'iceCandidate', {
483501
peerId: socket.id,
484502
iceCandidate: iceCandidate,

‎frontend/js/client.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @license For private project or commercial purposes contact us at: license.mirotalk@gmail.com or purchase it directly via Code Canyon:
1010
* @license https://codecanyon.net/item/mirotalk-c2c-webrtc-real-time-cam-2-cam-video-conferences-and-screen-sharing/43383005
1111
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
12-
* @version 1.3.02
12+
* @version 1.3.03
1313
*/
1414

1515
const roomId = new URLSearchParams(window.location.search).get('room');

‎package-lock.json‎

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mirotalkc2c",
3-
"version": "1.3.02",
3+
"version": "1.3.03",
44
"description": "A free WebRTC Cam-2-Cam browser-based video calls",
55
"main": "server.js",
66
"scripts": {
@@ -44,7 +44,7 @@
4444
"colors": "^1.4.0",
4545
"compression": "^1.8.1",
4646
"cors": "^2.8.6",
47-
"dompurify": "^3.4.3",
47+
"dompurify": "^3.4.4",
4848
"dotenv": "^17.4.2",
4949
"express": "^5.2.1",
5050
"express-openid-connect": "^3.0.0",

0 commit comments

Comments
 (0)