diff --git a/app/api/search/route.ts b/app/api/search/route.ts index e53d805..18a986c 100644 --- a/app/api/search/route.ts +++ b/app/api/search/route.ts @@ -11,13 +11,101 @@ interface HashDocument { created_at?: string; } +// Maximum allowed query length +const MAX_QUERY_LENGTH = 1000; + +// Characters that could be used in NoSQL/Elasticsearch injection attacks +const DANGEROUS_PATTERNS = [ + /[{}\[\]]/g, // JSON structure characters + /\$[a-zA-Z]/g, // MongoDB-style operators + /\\u[0-9a-fA-F]{4}/g, // Unicode escapes + /