/** * MultiModalGuard (L8) * * Detects hidden instructions and malicious content in multi-modal inputs * (images, audio, documents, base64 payloads). * * Threat Model: * - ASI01: Agent Goal Hijack via manipulated media * - Multi-Modal Injection: Hidden text in images, audio with embedded instructions * * Detection Capabilities: * - Image metadata (EXIF) injection * - Steganographic patterns * - Hidden text detection (white-on-white, etc.) * - Base64 embedded payloads * - Document macro/script detection * - Audio transcript injection markers */ export interface MultiModalGuardConfig { /** Enable EXIF/metadata scanning */ scanMetadata?: boolean; /** Enable base64 payload detection */ detectBase64Payloads?: boolean; /** Enable steganography detection heuristics */ detectSteganography?: boolean; /** Maximum allowed metadata size in bytes */ maxMetadataSize?: number; /** Suspicious patterns to detect in extracted text */ customPatterns?: RegExp[]; /** Allowed MIME types */ allowedMimeTypes?: string[]; /** Block all multi-modal content (strict mode) */ strictMode?: boolean; } export interface MultiModalContent { /** Content type: image, audio, document, base64 */ type: "image" | "audio" | "document" | "base64" | "url"; /** Raw content or base64 string */ content?: string; /** MIME type if known */ mimeType?: string; /** URL if remote content */ url?: string; /** Filename if provided */ filename?: string; /** Extracted metadata */ metadata?: Record; /** Any extracted text (OCR, transcripts, etc.) */ extractedText?: string; } export interface MultiModalGuardResult { allowed: boolean; reason: string; violations: string[]; request_id: string; content_analysis: { type: string; threats_detected: string[]; metadata_suspicious: boolean; hidden_content_detected: boolean; injection_patterns_found: string[]; risk_score: number; }; recommendations: string[]; } export declare class MultiModalGuard { private config; private readonly INJECTION_PATTERNS; private readonly SUSPICIOUS_METADATA_FIELDS; private readonly DANGEROUS_MIME_TYPES; private readonly STEGO_MARKERS; constructor(config?: MultiModalGuardConfig); /** * Analyze multi-modal content for hidden instructions or malicious payloads */ check(content: MultiModalContent, requestId?: string): MultiModalGuardResult; /** * Batch check multiple content items */ checkBatch(contents: MultiModalContent[], requestId?: string): MultiModalGuardResult; /** * Extract and analyze image metadata (EXIF simulation) * In production, use a proper EXIF parser */ parseImageMetadata(base64Image: string): Record; private scanMetadata; /** * @param rawHeuristics - Whether to run the invisible-character and * intra-token-homoglyph-mixing heuristics, which look for anomalies * introduced by an attacker in the ORIGINAL text. Must be false when * scanning an already-decoded/normalized variant: partial homoglyph * normalization (only the small set of commonly-spoofed letters) applied * to genuinely non-English text (e.g. a plain Cyrillic sentence) creates * artificial intra-token script mixing that isn't an attack, and would * otherwise false-positive on legitimate non-English content. */ private scanText; private detectBase64Payloads; private detectSteganography; private checkUrl; private generateRecommendations; }