CVE-2021-27516: Insufficient Information (NVD-CWE-noinfo)
value: URI.js (aka urijs) before 1.19.6 mishandles certain uses of backslash such as http:\/ and interprets the URI as a relative path.
CWE description: There is insufficient information about the issue to classify it; details are unkown or unspecified.
CVSS v3 base score: 7.5
Published: 2021-02-22T00:15Z
Repository: https://github.com/medialize/URI.js
Language: JavaScript
Files changed: src/URI.js, test/urls.js
Commit date: 2021-02-13 16:05:10 +0100
Commit message: fix(parse): treat backslash as forwardslash in scheme delimiter

make `https:/\attacker.com` like `https:\/attacker.com` result in `https://attacker.com/`

Diff: diff --git a/src/URI.js b/src/URI.js
index 757507d..0108995 100644
--- a/src/URI.js
+++ b/src/URI.js
@@ -524,11 +524,11 @@
       if (pos > -1) {
         parts.protocol = string.substring(0, pos) || null;
         if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) {
           // : may be within the path
           parts.protocol = undefined;
-        } else if (string.substring(pos + 1, pos + 3) === '//') {
+        } else if (string.substring(pos + 1, pos + 3).replace(/\\/g, '/') === '//') {
           string = string.substring(pos + 3);
 
           // extract "user:pass@host:port"
           string = URI.parseAuthority(string, parts);
         } else {
diff --git a/test/urls.js b/test/urls.js
index 14255c1..c993038 100644
--- a/test/urls.js
+++ b/test/urls.js
@@ -2080,8 +2080,57 @@ var urls = [{
         ip4: false,
         ip6: false,
         idn: false,
         punycode: false
       }
+    }, {
+      name: 'backslashes protocol',
+      url: 'https:/\\attacker.com',
+      _url: 'https://attacker.com/',
+      parts: {
+        protocol: 'https',
+        username: null,
+        password: null,
+        hostname: 'attacker.com',
+        port: null,
+        path: '/',
+        query: null,
+        fragment: null
+      },
+      accessors: {
+        protocol: 'https',
+        username: '',
+        password: '',
+        port: '',
+        path: '/',
+        query: '',
+        fragment: '',
+        resource: '/',
+        authority: 'attacker.com',
+        origin: 'https://attacker.com',
+        userinfo: '',
+        subdomain: '',
+        domain: 'attacker.com',
+        tld: 'com',
+        directory: '/',
+        filename: '',
+        suffix: '',
+        hash: '',
+        search: '',
+        host: 'attacker.com',
+        hostname: 'attacker.com'
+      },
+      is: {
+        urn: false,
+        url: true,
+        relative: false,
+        name: true,
+        sld: false,
+        ip: false,
+        ip4: false,
+        ip6: false,
+        idn: false,
+        punycode: false
+      }
     }
 ];
 

Vulnerable code:         } else if (string.substring(pos + 1, pos + 3) === '//') {
Fixed code:         } else if (string.substring(pos + 1, pos + 3).replace(/\\/g, '/') === '//') {
    }, {
      name: 'backslashes protocol',
      url: 'https:/\\attacker.com',
      _url: 'https://attacker.com/',
      parts: {
        protocol: 'https',
        username: null,
        password: null,
        hostname: 'attacker.com',
        port: null,
        path: '/',
        query: null,
        fragment: null
      },
      accessors: {
        protocol: 'https',
        username: '',
        password: '',
        port: '',
        path: '/',
        query: '',
        fragment: '',
        resource: '/',
        authority: 'attacker.com',
        origin: 'https://attacker.com',
        userinfo: '',
        subdomain: '',
        domain: 'attacker.com',
        tld: 'com',
        directory: '/',
        filename: '',
        suffix: '',
        hash: '',
        search: '',
        host: 'attacker.com',
        hostname: 'attacker.com'
      },
      is: {
        urn: false,
        url: true,
        relative: false,
        name: true,
        sld: false,
        ip: false,
        ip4: false,
        ip6: false,
        idn: false,
        punycode: false
      }