서울대학교 프로그래밍 연구실rosaec.snu.ac.kr/meet/file/20120727p12.pdf ·...

1
ScanDal: 안드로이드 개인정보 누출 분석기에서 악성 분석기로 확장하기 문제 개인정보 누출 분석기 (MoST ’12) 김진영 윤용호 이승중 서울대학교 프로그래밍 연구실 악성 분석기 앱이 사용자의 민감한 개인 정보를 외부로 내보내지 않는가? 단말기 식별번호, 위치정보 많은 누출 사례 새로운 형태의 악성 앱이 계속 등장할 전망 다양한 행동을 하는 악성 앱을 유연하게 감지할 있다면? 해결 방법 번역 추출 .apk Dalvik Bytecode + XML Dalvik Core Result 분석 ScanDal: 요약해석 기반의 정적 분석기 protoFromLocation() new-array r1, r1, Object callv Location.getLatitude(r10) move-result r3 mul-double r3, r7 double-to-long r3, r3 calld Long.valueOf(r3) move-result r3 aput-object r3, r1, r2 calld String.format(r0, r1) move-result r0 return r0 getLocationParam() callv protoFromLocation(r6, r5) move-result r1 const-string r5 "e1+" callv StringBuilder.append(r0, r5) callv StringBuilder.append(r0, r1) ... callv StringBuilder.toString(r0) move-result r5 return r5 showAds() callv generateHtml(r4, r5, r6) move-result r0 callv WebView.loadData(r1,r0,r2,r3) genearteHtml() callv getLocationParam(r11) move-result r4 calld AdSpec.Parameter.<init>(r11, r12, r4) callv List.add(r5, r11) ... new r11, StringBuilder calld StringBuilder.<init>(r11) const-string r12, ";\n</script>\n<script type= ’text/javascript’ src=’" callv StringBuilder.append(r11, r12) move-result r11 callv AdSpec.getAdUrl(r15) move-result r12 callv StringBuilder.append(r11, r12) move-result r11 const-string r12, "’></script>\n</body> \n</html>" ... calld AdUtil.generateJSONParameters(r5) move-result r12 callv StringBuilder.append(r11, r12) move-result r11 callv StringBuilder.toString(r11) move-result r11 return r11 패키지 파일을 입력으로 (.apk) 소스 코드 없이 분석 Dalvik VM Bytecode대상언어 코드에 없는 XML 정보도 이용 분석용 중간 언어 Dalvik Core번역 200여개 Dalvik 명령을 10여개 핵심 명령으로 구성요소의 실행흐름은 명시되어 있지 않음 2단계 실행모델: 초기화 - (이벤트/콜백)* 요약실행으로 분석 대상 성질 확인 실행의미, 요약실행의미 정의 Dalvik Core 언어에 대해 안전 고정점 계산 결과를 보고 확인 개인정보 누출의 흐름을 분석 개인정보 Source API로부터 위치정보 - getLastKnownLocation(), ... 단말기 식별번호 - getDeviceId(), ... Sink API나가는 흐름이 있는지 네트워크 - loadURL(), ... 네트워크/파일 - write(), ... SMS - sendTextMessage(), ... 요약실행으로 어떻게 분석? 값을 만드는 기여한 개인정보 Source API들을 안전하게 기록 ScanDal기존 틀을 유지 특정 악성 앱에 특화되지 않는 일반화된 분석 이를 위해 요약실행기와 후처리기를 분리 악성 앱을 유연하게 감지할 있도록 악성 앱의 행동을 질의 형태로 받은 이를 요약실행의 고정점 계산 결과를 이용해 확인 다양한 악성 행동을 감지할 있도록 악성 행동을 기술할 있는 언어 정의 기술된 악성 행동 포함 여부 확인하는 후처리기 설계 예제 개인정보 누출 SourceSink기술하고 사이에 흐름이 있음을 기술 사용자 몰래 문자메세지 전송 문자메세지 전송을 위해 불려야 하는 이벤트를 기술 해당 이벤트 처리 과정 유저 이벤트가 없음을 기술 Exploit이용한 앱의 루트 권한 상승 알려진 Exploit 행동의 핵심을 기술 현재의 실행모델은 지나치게 단순 모든 이벤트를 하나의 묶음으로 처리 액티비티간의 순서 액티비티 생애주기 (lifecycle) 고려 없음 개선 가능성 충분 2단계 실행모델에서 최대한 개선한 결과 수행시간 18% 감소 액티비티 고려하도록 실행모델 개선 2단계가 아닌 액티비티 단위로 문법, 실행의미, 요약실행의미 수정, 인텐트 분석 필요 1260개의 악성 확보 (http://malgenomeproject.org /) 살펴보는 다양한 악성 행동을 기술할 있는 언어 정의 기술된 악성 행동 포함 여부 확인하는 후처리기 설계 일부 악성 행동은 JNI (Java Native Interface)사용 권한 상승을 위한 Exploit 필요하다면 ARM 기계어 코드 포함하도록 분석기 확장 http://rosaec.snu.ac.kr

Upload: others

Post on 26-Mar-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 서울대학교 프로그래밍 연구실rosaec.snu.ac.kr/meet/file/20120727p12.pdf · DataOutputStream, HttpURLConnection, and Webview objects are considered as sinks. • SMS: sendTextMessage()

ScanDal: 안드로이드 개인정보 누출 분석기에서악성 앱 분석기로 확장하기

문제

개인정보 누출 분석기 (MoST ’12)

김진영 윤용호 이승중서울대학교 프로그래밍 연구실

악성 앱 분석기• 앱이 사용자의 민감한 개인 정보를 외부로 내보내지 않는가?

• 단말기 식별번호, 위치정보 등 많은 누출 사례• 새로운 형태의 악성 앱이 계속 등장할 전망

• 다양한 행동을 하는 악성 앱을 유연하게 감지할 수 있다면?

해결방법 번역추출

.apkDalvik

Bytecode+ XML

Dalvik Core Result

분석

• ScanDal: 요약해석 기반의 정적 분석기

1 protoFromLocation()2 new-array r1, r1, Object3 callv Location.getLatitude(r10)4 move-result r35 mul-double r3, r76 double-to-long r3, r37 calld Long.valueOf(r3)8 move-result r39 aput-object r3, r1, r2

10 calld String.format(r0, r1)11 move-result r012 return r013

14 getLocationParam()15 callv protoFromLocation(r6, r5)16 move-result r117 const-string r5 "e1+"18 callv StringBuilder.append(r0, r5)19 callv StringBuilder.append(r0, r1)20 ...21 callv StringBuilder.toString(r0)22 move-result r523 return r524

25 genearteHtml()26 callv getLocationParam(r11)27 move-result r428 calld AdSpec.Parameter.<init>(r11, r12, r4)29 callv List.add(r5, r11)30 ...31 new r11, StringBuilder32 calld StringBuilder.<init>(r11)33 const-string r12,34 ";\n</script>\n<script type=35 ’text/javascript’ src=’"36 callv StringBuilder.append(r11, r12)37 move-result r1138 callv AdSpec.getAdUrl(r15)39 move-result r1240 callv StringBuilder.append(r11, r12)41 move-result r1142 const-string r12,43 "’></script>\n</body>44 \n</html>"45 ...46 calld AdUtil.generateJSONParameters(r5)47 move-result r1248 callv StringBuilder.append(r11, r12)49 move-result r1150 callv StringBuilder.toString(r11)51 move-result r1152 return r1153

54 showAds()55 callv generateHtml(r4, r5, r6)56 move-result r057 callv WebView.loadData(r1,r0,r2,r3)

A brief video demo of the experiments is available at ourwebsite [15].

C. Organization

Sections 2 through 4 describe an overview of SCANDAL,Section 5 shows the experiment results, Section 6 discussesthe limitations, Section 7 describes related work, and Section8 concludes.

II. ANALYSIS TARGET

A. Target: Privacy Leaks

SCANDAL determines if there exists a flow of data froman information source through a sink. We call such a flowa privacy leak.

1) Sources: API calls that return private information areconsidered as information sources. We track 3 types ofprivate information:

