본문 바로가기

Study/보안

npm prototype pollution attack (CVE-2020-8203)

💡  lodash의 zipObjectDeep() 메소드에서 발견된 취약점 -
prototype의 속성 식별자가 user-supplied일 경우, 악의적인 사용자가 오브젝트의 프로토타입을 수정할 수 있는 이슈

 

깃헙에 lodash 관련 이슈가 터졌다.

메일로도 알림이 올 정도면 얼마나 큰 이슈라는거지?

'low severity'라고 되어있지만 알림이 왔으니 한 번 확인해봤다.

 

 

# Prototype Pollution

 

 

Prototype Pollution Attack

Prototype Pollution 공격에 대한 원문은 이 링크에서 확인할 수 있다.

 

node.js의 third party 앱중에 lodash 라는 라이브러리가 있었다. lodash 홈페이지

Underscore같은 자바스크립트 유틸리티 라이브러린데, 데이터를 쉽게 다룰 수 있게 해준다고 한다.

 

이 lodash에는 zipObjectDeep()이라는 메소드가 있다.

오브젝트의 속성과 값을 매칭시켜주는 기능인데, 파이썬의 zip함수와 비슷하게 생겼다.

 

zipObjectDeep()

 

이 메소드는 prototype의 속성 식별자가 user-supplied일 경우, 악의적인 사용자가 오브젝트의 프로토타입을 수정할 수 있도록 하는 취약점이 있었다. => 해커가 property를 수정하거나 추가할 수 있다!

 

Prototype Pollution은 이 lodash의 취약점을 이용한 공격이다.

 

 

# 해결방법

lodash를 4.17.19 이상 버전으로 업데이트한다.

 

package-lock.json

"dependencies": {
  "lodash": ">=4.17.19"
}

//or
"devDependencies": {
  "lodash": ">=4.17.19"
}

 

참고


 

npm report:

www.npmjs.com/advisories/1523

 

npm

Versions of lodash prior to 4.17.19 are vulnerable to Prototype Pollution. The function zipObjectDeep allows a malicious user to modify the prototype of Object if the property identifiers are user-supplied. Being affected by this issue requires zipping obj

www.npmjs.com

 

해커원 리포트 :

hackerone.com/reports/712065

 

Node.js third-party modules disclosed on HackerOne: Prototype...

I would like to report a prototype pollution vulnerability in lodash. It allows an attacker to inject properties on Object.prototype Module module name: lodash version: 4.17.15 npm page: https://www.npmjs.com/package/lodash Module Description The Lodash li

hackerone.com

 

깃헙 이슈:

github.com/advisories/GHSA-p6mc-m468-83gw

 

GHSA-p6mc-m468-83gw - GitHub Advisory Database

Prototype Pollution in lodash

github.com

 

 

CVE

cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-8203

 

CVE - CVE-2020-8203

20200128 Disclaimer: The entry creation date may reflect when the CVE ID was allocated or reserved, and does not necessarily indicate when this vulnerability was discovered, shared with the affected vendor, publicly disclosed, or updated in CVE.

cve.mitre.org