fix(desktop): validate URL scheme in open-external IPC handler

This commit is contained in:
CREDO23 2026-03-18 20:58:49 +02:00
parent 572e7999b2
commit 3b19b54b2b

View file

@ -38,7 +38,7 @@ let deepLinkUrl: string | null = null;
let serverPort: number = 3000; // overwritten at startup with a free port
const PROTOCOL = 'surfsense';
// Injected at compile time from .env.desktop via esbuild define
// Injected at compile time from .env via esbuild define
const HOSTED_FRONTEND_URL = process.env.HOSTED_FRONTEND_URL as string;
function getStandalonePath(): string {
@ -145,7 +145,14 @@ function createWindow() {
// IPC handlers
ipcMain.on('open-external', (_event, url: string) => {
shell.openExternal(url);
try {
const parsed = new URL(url);
if (parsed.protocol === 'http:' || parsed.protocol === 'https:') {
shell.openExternal(url);
}
} catch {
// invalid URL — ignore
}
});
ipcMain.handle('get-app-version', () => {