security: add comprehensive validation to sitemap index parser and stream #461
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses multiple security vulnerabilities in the sitemap index parsing and generation functionality by adding comprehensive validation and security checks.
Security Fixes
π΄ HIGH: Protocol Injection Prevention
javascript:,data:,file:, andftp:protocol injection attacksvalidateURL()for consistent security enforcementπ‘ MEDIUM: URL Length DoS Protection
π‘ MEDIUM: Memory Exhaustion Protection
maxEntriesparameter toparseSitemapIndex()with default limit of 50,000 entriesπ‘ MEDIUM: Inconsistent Validation Fixed
validateURL()π’ LOW-MEDIUM: Date Format Validation
π’ LOW: Empty URL Leakage Fixed
Changes
Modified Files
lib/sitemap-index-parser.tsvalidateURL()LIMITS.ISO_DATE_REGEXvalidateURLandLIMITSfrom validation/constants moduleslib/sitemap-index-stream.tsnew URL()check with centralizedvalidateURL()validateURLfrom validation moduletests/sitemap-index-security.test.ts(NEW)Test Results
β All 356 tests passing
Backward Compatibility
β 100% backward compatible
maxEntriesparameter is optional with sensible default (50,000)Example Usage
Security Impact
This PR protects against:
Checklist
π€ Generated with Claude Code
Co-Authored-By: Claude [email protected]