feat(#285): Add input sanitization for XSS prevention
Security improvements: - Create sanitization utility using sanitize-html library - Add @Sanitize() and @SanitizeObject() decorators for DTOs - Apply sanitization to vulnerable fields: - Connection rejection/disconnection reasons - Connection metadata - Identity linking metadata - Command payloads - Remove script tags, event handlers, javascript: URLs - Prevent data exfiltration, CSS-based XSS, SVG-based XSS Changes: - Add sanitize.util.ts with recursive sanitization functions - Add sanitize.decorator.ts for class-transformer integration - Update connection.dto.ts with sanitization decorators - Update identity-linking.dto.ts with sanitization decorators - Update command.dto.ts with sanitization decorators - Add comprehensive test coverage including attack vectors Part of M7.1 Remediation Sprint P1 security fixes. Fixes #285 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
import { IsString, IsObject, IsNotEmpty, IsNumber } from "class-validator";
|
||||
import type { CommandMessage } from "../types/message.types";
|
||||
import { SanitizeObject } from "../../common/decorators/sanitize.decorator";
|
||||
|
||||
/**
|
||||
* DTO for sending a command to a remote instance
|
||||
@@ -21,6 +22,7 @@ export class SendCommandDto {
|
||||
|
||||
@IsObject()
|
||||
@IsNotEmpty()
|
||||
@SanitizeObject()
|
||||
payload!: Record<string, unknown>;
|
||||
}
|
||||
|
||||
@@ -42,6 +44,7 @@ export class IncomingCommandDto implements CommandMessage {
|
||||
|
||||
@IsObject()
|
||||
@IsNotEmpty()
|
||||
@SanitizeObject()
|
||||
payload!: Record<string, unknown>;
|
||||
|
||||
@IsNumber()
|
||||
|
||||
Reference in New Issue
Block a user