Skip to content

Commit

Permalink
feat: allowlist commands (#767)
Browse files Browse the repository at this point in the history
  • Loading branch information
baxen authored Jan 25, 2025
1 parent 56e5b0f commit dcfb769
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ui/desktop/src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,17 @@ export async function addExtensionFromDeepLink(url: string, navigate: NavigateFu
throw new Error("Missing required 'cmd' parameter in the URL");
}

// Validate that the command is one of the allowed commands
const allowedCommands = ['npx', 'uvx', 'goosed'];
if (!allowedCommands.includes(cmd)) {
throw new Error(`Invalid command: ${cmd}. Only ${allowedCommands.join(', ')} are allowed.`);
}

// Check for security risk with npx -c command
const args = parsedUrl.searchParams.getAll('arg');
if (cmd === 'npx' && args.includes('-c')) {
throw new Error('Error: npx with -c argument can lead to code injection');
}
const envList = parsedUrl.searchParams.getAll('env');
const id = parsedUrl.searchParams.get('id');
const name = parsedUrl.searchParams.get('name');
Expand Down

0 comments on commit dcfb769

Please sign in to comment.