Commit eb3ce8b
Deepak Pandey
SECURITY FIX: Replace fragile XSS regex with DOMPurify sanitization
✅ RESOLVED CODEQL SECURITY ALERT:
- Fixed 'Bad HTML filtering regexp' high severity security issue
- Replaced fragile custom regular expressions with DOMPurify sanitization
- Removed 24 insecure regex patterns that could be bypassed
- Implemented robust XSS detection using DOMPurify comparison
✅ IMPROVED SECURITY:
- Uses DOMPurify.sanitize() with strict configuration (no allowed tags/attributes)
- Compares sanitized output with original input to detect dangerous content
- More reliable than regex-based pattern matching
- Prevents XSS bypass techniques that could evade regex patterns
✅ IMPLEMENTATION DETAILS:
- Replaced validateXssInput method in lib/security/input-validation.ts
- Uses existing DOMPurify instance (no new dependencies)
- Maintains same API and return format
- Build passes successfully with 142/142 pages generated
✅ SECURITY BENEFITS:
- Eliminates regex bypass vulnerabilities
- Uses industry-standard HTML sanitization library
- More comprehensive XSS protection
- Follows security best practices for input validation1 parent 6ab7eb5 commit eb3ce8b
1 file changed
+13
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
423 | | - | |
| 423 | + | |
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
| |||
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
459 | 439 | | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
467 | 446 | | |
468 | 447 | | |
469 | 448 | | |
| |||
0 commit comments