# TypeScript Unsafe Type Guard - ID: typescript-unsafe-type-guard - Severity: HIGH - CWE: CWE-704 (CWE-704) - Languages: TypeScript - Frameworks: typescript ## Description Type guards that always return true or use assertions without validation create type confusion, allowing untrusted data to bypass security checks. ## Detection Message Type guard '{function}' uses 'is' predicate but lacks proper runtime validation. This creates type confusion vulnerabilities. ## Remediation Implement proper runtime validation in type guards. ```typescript function isUser(obj: unknown): obj is User { if (typeof obj !== 'object' || obj === null) { return false; } const u = obj as Record; return ( typeof u.id === 'number' && typeof u.email === 'string' ); } ``` Learn more: https://shoulder.dev/learn/typescript/cwe-704/unsafe-type-guard ## Documentation [object Object] ## Related Rules - **tRPC Type Safety Bypass with Any** [MEDIUM]: - **TypeScript Unconstrained Generic Type Parameters** [MEDIUM]: - **TypeScript Strict Mode Disabled** [HIGH]: - **Unsafe 'any' Type in Security-Sensitive Context** [HIGH]: