# Input Guard
Automatically detects and blocks common attack patterns before policy evaluation.
Automatic protection: Input Guard runs automatically as step 3 of the MCP Interceptor pipeline. All tool arguments are scanned for threats before policy evaluation and execution. You only need to configure it manually if you want to customize thresholds or add custom patterns.
Threat Types
PATH_TRAVERSALDetects ../, URL-encoded variants, null bytes, and sensitive system paths like /etc/passwd
SHELL_INJECTIONDetects shell metacharacters (; | & $ `), command substitution, redirects, and keywords like eval
WILDCARD_ABUSEBlocks recursive globs (**) and values with more than 3 wildcards
LENGTH_EXCEEDEDBlocks inputs exceeding the configured max length (default: 4,096 characters)
HIGH_ENTROPYDetects high-entropy strings (>4.5 bits/char) that may indicate encoded payloads or obfuscated exploits
Example
1// Path traversal - automatically blocked2const result = await api.validate('file_read', {3 path: '../../../etc/passwd',4});56// Response7{8 allowed: false,9 decision: {10 effect: 'DENY',11 reason: 'Path traversal pattern detected'12 },13 threats: [{14 type: 'PATH_TRAVERSAL',15 message: 'Path traversal pattern detected',16 field: 'path'17 }]18}
Custom Input Guard
1import { InputGuard } from '@solongate/sdk';23const guard = new InputGuard({4 maxLength: 5000, // Custom max length5 enablePathTraversal: true, // Enable path traversal detection6 enableShellInjection: true, // Enable shell injection detection7 enableSqlInjection: true, // Enable SQL injection detection8 customPatterns: [ // Custom regex patterns9 { name: 'CUSTOM_THREAT', pattern: /dangerous_pattern/i }10 ]11});1213const threats = guard.scan({14 path: '/data/file.txt',15 content: 'some content'16});1718if (threats.length > 0) {19 console.log('Threats detected:', threats);20}