Skip to content

Commit 6c089bc

Browse files
Validate flags used in MCP server config commands
1 parent 5495511 commit 6c089bc

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

packages/components/nodes/tools/MCP/core.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ export const validateCommandFlags = (command: string, args: string[]): void => {
272272
npx: [
273273
'-c', // Execute shell commands
274274
'--call', // Execute shell commands
275-
'--shell-auto-fallback' // Shell execution fallback
275+
'--shell-auto-fallback', // Shell execution fallback
276+
'-y' // Auto-confirms installation prompts
276277
],
277278
node: [
278279
'-e', // Execute JavaScript code

packages/components/test/nodes/tools/MCP/core.test.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ describe('MCP Security Validations', () => {
2727
}).toThrow("Argument '--shell-auto-fallback' is not allowed for command 'npx'")
2828
})
2929

30+
it('should block -y flag', () => {
31+
expect(() => {
32+
validateCommandFlags('npx', ['-y', 'https://test-malicious-download.com'])
33+
}).toThrow("Argument '-y' is not allowed for command 'npx'")
34+
})
35+
3036
it('should block case variations', () => {
3137
expect(() => {
3238
validateCommandFlags('npx', ['-C', 'command'])
@@ -41,10 +47,6 @@ describe('MCP Security Validations', () => {
4147
expect(() => {
4248
validateCommandFlags('npx', ['@modelcontextprotocol/server-filesystem', '/tmp'])
4349
}).not.toThrow()
44-
45-
expect(() => {
46-
validateCommandFlags('npx', ['-y', '@modelcontextprotocol/server-github'])
47-
}).not.toThrow()
4850
})
4951
})
5052

@@ -393,14 +395,6 @@ describe('MCP Security Validations', () => {
393395
})
394396

395397
it('should allow legitimate MCP server configurations', () => {
396-
expect(() => {
397-
validateMCPServerConfig({
398-
command: 'npx',
399-
args: ['-y', '@modelcontextprotocol/server-github'],
400-
env: { GITHUB_TOKEN: 'token123' }
401-
})
402-
}).not.toThrow()
403-
404398
expect(() => {
405399
validateMCPServerConfig({
406400
command: 'node',

0 commit comments

Comments
 (0)