• Location Information: Applications can send users’physical location to remote advertisement servers [7].

• Phone Identifiers: Applications can send phone identi-fiers to remote network servers [6], [7]. We track fourphone identifiers: phone number, IMEI (device ID),IMSI (subscriber ID), and ICC-ID (SIM card serialnumber).

• Eavesdropping: We track both audio (on microphone)and video (on camera) eavesdropping.

2) Sinks: API calls that can transfer data to the networkor SMS are considered as sinks.

• Network: Relevant API calls in the Outputstream,DataOutputStream, HttpURLConnection, andWebview objects are considered as sinks.

• SMS: sendTextMessage() function in objectSmsManager is also considered as a sink.

Whenever private data is sent out of the phone, SCANDALconsiders it as a privacy leak. Such a leak might reasonablybe expected by users, depending on the functionality of theapplication. We do not try to understand the intention of thesituations.

B. Target Language: Dalvik VM Bytecode

Dalvik is the register-based virtual machine in the Androidoperating system. Android developers commonly write anapplication in a dialect of Java, and the application iscompiled to bytecode.

SCANDAL deals with the Dalvik bytecode, rather thantranslating the Dalvik bytecode to Java. We do this becauseknown reverse engineering tools, such as dex2jar, fail insome cases. It is also possible for malicious developers todeliberately modify an application at the bytecode level,which makes the application hard to be decompiled. Bydealing directly with the bytecode, we do not have to sufferfrom such issues.

