CVE-2018-1874
위험도 중간 ASEC 언급 2건
- 우선순위 이 사이트의 참고 점수
- 6.11
- 위험도 CVSS 3.0 · 0~10점
- 4.6
- 악용 가능성 EPSS · 30일 안에 공격에 쓰일 확률
- 0.4%
- 공개일 NVD
- 2019-04-02
설명 NVD 원문
IBM API Connect 5.0.0.0 through 5.0.8.5 could display highly sensitive information to an attacker with physical access to the system. IBM X-Force ID: 151636.
위험도 세부 항목 CVSS 3.0
- 공격 경로
- 물리 접근 AV:P
- 공격 난이도
- 낮음(쉬움) AC:L
- 필요한 권한
- 없음(로그인 불필요) PR:N
- 사용자 행동 필요
- 필요 없음 UI:N
- 영향 범위
- 그 제품 안 S:U
- 정보 유출(기밀성)
- 높음 C:H
- 데이터 변조(무결성)
- 없음 I:N
- 서비스 중단(가용성)
- 없음 A:N
CVSS:3.0/AV:P/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
조치 방법 0행
수집된 조치 정보가 없습니다. 조치가 필요 없다는 뜻은 아닙니다.
살펴볼 장비 초안
분류 대상이 아닙니다 (지금은 KEV 만 분류합니다). 안전하다는 뜻이 아닙니다.
단계별 판정 예시 환경
시나리오 미작성 — 이 CVE 는 단계별 판정을 하지 않았습니다. 안전하다는 뜻이 아닙니다.
출처별 내용 2건
ASEC 영어·일본어 등 다른 언어 글 2건
ASEC CVE-2018-8174 脆弱性分析 2018-11-26
AhnLab ASEC 分析チームは、ランサムウェアを含む国内でのマルウェア拡散に広く使用されているIEの脆弱性、CVE-2018-8174 に対する分析を行った。この脆弱性はマグニバー(Magniber)ランサムウェアの拡散にも使用されており、セキュリティパッチの適用によって被害を予防する作業が必要である。 MS セキュリティアップデートページ (CVE-2018-8174) – https://portal.msrc.microsoft.com/ko-kr/security-guidance/advisory/CVE-2018-8174 01. 要約 1) CVE-2018-8174 の概要 CVE-2018-8174の脆弱性は VBScript エンジンの Use After Free 発生によるオブジェクトの再使用によって発生する。 リモートでの実行が可能な脆弱性であり、影響を受けるバージョンは、Internet explorer8、Internet explorer9、Internet explorer10、Internet explorer11(1803以下のバージョン)、Windows 10(1803以下)、Windows 7、Windows 8、Windows Serverである。 02. 事前知識 1) VBScript エンジンがスクリプトを実行する方法 イ ) 定義 VBScript エンジンのスクリプトは、エンジンが解析可能な Precompiled Code (以下、P-Code)に変換されて実行される。変換された P-Code は、0x00~0x6Fの112個の値を持ち、VBScript エンジンの内部関数である RunNoEH で解析した後、P-Code に適した VBScript 関数を呼び出す。RunNoEH 関数は [図1] の通りである。 [図1] RunNoEH 関数の定義 ロ ) 実行方法 P-Code は RunNoEH 関数で実行され、[図1] の最初のパラメータである CScriptRuntime クラスの内部に位置する。CScriptRuntime クラスは [図2] の通りで、0xC0に位置するメンバ変数 Compiled Script によって P-Code の位置が分かる。[図2] の0xB4に位置するメンバ変数 Position Counter は、次に実行する P-Code コマンドを指している。これは、EIP レジスタに類似した役割を実行する。 [図2] CScriptRuntime クラス VBScript エンジンにおいて、P-Codeは [図3] のように Call-Return 方式で実行される。Call-Return 方式とは、Global Code の P-Code を実行しながら、その内部で Call を呼び出す P-Code に遭遇したとき、次に実行する P-Code を保存して当該関数の P-Code コマンドを実行する方式である。 [図3] P-Codeの実行の流れ ハ ) ツールの紹介 Kaspersky 社は、P-Code を抽出するスクリプトを github に公開した。これを利用すれば、上で説明した CScriptRuntime クラスの Compiled Script を抽出して分析に利用できる。 03. 詳細分析 1) CVE-2018-8174 イ ) 脆弱性の発生原理 CVE-2018-8174の脆弱性は VBScript エンジンの Use After Free 発生によるオブジェクトの再使用問題を命名したものである。 以下の [図4]、[図5] は、CVE-2018-8174の脆弱性において Use After Free の発生原理を整理した図である。図のスクリプトは、CVE-2018-1874 の PoC(Proof of Concept)スクリプトである。図で定義された数字の順に実行され、[図4]、[図5] が順番に続く。 [図4] Use After Free の原理-1 [図4] のスクリプト内容のうち、1番の Dim は変数の宣言であり、グローバル変数 o を宣言する。2番の Redim の意味は配列の宣言であり、arr で命名した2個の配列が宣言される。3番のプロセスによって cla1 クラスオブジェクトを、宣言された最初の配列 arr(0) に割り当てる。このプロセスによって、最初の配列 arr(0) に cla1 クラスオブジェクトのアドレスが保存され、クラスオブジェクトに対する参照回数(参照カウント)は1となる。 [図5] Use After Free の原理-2 [図4] のプロセス以降、[図5] の4番のメモリ解放プロセスを実行する。Erase ステートメントによって宣言された配列 arr の削除を試みる。arr 配列の最初の要素である arr(0) を削除すると、その配列に保存された cla1 クラスのClass_Terminate 関数がコールバック関数として呼び出され、5番のプロセスを実行する。5番のプロセスでは、arr(0) に保存された cla1 クラスオブジェクトのアドレス値を、1番のプロセスで宣言されたグローバル変数 o に保存する。自身を参照する変数が増加したため、cla1 クラスの参照回数は1増加する。6番で arr(0) に保存されたクラスオブジェクトのアドレスが異なる値に変更され、これによって cla1 クラスの参照回数は1減少する。以降、7番でコールバック関数は終了し、参照回数の増加・減少が一定になり、クラスオブジェクトのアドレスに対する free() 関数を呼び出す。最後の8番によってグローバル変数 o の値を出力する場合、すでに解放されたメモリアドレスを指している。 [図6] VBScriptClass::Release 関数 メモリ解放は VBScript.dll で定義された [図6] の関数によって実行される。コードからわかるとおり、InterlockedDecrement の呼び出し後に参照回数が0の場合、VBScriptClass::TerminateClass 関数が呼び出され、その後、解放対象であるクラス(v1変数)の参照回数が1の場合、free() 関数が呼び出される。Class_Terminate コールバック関数を呼び出す時、コールバック関数内でグローバル変数 o に、解放する前のクラスオブジェクトのアドレス値を保存し、参照回数のバランスを合わせることにより free() 関数を呼び出す。したがって、実際のメモリは解放されるため、このアドレス値を Dangling pointer として使用できる。 ロ ) Use After Free 前述した Use After Free の発生原理を、以下の [図7] のコードを利用して詳細に説明する。 [図7] Use After Free のスクリプト [図7] の1番の部分で、Redim は内部的に [図8] のような関数を呼び出す。 [図8] Redim 内部呼び出し SafeArrayAllocData 関数までの呼び出しが終了すると、tagSAFEARRAY 構造体が生成される。 [図9] 割り当てられたメモリ値 [図7] の1番の redim 部分に割り当てられて初期化されたメモリ領域が生成され、Set コマンドによって値が割り当てられる。[図9] は、このプロセスによって割り当てられた値である。この時、保存される値の形式は Variant 構造体である。Variant 構造体は、複数のタイプのデータを伝達する構造体であり、最初のメンバである VT(Variant Type) 値に基づき、有効なデータタイプが決定される。現在割り当てられた Variant 構造体の VT 値が0x09(VT_DISPATCH)であることが確認できる。 [図10] VBScriptClass オブジェクト Variant 構造体の現在の VT 値である VT_DISPATCH のオブジェクトポインタが保存され、0x021C6AB8が保存されていることが確認できる。このアドレスに保存された値は、VBScriptClass に割り当てられた cla1 のオブジェクト情報が保存されている空間である。Set によって cla1 の参照値が増加し、参照回数が2になったことが確認できる。 [図11] VbsErase 内部呼び出し [図7] の1番の Erase 部分は、内部的に [図11] のような関数を呼び出す。oleaut32!ReleaseResources 関数はFreedObjectArray 配列を巡回し、保存された値を初期化する機能を実行する。そして、oleaut32!VariantClear 関数は Variant 構造体を初期化する関数である。VariantClear 関数は Variant 構造体の VT 値に応じて Clear するルーティンが異なる。Variant 構造体の VT 値が DISPATCH であるため、VBScriptClass::TerminateClass が呼び出される。[図7]の Erase 関数が呼び出されるタイミングは、メモリが割り当てられてすぐに解放される時であり、参照回数は [図11] のように1となる。その後 TerminateClass が呼び出され、初期化関数を経て、[図7] の2番のコールバック関数に移動する。 [図12] Erase 関数呼び出し後の参照回数 初期化された cla1 配列の参照回数は4であり、[図7] の2番の部分で Set 部分は cla1 オブジェクトのアドレス情報を持っている FreedObjectArray 配列を UafArrayA に割り当てて参照回数を1増加させる。UafArrayA に保存されたアドレス値が Dangling pointer に使用される [図13]。 [図13] Dangling pointer [図14] FreedObjectArray(1) 後のメモリ変化 以降、Redim で宣言された FreedObjectArray(1) 配列に新たな値を割り当てて、vbscript 内部で AssginVar が呼び出される。この時、1は Variant 構造体の VT 値のうち0x02(VT_I2)に該当するため、既存の0x09(VT_Dispatch)値は0x02(VT_I2)で上の [図14] のように割り当てられる。FreedObjectArray(1) 配列のオブジェクト参照によって、cla1 の参照回数は1減少する。コールバック関数において、開始値である4と同じくされた状態でコールバック関数の呼び出しが終了し、参照回数は0となり、メモリが解放される。 結果的に、クラス構造体の参照回数の検証が正常に実行されず、Use After Free が発生した。ここで発生した Dangling pointer が UafArrayA 配列に保存され、[図7] の3番のプロセスによって ReuseClass に再割り当てされ、以降 TypeConfusion の脆弱性に使用される。 ハ ) TypeConfusion TypeConfusion とは、宣言された Type に混乱を与えることを意味する。以下の [図15] のように、割り当てられた Type A 形式のデータがあると仮定する場合、構成されたシェルコードによって割り当てられたデータの領域に上書きされると、上書きされたシェルコードによってデータのタイプが変形する。変形した Type A の領域を読み込むと、割り当てられた Type A ではなく、変形した Type B として認識される。この方式が TypeConfusion の原理である。 [図15] TypeConfusion の原理 CVE-2018-8174の脆弱性において、Use After Free は2回実行され、2つの Dangling Pointer が発生し、また ReuseClass に2回割り当てられる。Use After Free の部分では方法と原理に差異がないため1つだけ説明したが、TypeConfusion では2つそれぞれの使用方法が異なる。まず最初の方法を説明し、続いて相違点を後述する。 以下の [図16] は、CVE-2018-8174コードの TypeConfusion 部分である。[図7] のプロセス3の Use After Free で求められた Dangling pointer に割り当てられた ReuseClass のアドレス、resueObjectA_arr に TypeConfusion のためのメモリを構成するコードである。resueObjectA_arr クラスの SetProp 関数が呼び出された場合、ReuseClass に宣言された規定のプロパティを実行する。規定のプロパティ関数内に構成されたQは0x0C、0x20の値で Variant 構造体の VT 値が0x200Cとなり、変数型は VT_ARRAY、VT_VARIANT である。UafArrayA に0を代入すると VBScript Terminate Class を呼び出し、参照回数が0となり、ReuseClass が free となる。以降、objectImitatingArray に FakeReuseClass オブジェクトを割り当てるが、この時 ReuseClass オブジェクトアドレスと同じアドレスを割り当てる。 [図16] TypeConfusion スクリプト-1 割り当てられた FakeReuseClass オブジェクトは、以下の [図17] の通りである。以下の [図17] の上の部分は ReuseClass オブジェクトを割り当てた空間で、下の部分は FakeReuseClass オブジェクトを割り当てた空間である。白い枠線の部分が関数名、変数名を表しており、白い枠線の前の空間が割り当てられたデータである。Function は0x4Cの値で始まり、dim で宣言された変数は0x00で始まる。 [図17] の ReuseClass オブジェクトを割り当てた空間に FakeReuseClass オブジェクトを割り当てるが、最初の関数名が p で10個の文字列が追加され、16byte 増加して SPP 関数がその後割り当てられる。 [図17] TypeConfusion 前後のメモリ値 FakeReuseClass オブジェクトに割り当てた objectImitatingArray の mem に、あらかじめ構成された FakeArrayString で上書きする。FakeArrayString は String で構成された値(0x08,BSTR)で、正常でないサイズの tagSAFEARRAY を作成するために構成された値である。書き込まれた値である FakeArrayString は、BSTR であるため、mem の VT 値が0x08に変更される。この中で0xFFFF、0x7FFFの値があるが、この値は TypeConfusion を実行する時に SafeArray 配列のサイズを0x7FFFFFFFサイズで作成するために構成された値である。また、0x0001と0x0880、0x0001の値があるが、この値は tagSAFEARRAY 構造体の1番目、2番目、3番目の引数値として設定され、それぞれ配列の次元情報、配列のフィーチャー情報、配列の要素のサイズ値となる。このようにして構成された値を objectImitatingArray の mem 変数に上書きする。このように上書きを行うと、以下の [図18] のように変更された tagSAFEARRAY 構造を確認できる。したがって、変更された tagSAFEARRAY は1次元配列の0x880( FADF_VARIANT | FADF_HAVEVARTYPE )属性と配列要素のサイズが1である0x7FFFFFFF個の配列を持つようになる。規定のプロパティ関数が終了し、SetProp に戻って定義された mem を構成された Q の値に ReuseClass の mem の位置に上書きし、タイプが0x08(BSTR)から0x200C(ARRAY, VARIANT)に変更される。その後、reuseObjectA_arr の mem を呼び出すと0x7FFFFFFFサイズの配列を使用できるようになる。正常でないサイズのこの配列は、スクリプトがロードされた iexplore.exe のヒープ領域と同じサイズのメモリにアクセスすることができる。 [図18] TypeConfusion 後の reuseObjectA_arr メモリ resueObjectB_int は resueObjectA_arr と同じ方式で TypeConfusion となる。上の説明と異なる点は、規定のプロパティ関数内に構成されたPの値とあらかじめ構成された FakeArrayString の値である。規定のプロパティ関数内に構成された P の値の VT 値が BSTR(0x08) から LONG(0x03) に変更され、空白の 16byte に満たされる。その空間にあるreuseObjectB_int の mem のグローバル変数アドレスを some_memory に挿入する。空白の値は、スクリプトがロードされた iexplore.exe のヒープ領域に、以降メモリの特定空間を保存するときに使用される。 [図19] TypeConfusion スクリプト-2 [図20] TypeConfusion 後の reuseObjectB_int メモリ ニ ) LeakVBAddr LeakVBAddr 部分では、先に実行した TypeConfusion で作成された配列(resueObjectA_arr)とヒープ領域のアドレス(resueObjectB_int)を利用して VBScript.dll の base addresss を取得する。 [図21] LeakVBAddr スクリプト [図22] LeakVBAddr プロセスのメモリ変化 空白の関数 EmptySub を emptySub_addr_placeholder 変数に割り当てることにより、vbscript.dll の内部アドレスを含むオブジェクトが割り当てられる。この時、空白の関数を変数に割り当てることは文法上のエラーになるが、On Error Resume Next によって以降のルーティンが実行可能である。以降、null を割り当てて VT 値が Func(0x4C) からNULL(0x01) に変更されることを確認できる。EmptySub を割り当てた後、Null を割り当てた状態で VT を Null(VT=0x01) から LONG(0x03) に変更し、メモリアドレスを変数で出力してメモリアドレスを漏えいさせる。TypeConfusion 関数によって得られた0x7FFFFFFFサイズの配列(reuseObjectA_arr.mem)で heap Address(some_memory) にアクセスし、タイプの変更を自由に実行することができる。 ホ ) Execute ShellCode [図23] コード実行スクリプト シェルコードは0x4D値を割り当てて実行される。0x4D値を割り当てると AssignVar が呼び出され、Variant 構造体の VT 値を確認して値に応じた分岐を行う。VT 値が0x4Dのときは VAR::Clear が呼び出され、構成されたメモリによって NtContinue と VirtualProtect でシェルコードまで実行される。 [図24] コード実行プロセス [図25] は、VirtualProtect でシェルコードに実行権限を付与するためにメモリを構成するスクリプトである。VirtualProtect は対象アドレス、サイズ、保護オプションによって呼び出される。実行権限として64(0x40)が使用される。これは、PAGE_EXECUTE_READWRITE 権限である。 [図25] VirtualProtect コールパラメータのメモリ構成スクリプト [図26] は、NtContinue を呼び出すときに使用される CONTEXT 構造体を構成するスクリプトである。レジストリの位置にはパディング値が設定され、EIP、ESP値の位置にそれぞれ VirtualProtect のアドレス値とシェルコードの EP アドレス値を使用してメモリを構成する。 [図26] CONTEXT 構造体の構成スクリプト 上で説明したように、VTに0x4D値を割り当てると AssignVar の後に Var::Clear が呼び出され、Var::Clear で以下の [図27] の分岐を実行する。[図27] のloc_6E50089Cにおける1列目は Variant 構造体のデータに該当する位置([esi+8])で、上の [図26] の StructForNtContinue で構成したメモリを指す。以降、StructForNtContinue で構成したメモリのアドレスを push したあと call し、NtContinue を実行する。 [図27] 構成されたメモリの実行 NtContinue が呼び出される時、上記で構成された CONTEXT 構造体のアドレスと共に呼び出され、VirtualProtect 関数を呼び出す。 構成された CONTEXT 構造体により VirtualProtect でシェルコードのアドレスを取得し、実行権限を付与して return し、シェルコードに分岐してシェルコードが実行される。 [図28] シェルコードの実行 [図29] メモリ実行権限の変化 ヘ ) 脆弱性修正パッチ 前述した CVE-2018-8174 の Use After Free 脆弱性については、oleaut32.dll モジュールが以下のようにパッチ適用された。[図30] は、oleaut32.dll パッチ適用前後の VariantClear 関数である。図の左側がパッチ適用前、右側がパッチ適用後である。割り当てられた Variant 構造体を解放するときに呼び出される関数は、[図11] の通りである。vbscript.dll の VbsErase が呼び出され、内部呼び出しにより oleaut32.dll モジュールの VariantClear 関数が呼び出される。呼び出された VariantClear 関数で vbscript.dll モジュールの TerminateClass によって解放されるが、[図30] の右側のように解放するとき、その関数で Variant Type 値を0x00(VT_EMPTY)で設定し、解放する形式でパッチが適用された。パッチ適用前後のメモリ値を比較すると、VT 値が0x09(VT_DISPATCH)から0x00(VT_EMPTY)に変更されていることがわかる。このようにパッチが適用され、Use After Free で取得した Dangling pointer を使用すると、UafArrayA 配列にオブジェクトのアドレスをコピーするプロセスでエラーが発生し、オブジェクトの再使用が不可能となる。 [図30] CVE-2018-8174 脆弱性パッチ適用前後の VariantClear 04. 参考文献 [1] https://github.com/KasperskyLab/VBscriptInternals , Github, KasperskyLab [2] https://msdn.microsoft.com/ko-kr/windows/hardware/ms221482(v=vs.71) , MSDN, SAFEARRAY structure [3] https://msdn.microsoft.com/en-us/library/cc237824.aspx , MSDN, ADVFEATUREFLAGS Advanced Feature Flags [4] https://msdn.microsoft.com/en-us/library/ms931135.aspx , MSDN, VARIANT structure [5] https://msdn.microsoft.com/en-us/library/cc237865.aspx , MSDN, VARIANT Type Constants [6] https://portal.msrc.microsoft.com/ko-kr/security-guidance/advisory/CVE-2018-8174 、Microsoft、セキュリティアップデートガイド [7] https://github.com/piotrflorczyk/cve-2018-8174_analysis/blob/master/analysis.vbs , Github, piotrflorczyk
ASEC Analysis of CVE-2018-8174 Vulnerability 2018-11-26
AhnLab ASEC performed an analysis on IE vulnerability CVE-2018-8174 which is being widely used to distribute ransomware and Korean malware. This vulnerability is used to distribute Magniber ransomware as well, and users must apply security patch to prevent damage that can be done. MS security update page (CVE-2018-8174) – https://portal.msrc.microsoft.com/ko-kr/security-guidance/advisory/CVE-2018-8174 01. Summary 1) CVE-2018-8174 overview CVE-2018-8174 vulnerability is created as a result of object reuse that occurs when Use After Free vulnerability of VBScript engine surfaces. This vulnerability allows remote execution, and the affected versions are: Internet explorer 8, Internet explorer 9, Internet explorer 10, Internet explorer 11 (1803 or older version), Windows 10 (1803 or older), Windows 7, Windows 8, and Windows Server. 02. Background Knowledge 1) How VBScript engine runs a script a) Definition VBScript engine converts script to P-Code (precompiled code) for analysis, then runs it. Converted P-Code contains 112 values (0x00 – 0x6F) and RunNoEH – VBScript engine’s inner function – analyzes it and calls VBScript function that fits the P-Code. Figure 1 shows the RunNoEH function. Figure 1. Definition of RunNoEH b) Execution method P-Code runs in RunNoEH function, and the code is located within CScriptRuntime class, the first parameter of Figure 1. Figure 2 shows CScriptRuntime class and the location of P-Code can be found via the member variable named Compiled Script that is located at 0xC0. Member variable named Position Counter that is located at 0xB4 of Figure 2 is pointing at the P-Code command to run next. This performs similar role as EIP register. Figure 2. CScriptRuntime class In VBScript engine, P-Code is run with Call-Return method as shown in Figure 3. In the Call-Return method, when Global Code’s P-Code runs and meets P-Code that calls a call internally, the P-Code that is run next is saved and the P-Code command of the function is run. In VBScript engine, P-Code is run with Call-Return method as shown in Figure 3. In the Call-Return method, when Global Code’s P-Code runs and meets P-Code that calls a call internally, the P-Code that is run next is saved and the P-Code command of the function is run. Figure 3. Execution flow of P-Code c) Tools Kaspersky Lab published a P-Code extraction script in github (Reference 1). This script can be used to extract Compiled Script of CScriptRuntime class mentioned above and use it for analysis. 03. Detailed analysis 1) CVE-2018-8174 a) Principle of vulnerability occurrence CVE-2018-8174 vulnerability is a name for the object reuse issue that occurs when Use After Free vulnerability of VBScript engine surfaces. Figure 4 and Figure 5 below is an overview of principle behind the occurrence of Use After Free vulnerability in CVE-2018-8174 vulnerability. The script below is the PoC (Proof of Concept) script of CVE-2018-1874. The occurrence follows the following steps in number order, and the process in Figure 4 is continued in Figure 5. Figure 4. Principle of Use After Free – 1 Among the steps of the script in Figure 4, Dim of step 1 is declaration of variable. In here, Dim declares global variable o. Redim of step 2 means declaration of array, and two arrays named arr are declared as array. Through step 3, it allocates class object cla1 to arr(0) which is the first declared array. As a result, address of the class object cla1 is saved to the first array arr(0), and reference count for class object becomes 1. Figure 5. Principle of Use After Free – 2 After the steps in Figure 4 are carried out, the memory deallocation process in step 4 of Figure 5 is proceeded. The script then attempts to delete arr, which is the array declared by Erase statement. When deleting arr(0) which is the first element of arr array, the Class_Terminate function of class cla1 is called as a callback function and it proceeds with step 5. Process at step 5 saves the address of class object cla1 that has been saved to arr(0) to global variable o declared in step 1. Since the variable that refers to self has increased, the reference count of class cla1 increases by 1. In step 6, the address of class object saved to arr(0) is changed to a different value, and due to this, the reference count of class cla1 decreases by 1. And in step 7, the callback function is terminated, and because the increase and decrease of reference count is consistent, free() function for class object address is called. When the value of global variable o is printed via final step 8, it is pointing at the deallocated memory address. Figure 6. VBScriptClass::Release function Memory deallocation is proceeded via function of Figure 6 that has been defined to VBScript.dll. As shown in the code, if reference count is 0 after calling InterlockedDecrement, VBScriptClass::TerminateClass function is called, and if the reference count of class (v1 variable) for memory deallocation is 1, free() function is called. Upon calling Class_Terminate callback function, the script saves the address value of the class object before deallocation of global variable o within the callback function, and calls free () function by balancing the reference number. Following this, the real memory is deallocated and the address value can be used as Dangling pointer. b) Use After Free The principle of Use After Free occurrence will be explained thoroughly using the code of Figure 7. Figure 7. Script of Use After Free Redim in step 1 of Figure 7 internally calls functions (See Figure 8). Figure 8. Internal call of Redim When up to SafeArrayAllocData function is called, tagSAFEARRAY struct is created. The structure of tagSAFEARRAY struct is shown in Figure 9. Figure 9. tagSAFEARRAY struct Figure 10. Allocated memory value Figure 11 Variant structure By allocating to redim step 1 of Figure 7, reset memory area is created, and the value is allocated via Set command. Figure 10 shows the value that was allocated via this process. The form of value that is saved is Variant struct (Reference 4). Variant struct is a struct that transmits various types of data, and the valid data type is decided via VT (Variant Type), which is the first member (Reference 5). As shown in Figure 11, the current allocated VT value of Variant struct is 0x09 (VT_DISPATCH). Figure 12. VBScriptClass object Pointer of VT_DISPATCH is saved in VT value of Variant struct, and 0x021C6AB8 is saved. The value saved into this address is a space where object info of cla1 that has been allocated to VBScriptClass is saved. Through Set, reference value for cla1 increases, and the reference count has become 2. Figure 13. Internal call of VbsErase Erase in step 1 of Figure 7 internally calls functions such as the ones shown in Figure 13. oleaut32!ReleaseResources function circulates FreedObjectArray array and resets saved values. oleaut32!VariantClear function is a function that resets Variant struct. VariantClear function’s clearing routine changes depending on the VT value of Variant struct. Since VT value of Variant struct is DISPATCH, VBScriptClass::TerminateClass is called. The time Erase function of Figure 7 is called is when the deallocation happened immediately after memory allocation. Thus, reference count becomes 1 as shown in Figure 14, TerminateClass is called, and through reset function, the callback function part in no. 2 of Figure 7 takes place. Figure 14. Reference count after calling Erase function The reference count of cla1 array that was reset is 4, and Set part in the highlight 2 of Figure 7 allocates FreedObjectArray array that has object address info to UafArrayA and increases reference count by 1. The address value saved to UafArrayA is used as a Dangling pointer (Figure 15). Figure 15. Dangling pointer Figure 16. Change in memory after FreedObjectArray(1) Afterward, the script allocates a new value to FreedObjectArray(1) array declared by Redim and AssignVar is called internally by vbscript. At this instance, 1 is 0x02(VT_I2) among the VT values of the Variant struct, and the previous 0x09 (VT_Dispatch) value is allocated to 0x02 (VT_I2) as shown in Figure 16. Due to object referencing on FreedObjectArray(1) array, the reference count of cla1 decreases by 1. Callback function call ends while the value of the callback function is adjusted to 4 which is the starting value, and the reference count reaches 0, deallocating memory. Ultimately, Use After Free occurs because the reference count of the class struct is not validated properly. Dangling pointer that occurs from this is saved to UafArrayA array, and through step 3 of Figure 7., is relocated to ReuseClass and is used in TypeConfusion vulnerability. c) TypeConfusion TypeConfusion means causing confusion for the declared Type. Assuming that there is an assigned Type A data as shown in Figure 17, when ShellCode is used to overwrite the area of the assigned data, the data type is changed by the overwriting ShellCode. Upon reading the area of modified Type A, it is recognized as modified Type B instead of Type A. This is the principle of TypeConfusion. Figure 17. Principle of TypeConfusion Use After Free is proceeded 2 times in CVE-2018-8174 vulnerability, 2 Dangling Pointers occur, and allocation to ReuseClass occurs 2 times. Since there is no difference in method and principle for Use After Free, only 1 sample was explained. TypeConfusion however, 2 methods are each used differently. The first method will be explained below, and the difference will be explained later. Figure 18 shows TypeConfusion part of CVE-2018-8174 code. It is a code that forms a memory for TypeConfusion in the address resueObjectA_arr of ReuseClass that has been set with the Dangling pointer which was obtained via Use After Free, step 3 of Figure 7. When SetProp function of resueObjectA_arr class is called, it performs default property declared to ReuseClass. Q that is configured within the default property function is 0x0C, 0x20 value, therefore VT value of Variant struct becomes 0x200C, and the variable form is VT_ARRAY, VT_VARIANT. When 0 is inputted in UafArrayA, VBScript Terminate Class is called, reference count becomes 0, and ReuseClass is freed. Afterward, FakeReuseClass object is assigned to objectImitatingArray. At this instance, address that is same as ReuseClass object address is assigned. Figure 18. TypeConfusion Script-1 Assigned FakeReuseClass object is shown in Figure 19 below. The upper section of Figure 19 shows the area where ReuseClass object is assigned, and the lower section shows the area where FakeReuseClass is assigned. The white box shows function name and variable name. The area after the white box is the assigned data. Function starts with 0x4C value, and variable declared as dim starts with 0x00. FakeReuseClass object is assigned to the area where ReuseClass of Figure 19 is assigned. For the first function name, 10 strings are added from p, resulting in the expansion by 16-byte, and SPP function is assigned later. Figure 19. Memory value before and after TypeConfusion Memory of objectImitatingArray that has been assigned as FakeReuseClass object is overwritten with pre-configured FakeArrayString. FakeArrayString is a value (0x08,BSTR) composed of String. It is configured to create tagSAFEARRAY of abnormal size. Used value FakeArrayString is BSTR, therefore VT value of mem is changed to 0x08. 0xFFFF, 0x7FFF value is among them, and these values have been configured to be used in TypeConfusion to set the size of SafeArray array to 0x7FFFFFFF. There are also 0x0001, 0x0880, and 0x0001 value. These values are respectively set as the first, second, and the third argument of tagSAFEARRAY struct, and each becomes the size value of the array’s dimension info, array feature info, and array element. The script overwrites mem variable of objectImitatingArray with the configured values above. Upon overwriting, the structure of tagSAFEARRAY is changed as shown in Figure 20. tagSAFEARRAY now has 0x7FFFFFFF arrays with the 0x880( FADF_VARIANT | FADF_HAVEVARTYPE ) property of 1-dimensional array and the array element size of 1. mem that is defined after default property ends and going back to SetProp overwrites mem of ReuseClass using the configured Q value, and the type changes from 0x08(BSTR) to 0x200C(ARRAY, VARIANT). Afterward, when mem of reuseObjectA_arr is called, array with 0x7FFFFFFF size becomes available for use. This array with abnormal size can access the memory of the same size via heap area of the iexplore.exe where the script is loaded. Figure 20. reuseObjectA_arr memory after TypeConfusion TypeConfusion is carried out in the same way as resueObjectA_arr for resueObjectB_int. The difference between the description above is P value that’s been configured within default property function and pre-configured FakeArrayString value. VT value of the P value configured inside the default property function is changed from BSTR(0x08) to LONG(0x03), and is filled with empty 16-byte. mem of reuseObjectB_int of empty space and global variable address is inserted to some_memory. The empty value is the heap space of iexplore.exe where script is loaded, and is later used to save certain space of memory. Figure 21. TypeConfusion Script-2 Script 22. reuseObjectB_int memory after TypeConfusion d) LeakVBAddr In the LeakVBAddr part, the array (resueObjectA_arr) made with TypeConfusion earlier and the heap address (resueObjectB_int) is used to obtain the base address of VBScript.dll. Figure 23. LeakVBAddr script Figure 24. The changes in memory in LeakVBAddr step With EmptySub assigned to the emptySub_addr_placeholder variable, object that includes internal address of vbscript.dll is saved. The string that assigned the empty function to a variable is grammatically incorrect, but routine can be performed via On Error Resume Next. Afterward, null is assigned and VT value is changed from Func(0x4C) to NULL(0x01). After assigning EmptySub then assigning Null, VT is edited from Null(VT=0x01) to LONG(0x03), memory address is printed as variable, and memory is leaked. The attacker can use the array (reuseObjectA_arr.mem) of 0x7FFFFFFF size obtained via TypeConfusion function to access heap Address (some_memory) and freely change the type. e) Execute ShellCode Figure 25. Code execution script The execution of ShellCode begins as 0x4D is assigned. Upon assigning 0x4D value, AssignVar is called and VT value of Variant struct is checked. Afterward, branching takes place for the matching value. When the VT value is 0x4D, VAR::Clear is called and ShellCode is run via NtContinue and VirtualProtect due to configured memory. Figure 26. Code execution process Figure 27 shows VirtualProtect which is a script that configures memory to give execution privilege to ShellCode. VirtualProtect is called to IP address, download size, and file protection option. 64(0x40) is used as the execution privilege, and this is the PAGE_EXECUTE_READWRITE privilege. Figure 27. Script for VirtualProtect call parameter memory configuration Figure 28 shows the script that configures CONTEXT struct which is used to call NtContinue. Registry location is filled with padding value, and memory is configured by using VirtualProtect address value and ShellCode EP address value in the location of EIP, ESP value respectively. Figure 28. CONTEXT struct configuration script As explained above, when 0x4D value is assigned to VT, it is called after AssignVar as Var::Clear, and performs the branching statement from Var::Clear (See Figure 29). In loc_6E50089C of Figure 29, the first line is the location (esi+8) of data of Variant struct, and it points at the memory configured with StructForNtContinue of Figure 28. Afterward, it pushes and calls the address of memory that is configured with StructForNtContinue to prompt it to run NtContinue. As explained above, when 0x4D value is assigned to VT, it is called after AssignVar as Var::Clear, and performs the branching statement from Var::Clear (See Figure 29). In loc_6E50089C of Figure 29, the first line is the location (esi+8) of data of Variant struct, and it points at the memory configured with StructForNtContinue of Figure 28. Afterward, it pushes and calls the address of memory that is configured with StructForNtContinue to prompt it to run NtContinue. Figure 29. Execution of configured memory When NtContinue is called, the CONTEXT struct address that was configured as above is called along and this results in VirtualProtect function being called. VirtualProtect gives execution privilege after receiving ShellCode address due to the configured CONTEXT struct, returns it, and branches to ShellCode which results in the execution of ShellCode. Figure 30. Execution of ShellCode Figure 31. Change in memory execution privilege f) Vulnerability patch Figure 32. VariantClear before and after CVE-2018-8174 vulnerability patch Use After Free vulnerability of CVE-2018-8174 underwent oleaut32.dll module patch (Reference 6). Figure 32 shows VariantClear function before and after oleaut32.dll patch. The left side of the figure shows the function before the patch and the right side shows the function after the patch. The function that is called when deallocating assigned Variant struct is shown in Figure 13. VbsErase of vbscript.dll is called and VariantClear function of oleaut32.dll module is called via internal call. Variant struct is deallocated via TerminateClass of vbscript.dll in VariantClear function, and as shown in the right side of Figure 32, the patch made a change so that when it is deallocated, the Variant Type value of the function is filled with 0x00(VT_EMPTY) and deallocated. The VT value of the memory value before the patch was 0x09(VT_DISPATCH), but it changed to 0x00(VT_EMPTY) after the patch. After the patch, using Dangling pointer obtained from Use After Free results in occurrence of error during the phase of copying object address to UafArrayA, rendering it impossible to reuse object.
자동 추천 장비와 근거 참고용
분류 체계(취약점 종류 CWE → 공격 유형 CAPEC → 공격 기법 ATT&CK) 매핑으로 계산한 후보입니다. 범위가 넓어 관련이 적은 장비가 섞입니다. 해당 장비가 이 공격을 탐지한다고 확인한 것은 아니며, 위의 '살펴볼 장비' 와 단계별 판정에는 쓰지 않습니다.
| 장비 | 방법 | 근거 경로 |
|---|---|---|
| 서버 접근제어 ACCESS | attack | CWE-200 > CAPEC-60 > T1550.004 > Logon Session Creation |
| 엔드포인트 탐지·대응 EDR | attack | CWE-200 > CAPEC-13 > T1574.006 > File Creation |
| 방화벽 FW | attack | CWE-200 > CAPEC-169 > T1595 > Network Traffic Flow |
| 계정·인증 (AD·LDAP·SSO) IAM | attack | CWE-200 > CAPEC-60 > T1550.004 > Logon Session Creation |
| 침입방지시스템 IPS | attack | CWE-200 > CAPEC-169 > T1595 > Network Traffic Content |
| 네트워크 탐지·대응 / 패킷 분석 NDR | attack | CWE-200 > CAPEC-169 > T1595 > Network Traffic Content |
| 서버 감사 로그 SYSAUDIT | attack | CWE-200 > CAPEC-13 > T1574.006 > File Creation |
| VPN VPN | attack | CWE-200 > CAPEC-60 > T1550.004 > Logon Session Creation |
| 취약점 스캐너 VULNSCAN | attack | CWE-200 > CAPEC-169 > T1592 > Response Content |
| 웹 방화벽 WAF | attack | CWE-200 > CAPEC-169 > T1595 > Network Traffic Content |
| 웹서버·WAS 로그 WEBLOG | attack | CWE-200 > CAPEC-60 > T1550.004 > Web Credential Usage |
취약점 종류 CWE
- 정보 노출 — CWE-200 Exposure of Sensitive Information to an Unauthorized Actor
영향받는 제품 CPE · 1건
| 제조사 | 제품 | 영향받는 버전 | 표준 표기CPE |
|---|---|---|---|
| ibm | api_connect | 5.0.0.0 이상 5.0.8.5 이하 | cpe:2.3:a:ibm:api_connect:*:*:*:*:*:*:*:* |
참고 링크 6건
- 제3자 권고 · 취약점 DB http://www.securityfocus.com/bid/107733
- 취약점 DB · 제조사 권고 https://exchange.xforce.ibmcloud.com/vulnerabilities/151636
- 패치 · 제조사 권고 https://www.ibm.com/support/docview.wss?uid=ibm10876994
- 제3자 권고 · 취약점 DB http://www.securityfocus.com/bid/107733
- 취약점 DB · 제조사 권고 https://exchange.xforce.ibmcloud.com/vulnerabilities/151636
- 패치 · 제조사 권고 https://www.ibm.com/support/docview.wss?uid=ibm10876994
용어 설명 CVE · CVSS · EPSS · KEV · NVD …
- CVE 취약점 번호
- 공개된 보안 취약점마다 붙는 국제 고유 번호입니다. 예: CVE-2021-44228(Log4j). 가운데 숫자는 번호를 받은 해입니다.
- CVSS 위험도 점수
- 취약점이 얼마나 위험한지 0~10점으로 매긴 국제 표준 점수입니다. 심각 9.0 이상 · 높음 7.0~8.9 · 중간 4.0~6.9 · 낮음 0.1~3.9. 공격이 얼마나 쉬운지와 피해 크기로 정하며, 실제로 공격받고 있는지는 반영하지 않습니다.
- EPSS 악용 가능성
- 앞으로 30일 안에 실제 공격에 쓰일 확률을 추정한 값(0~100%)입니다. 국제 보안 단체 FIRST 가 매일 계산합니다. 높을수록 먼저 조치하세요.
- KEV 실제 악용 확인
- 미국 사이버보안청(CISA)이 실제 공격에 쓰인 것을 확인한 취약점만 모은 목록입니다. 여기에 있으면 가장 먼저 조치할 대상입니다. '랜섬웨어' 표시는 랜섬웨어 공격에 쓰인 것으로 알려진 것입니다.
- 공격 코드 공개된 PoC
- NVD 참고 링크 중 '공격 코드(Exploit)' 표시가 붙은 것이 있다는 뜻입니다. 누구나 공격을 시도해 볼 수 있으므로 서두르는 게 좋지만, 실제 악용이 확인된 것(KEV)과는 다릅니다.
- NVD 미국 취약점 DB
- 미국 국립표준기술연구소(NIST)가 운영하는 취약점 데이터베이스입니다. CVE 마다 설명·CVSS 점수·영향받는 제품·취약점 종류를 붙입니다. 이 사이트 설명의 원문 출처입니다.
- 우선순위 이 사이트의 참고 점수
- CVSS·KEV·랜섬웨어·EPSS·ASEC 언급·공격 코드 공개를 합쳐 계산한 점수입니다. 높을수록 먼저 살펴보세요. 공식 점수가 아닙니다.
- ASEC 안랩 분석 글
- 안랩 보안대응센터 블로그입니다. 'ASEC 3' 은 분석 글에 그 CVE 번호가 3번 나왔다는 뜻이며, 국내에서 악용이 확인됐다는 뜻은 아닙니다.
- CWE 취약점 종류
- 취약점 종류의 분류 번호입니다. 예: CWE-89 SQL 인젝션, CWE-79 크로스 사이트 스크립팅.
- CPE 영향받는 제품
- 취약점이 있는 제품과 버전을 적는 표준 표기입니다. 예: apache:tomcat 9.0.0~9.0.80.
- KB Microsoft 업데이트 번호
- Microsoft 가 업데이트마다 붙이는 번호입니다. 예: KB5068791. '수정된 버전' 은 업데이트 후의 빌드 번호로, 이보다 낮으면 업데이트가 필요합니다.
- 시나리오 · 번역
- '시나리오' 는 단계별 판정 초안이 있다는 표시입니다(없다고 안전한 것은 아닙니다). '(번역)' 은 Claude 로 기계 번역한 설명입니다.