Reputation: 1
Hello All I have implemented the following pattern for sanitizing the XSS input. Can you help me if there is any possibility or any payload that can be constructed in bypassing the below patterns
str = str.replaceAll("\\<.*?\\>", ""); str = str.replaceAll("\\<.*?\\>", "");
private static final String XSS_PATTERN = "<(?:img\\s+src\\s*=\\s*[^>]+\\s+onerror\\s*=\\s*\"?[^>]*prompt\\(.*\\)[^>]*>|script\\s*>[^<]*alert\\(.*\\)[^<]*</script\\s*)>|<\\s*img\\s+src\\s*=\\s*[^>]+\\s+onerror\\s*=\\s*\"?[^>]*prompt\\(.*\\)[^>]*>|<\\s*img\\s+src\\s*=\\s*[^>]*\\b(onerror=eval\\(src\\))[^>]*>|script\\s*>.*\\</script\\s*>|style\\s*>.*\\</style\\s*>";
private static final String XSS_PATTERN2 = "<(?:img\\s+src\\s*=\\s*[^>]+\\s+onerror\\s*=\\s*\"?[^>]*prompt\\(.*\\)[^>]*>|script\\s*>[^<]*alert\\(.*\\)[^<]*</script\\s*)>|<\\s*img\\s+src\\s*=\\s*[^>]+\\s+onerror\\s*=\\s*\"?[^>]*prompt\\(.*\\)[^>]*>|<\\s*img\\s+src\\s*=\\s*[^>]*\\b(onerror=eval\\(src\\))[^>]*>|script\\s*>.*\\</script\\s*>|style\\s*>.*\\</style\\s*>";
Upvotes: 0
Views: 32