1 protoFromLocation()2 new-array r1, r1, Object3 callv Location.getLatitude(r10)4 move-result r35 mul-double r3, r76 double-to-long r3, r37 calld Long.valueOf(r3)8 move-result r39 aput-object r3, r1, r2

10 calld String.format(r0, r1)11 move-result r012 return r013

14 getLocationParam()15 callv protoFromLocation(r6, r5)16 move-result r117 const-string r5 "e1+"18 callv StringBuilder.append(r0, r5)19 callv StringBuilder.append(r0, r1)20 ...21 callv StringBuilder.toString(r0)22 move-result r523 return r524

25 genearteHtml()26 callv getLocationParam(r11)27 move-result r428 calld AdSpec.Parameter.<init>(r11, r12, r4)29 callv List.add(r5, r11)30 ...31 new r11, StringBuilder32 calld StringBuilder.<init>(r11)33 const-string r12,34 ";\n</script>\n<script type=35 ’text/javascript’ src=’"36 callv StringBuilder.append(r11, r12)37 move-result r1138 callv AdSpec.getAdUrl(r15)39 move-result r1240 callv StringBuilder.append(r11, r12)41 move-result r1142 const-string r12,43 "’></script>\n</body>44 \n</html>"45 ...46 calld AdUtil.generateJSONParameters(r5)47 move-result r1248 callv StringBuilder.append(r11, r12)49 move-result r1150 callv StringBuilder.toString(r11)51 move-result r1152 return r1153

54 showAds()55 callv generateHtml(r4, r5, r6)56 move-result r057 callv WebView.loadData(r1,r0,r2,r3)

A brief video demo of the experiments is available at ourwebsite [15].

C. Organization

Sections 2 through 4 describe an overview of SCANDAL,Section 5 shows the experiment results, Section 6 discussesthe limitations, Section 7 describes related work, and Section8 concludes.

II. ANALYSIS TARGET

A. Target: Privacy Leaks

SCANDAL determines if there exists a flow of data froman information source through a sink. We call such a flowa privacy leak.

1) Sources: API calls that return private information areconsidered as information sources. We track 3 types ofprivate information:

• Location Information: Applications can send users’physical location to remote advertisement servers [7].

• Phone Identifiers: Applications can send phone identi-fiers to remote network servers [6], [7]. We track fourphone identifiers: phone number, IMEI (device ID),IMSI (subscriber ID), and ICC-ID (SIM card serialnumber).

• Eavesdropping: We track both audio (on microphone)and video (on camera) eavesdropping.

2) Sinks: API calls that can transfer data to the networkor SMS are considered as sinks.

• Network: Relevant API calls in the Outputstream,DataOutputStream, HttpURLConnection, andWebview objects are considered as sinks.

• SMS: sendTextMessage() function in objectSmsManager is also considered as a sink.

Whenever private data is sent out of the phone, SCANDALconsiders it as a privacy leak. Such a leak might reasonablybe expected by users, depending on the functionality of theapplication. We do not try to understand the intention of thesituations.

B. Target Language: Dalvik VM Bytecode

Dalvik is the register-based virtual machine in the Androidoperating system. Android developers commonly write anapplication in a dialect of Java, and the application iscompiled to bytecode.

SCANDAL deals with the Dalvik bytecode, rather thantranslating the Dalvik bytecode to Java. We do this becauseknown reverse engineering tools, such as dex2jar, fail insome cases. It is also possible for malicious developers todeliberately modify an application at the bytecode level,which makes the application hard to be decompiled. Bydealing directly with the bytecode, we do not have to sufferfrom such issues.

