CVE-2021-27516
📋 TL;DR
URI.js versions before 1.19.6 incorrectly parse URIs containing backslashes (like http:\/), treating them as relative paths instead of absolute URLs. This can lead to security bypasses in applications that rely on URI validation. Any application using vulnerable URI.js versions for URL parsing or validation is affected.
💻 Affected Systems
- URI.js (urijs) library
📦 What is this software?
Uri.js by Uri.js Project
⚠️ Risk & Real-World Impact
Worst Case
Attackers could bypass URL validation, security filters, or access controls by crafting malicious URIs with backslashes, potentially leading to SSRF, open redirects, or authentication bypass.
Likely Case
Most commonly, this could allow bypassing URL validation in web applications, leading to open redirect vulnerabilities or manipulation of URL-based security controls.
If Mitigated
With proper input validation and security controls, the impact is limited to potential parsing inconsistencies rather than critical security breaches.
🎯 Exploit Status
Exploitation requires the application to use URI.js for parsing user-supplied URLs. The vulnerability is simple to trigger with crafted input.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 1.19.6
Vendor Advisory: https://github.com/medialize/URI.js/releases/tag/v1.19.6
Restart Required: No
Instructions:
1. Update URI.js dependency to version 1.19.6 or later. 2. Run 'npm update urijs' or update package.json to 'urijs': '^1.19.6'. 3. Test application functionality after update.
🔧 Temporary Workarounds
Input Validation Workaround
allImplement custom validation to reject or normalize URIs containing backslashes before passing to URI.js.
🧯 If You Can't Patch
- Implement strict input validation to reject URIs containing backslashes in URL schemes
- Use alternative URL parsing libraries that properly handle backslashes
🔍 How to Verify
Check if Vulnerable:
Check package.json or node_modules for URI.js version. If version is below 1.19.6, the system is vulnerable.
Check Version:
npm list urijs
Verify Fix Applied:
After updating, verify the version is 1.19.6 or higher and test that URIs with backslashes are properly rejected or normalized.
📡 Detection & Monitoring
Log Indicators:
- Unusual URL patterns with backslashes in HTTP requests
- Failed URL validation attempts with backslash characters
Network Indicators:
- HTTP requests containing backslashes in URL schemes
- Redirects to unexpected domains
SIEM Query:
source="web_logs" AND (url="*http:\\/*" OR url="*https:\\/*")
🔗 References
- https://advisory.checkmarx.net/advisory/CX-2021-4305
- https://github.com/medialize/URI.js/commit/a1ad8bcbc39a4d136d7e252e76e957f3ece70839
- https://github.com/medialize/URI.js/releases/tag/v1.19.6
- https://advisory.checkmarx.net/advisory/CX-2021-4305
- https://github.com/medialize/URI.js/commit/a1ad8bcbc39a4d136d7e252e76e957f3ece70839
- https://github.com/medialize/URI.js/releases/tag/v1.19.6