프로토타입 오염
이 공격은 JSON.parse
와 Object.deepCopy
를 사용하는 모든 로직에서 발생할 수 있다.
2019-04-17 에 발표된 이 취약점은 $.extends
구문 상에서 프로토타입 XSS 공격이 가능하다.
예시
1 2 3 4 5 6
| var myObject = '{"myProperty" : "a", "__proto__" : { "isAdmin" : true } }'; var newObject = $.extend(true, {}, JSON.parse(myObject)); console.log(newObject.isAdmin);
var temp = {}; console.log(temp.isAdmin);
|
패치
취약점 패치는 아래 부분을 변경해준다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| jQuery.extend = jQuery.fn.extend = function () { for (; i < length; i++) { if ((options = arguments[i]) != null) { for (name in options) { src = target[name]; copy = options[name];
if (name === '__proto__' || target === copy) { continue; }
if ( deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy))) ) { if (copyIsArray) { copyIsArray = false; clone = src && jQuery.isArray(src) ? src : []; } else { clone = src && jQuery.isPlainObject(src) ? src : {}; }
target[name] = jQuery.extend(deep, clone, copy); } else if (copy !== undefined) { target[name] = copy; } } } }
return target; };
|