1 protoFromLocation()2 new-array r1, r1, Object3 callv Location.getLatitude(r10)4 move-result r35 mul-double r3, r76 double-to-long r3, r37 calld Long.valueOf(r3)8 move-result r39 aput-object r3, r1, r2

10 calld String.format(r0, r1)11 move-result r012 return r013

14 getLocationParam()15 callv protoFromLocation(r6, r5)16 move-result r117 const-string r5 "e1+"18 callv StringBuilder.append(r0, r5)19 callv StringBuilder.append(r0, r1)20 ...21 callv StringBuilder.toString(r0)22 move-result r523 return r524

25 genearteHtml()26 callv getLocationParam(r11)27 move-result r428 calld AdSpec.Parameter.<init>(r11, r12, r4)29 callv List.add(r5, r11)30 ...31 new r11, StringBuilder32 calld StringBuilder.<init>(r11)33 const-string r12,34 ";\n</script>\n<script type=35 ’text/javascript’ src=’"36 callv StringBuilder.append(r11, r12)37 move-result r1138 callv AdSpec.getAdUrl(r15)39 move-result r1240 callv StringBuilder.append(r11, r12)41 move-result r1142 const-string r12,43 "’></script>\n</body>44 \n</html>"45 ...46 calld AdUtil.generateJSONParameters(r5)47 move-result r1248 callv StringBuilder.append(r11, r12)49 move-result r1150 callv StringBuilder.toString(r11)51 move-result r1152 return r1153

54 showAds()55 callv generateHtml(r4, r5, r6)56 move-result r057 callv WebView.loadData(r1,r0,r2,r3)

A brief video demo of the experiments is available at ourwebsite [15].

C. Organization

Sections 2 through 4 describe an overview of SCANDAL,Section 5 shows the experiment results, Section 6 discussesthe limitations, Section 7 describes related work, and Section8 concludes.

II. ANALYSIS TARGET

A. Target: Privacy Leaks

SCANDAL determines if there exists a flow of data froman information source through a sink. We call such a flowa privacy leak.

1) Sources: API calls that return private information areconsidered as information sources. We track 3 types ofprivate information:

• Location Information: Applications can send users’physical location to remote advertisement servers [7].

• Phone Identifiers: Applications can send phone identi-fiers to remote network servers [6], [7]. We track fourphone identifiers: phone number, IMEI (device ID),IMSI (subscriber ID), and ICC-ID (SIM card serialnumber).

• Eavesdropping: We track both audio (on microphone)and video (on camera) eavesdropping.

2) Sinks: API calls that can transfer data to the networkor SMS are considered as sinks.

• Network: Relevant API calls in the Outputstream,DataOutputStream, HttpURLConnection, andWebview objects are considered as sinks.

• SMS: sendTextMessage() function in objectSmsManager is also considered as a sink.

Whenever private data is sent out of the phone, SCANDALconsiders it as a privacy leak. Such a leak might reasonablybe expected by users, depending on the functionality of theapplication. We do not try to understand the intention of thesituations.

B. Target Language: Dalvik VM Bytecode

Dalvik is the register-based virtual machine in the Androidoperating system. Android developers commonly write anapplication in a dialect of Java, and the application iscompiled to bytecode.

SCANDAL deals with the Dalvik bytecode, rather thantranslating the Dalvik bytecode to Java. We do this becauseknown reverse engineering tools, such as dex2jar, fail insome cases. It is also possible for malicious developers todeliberately modify an application at the bytecode level,which makes the application hard to be decompiled. Bydealing directly with the bytecode, we do not have to sufferfrom such issues.

• 앱 패키지 파일을 입력으로 (.apk)

• 소스 코드 없이 분석• Dalvik VM Bytecode가 대상언어• 코드에 없는 XML 정보도 이용

• 분석용 중간 언어 Dalvik Core로 번역• 200여개 Dalvik 명령을 10여개 핵심 명령으로• 앱 구성요소의 실행흐름은 명시되어 있지 않음• 2단계 실행모델: 초기화 - (이벤트/콜백)*

• 요약실행으로 분석 대상 성질 확인• 실행의미, 요약실행의미 정의• Dalvik Core 언어에 대해 안전• 고정점 계산 결과를 보고 확인

• 개인정보 누출의 흐름을 분석• 개인정보 Source API로부터

• 위치정보 - getLastKnownLocation(), ...

• 단말기 식별번호 - getDeviceId(), ...

• Sink API로 나가는 흐름이 있는지• 네트워크 - loadURL(), ...

• 네트워크/파일 - write(), ...

