Skip to content

Commit fca969f

Browse files
committed
fix: prevent URL substring injection in platform detection
Parse URL hostname properly instead of using substring matching to prevent malicious URLs from being detected as legitimate meeting platforms. Before: url.includes("meet.google.com") matched evil.com/meet.google.com After: hostname === "meet.google.com" or hostname.endsWith(".zoom.us") Fixes security vulnerability identified by GitHub security bot.
1 parent 8d0ef6f commit fca969f

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/main/services/recallRecording.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,36 @@ export function initializeRecallSDK(
186186
}
187187

188188
function detectPlatform(window: { url?: string; title?: string }): string {
189-
const url = window.url?.toLowerCase() || "";
189+
const urlString = window.url?.toLowerCase() || "";
190190
const title = window.title?.toLowerCase() || "";
191191

192-
if (url.includes("zoom.us") || title.includes("zoom")) {
192+
let hostname = "";
193+
try {
194+
if (urlString) {
195+
const parsedUrl = new URL(urlString);
196+
hostname = parsedUrl.hostname;
197+
}
198+
} catch {
199+
// Invalid URL, fall back to title-based detection only
200+
}
201+
202+
if (
203+
hostname === "zoom.us" ||
204+
hostname.endsWith(".zoom.us") ||
205+
title.includes("zoom")
206+
) {
193207
return "zoom";
194208
}
195209

196-
if (url.includes("teams.microsoft.com") || title.includes("teams")) {
210+
if (
211+
hostname === "teams.microsoft.com" ||
212+
hostname.endsWith(".teams.microsoft.com") ||
213+
title.includes("teams")
214+
) {
197215
return "teams";
198216
}
199217

200-
if (url.includes("meet.google.com") || title.includes("google meet")) {
218+
if (hostname === "meet.google.com" || title.includes("google meet")) {
201219
return "meet";
202220
}
203221

0 commit comments

Comments
 (0)