Skip to content

Commit dcfb769

Browse files
authored
feat: allowlist commands (#767)
1 parent 56e5b0f commit dcfb769

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ui/desktop/src/extensions.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,17 @@ export async function addExtensionFromDeepLink(url: string, navigate: NavigateFu
265265
throw new Error("Missing required 'cmd' parameter in the URL");
266266
}
267267

268+
// Validate that the command is one of the allowed commands
269+
const allowedCommands = ['npx', 'uvx', 'goosed'];
270+
if (!allowedCommands.includes(cmd)) {
271+
throw new Error(`Invalid command: ${cmd}. Only ${allowedCommands.join(', ')} are allowed.`);
272+
}
273+
274+
// Check for security risk with npx -c command
268275
const args = parsedUrl.searchParams.getAll('arg');
276+
if (cmd === 'npx' && args.includes('-c')) {
277+
throw new Error('Error: npx with -c argument can lead to code injection');
278+
}
269279
const envList = parsedUrl.searchParams.getAll('env');
270280
const id = parsedUrl.searchParams.get('id');
271281
const name = parsedUrl.searchParams.get('name');

0 commit comments

Comments
 (0)