• SMS - sendTextMessage(), ...

• 요약실행으로 어떻게 분석?

• 값을 만드는 데 기여한 개인정보 Source API들을 안전하게 기록

• ScanDal의 기존 틀을 유지• 특정 악성 앱에 특화되지 않는 일반화된 분석• 이를 위해 요약실행기와 후처리기를 분리

• 악성 앱을 유연하게 감지할 수 있도록• 악성 앱의 행동을 질의 형태로 받은 뒤• 이를 요약실행의 고정점 계산 결과를 이용해 확인

• 다양한 악성 행동을 감지할 수 있도록• 악성 행동을 기술할 수 있는 언어 정의• 기술된 악성 행동 포함 여부 확인하는 후처리기 설계

예제

할 일

• 개인정보 누출• Source와 Sink를 기술하고 그 사이에 흐름이 있음을 기술

• 사용자 몰래 문자메세지 전송• 문자메세지 전송을 위해 불려야 하는 이벤트를 기술• 해당 이벤트 처리 과정 중 유저 이벤트가 없음을 기술

• Exploit을 이용한 앱의 루트 권한 상승• 알려진 Exploit 행동의 핵심을 기술

• 현재의 앱 실행모델은 지나치게 단순• 모든 이벤트를 하나의 묶음으로 처리• 액티비티간의 순서 및 액티비티 생애주기 (lifecycle) 고려 없음

• 개선 가능성 충분• 2단계 실행모델에서 최대한 개선한 결과 수행시간 18% 감소

• 액티비티 고려하도록 실행모델 개선• 2단계가 아닌 액티비티 단위로• 문법, 실행의미, 요약실행의미 수정, 인텐트 분석 필요

• 1260개의 악성 앱 확보 (http://malgenomeproject.org/)

• 살펴보는 중

• 다양한 악성 행동을 기술할 수 있는 언어 정의• 기술된 악성 행동 포함 여부 확인하는 후처리기 설계

• 일부 악성 행동은 JNI (Java Native Interface)를 사용• 권한 상승을 위한 Exploit

• 필요하다면 ARM 기계어 코드 포함하도록 분석기 확장

��� ��

{skcho, yslee, jhkang}@ropas.snu.ac.krgB�, [M@, �j�

��P 1y• <@�Z �( J�� 4X D _X�?

• Sparse Airac: 44 KLOC in Ocaml• :b| sd� (Localization, Sparse analysis, ...)

• Sparse AiracZ �( CoqV# �i{`.• <@� eq( �i{/ <@� B�[ c{• <@ �� �q# O5&�/ OK!

http://rosaec.snu.ac.kr

ProgrammingResearch Laboratory

http://ropas.snu.ac.kr

CoqV# �i{�

z#�� <@• RI E� (abstract interpretation) � � <@

i0 78

• Xavier Leroy Q: C uw] • Pichardie Q: ��| z#�� <@�

• T): ESd\ z#�� <@�Z � �i�

0: x := 01: while (x < 100) {2: x := 2 * x + 13: }4: return x

x

0 [0, 0]

1 [0, 199]

2 [0, 99]

3 [1, 199]

4 [100, 199]

• <@�( +�. ��| ED�• Galois connectionX a2 +�• 9D�Z Def-Use �( a2 >, a2� sd� D�• Abstract transfer functionX a2 fZ• join/meet/orderP �W domain �" L>X a2 fZ• ...

• z#�� P <@ � ( ^!V# 6YP s

• z#�� Z ?vZ m� P E� Z3 P r� ?v fZP S R ✓ S ⇥ S

• ��| <@ �Z m� ( fZ. � B*{�$. S s 2 S

• Ge{� xA��� � ( fZ.� ✓ S ⇥ S

i 2 S

• h=

• Abstract transfer function fZF : S ! S

• �i�( +�. i0�H } �• is monotone ( [/ )F a v b F (a) v F (b)

• is monotone ( , [/ )a v b� s � bs � a

s1R

s29�

s1F // s2• N'n diagram

• �i�� �\} � i � s F (s) v s

• GfB i0s1

R

s29�

s1F // s2

F (s) v s

s0�

s

s0 Rn s

s � s) ��

��.

lp ?�• concrete/abstract semantics fZ (Fk Full C� �%j� 2~)• eq i0Z K�� ,t. C;d\ �SX oU �JH ~• �-\ �

• equivalence class, partially-ordered set, lattice• interval, sum, product, set, map