SlideShare una empresa de Scribd logo
1 de 35
Descargar para leer sin conexión
安卓软件漏洞  
修复与检测技术研究  
张源    博士  
复旦大学系统软件与安全实验室  
软件漏洞  
2
•  攻击目的:privilege  
–  突破沙箱、访问控制等防护机制  
–  Know  something  you  are  not  allowed  to  know  
–  Do  something  you  are  not  allowed  to  do  
•  Code  Injection/Reuse  Attack?  
–  使用受害者的身份运行攻击者指定的代码逻辑  
–  二进制:利用内存读写漏洞  
•    Buffer  overflow,  Format  string,  User-after-free,  
Information  disclosure,  etc  
–  Web:  Cross  Site  Scripting,  SQL  Injection,  etc  
•  Insecure  privileged  interface  
–  利用没有保护好的具有特权的接口  
–  e.g  Cross  Site  Request  Forgery  
安卓软件漏洞  
3
•  Code  Injection/Reuse  is  Hard!  
–  Java  is  sandboxed,  memory-safe  
–  Android  app  is  not  a  server  
•  TRUE  until  wormhole?  
–  Limited  injection/reuse  attack  cases  
•  Java代码加载漏洞  
•  WebView导致js代码注入  
•  Capability  Leak  (Privilege  Escalation)  
–  权限泄露漏洞  
•  Confused  deputy  
•  Component  hijacking  
–  Content  Provider漏洞  
•  Bad  security  practice  
•  Insecure  SSL  
•  Insecure  Crypto  
•  Vulnerability?  or  Risk?  
主题:漏洞防护  
4
漏洞检测  
漏洞修复  
代码分析  
漏洞特征描述  
漏洞特征报告  
根据漏洞细节修复漏洞  
如何修复漏洞?  
5
•  人工修复  
–  理解漏洞?  
–  如何修改?  
–  确保没有引入新漏洞?  
•  自动化程序重写  
–  如何使所有版本更新?  
•  有没有更好的选择?  
–  Policy-driven的漏洞修复  
–  系统级的漏洞修复支持  
权限泄露漏洞  
6
public class SmsReceiverService extends Service {
public int onStartCommand(Intent intent, int flags, int startId) {
... ...
Message msg = mServiceHandler.obtainMessage();
msg.arg1 = startId;
msg.obj = intent;
mServiceHandler.sendMessage(msg);
... ...
}
private final class ServiceHandler extends Handler {
public void handleMessage(Message msg) {
Intent intent = (Intent)msg.obj;
if (intent != null) {
String action = intent.getAction();
... ...
} else if (SMS_RECEIVED_ACTION.equals(action)) {
handleSmsReceived(intent, error);
}
... ...
}
}
}
private void handleSmsReceived(Intent intent, int error) {
SmsMessage[] msgs = Intents.getMessagesFromIntent(intent);
String format = intent.getStringExtra("format");
Uri messageUri = insertMessage(this, msgs, error, format);
if (messageUri != null) {
long threadId = MessagingNotification.getSmsThreadId(this, messageUri);
MessagingNotification.blockingUpdateNewMessageIndicator(this, threadId, false);
}
}
}
AOSP中Mms程序存
在的WRITE_SMS权
限泄露漏洞	

权限泄露漏洞分析  
7
SmsReceiverService
SmsReceiver
WRITE_SMS leak SEND_SMS leak
public interface
a b
c
•  漏洞利用程序  
– 三条漏洞路径:a、b、c->b  
– 编写测试程序,均可成功利用这些漏洞  
权限泄露漏洞分析  
8
•  Why  permission  leak?    
–  intra/inter  component  interaction  share  the  same  
communication  channel  
–  components  may  be  designed  for  both  public  use  
and  internal  use  
•  Key  to  fix  permission  leak  
– Identify  vulnerable  path  
– Differ  public  use  or  internal  use  
FineDroid  
9  
•  Key  Idea  
–  Permission  Request    <-->    Application  Context  
–  New  Granularity  
•  At  the  level  of  application  execution  context  
•  Application  Execution  Context  
–  Intra-application  context,  mark  the  execution  flow  
inside  the  app  
–  Inter-application  context,  mark  the  IPC  behavior  
among  interacted  apps  
•  Policy-driven  Permission  Framework  
–  Unified  Permission  Interception  
–  Extensible  Policy  Framework  
系统设计  
10  
Library Layer
Android Framework
Linux Kernel
App_1 App_2
Context Builder
Context API
Policy
Manager
Permission
Manager
Security
Extensions
Permission
Record
install policy
extend action
•  Building  and  Propagating  Context  along  with  
application  execution  
•  Intercept  all  permission  requests  with  system-wide  
application  execution  context  
•  Query  policy  framework  to  handle  permission  
request  in  a  context-sensitive  manner  
核心模块  
11  
•  Context  Builder  
– Intra-application  context  builder  
– Inter-application  context  builder  
•  Context  Propagator  
– Intent-level,  Thread-level,  Event-level  
•  Policy-driven  Permission  Framework  
– Permission  Interception  
– Extensible  Policy  Framework  
Intra-application  Context  Builder  
12  
•  Mark  the  execution  flow  inside  the  app  
– using  Calling  Context  to  monitor  internal  
flow  
– Probabilistic  Calling  Context  (PCC)  
•  An  integer  birthmark  based  on  all  the  
functions  in  the  flow  
•  Can  be  calculated  with  a  recursive  expression  
•  Call-site  birthmark:  offset  of  the  invoke-site  in  
DEX  
   𝒑𝒄𝒄=𝟑  ∗ 𝒑𝒄𝒄‘+   𝒄𝒔,   𝑤ℎ𝑒𝑟𝑒   𝒑𝒄​ 𝒄↑′ 𝑖𝑠   𝑃𝐶𝐶   𝑣𝑎𝑙𝑢𝑒   𝑜𝑓   𝑐𝑎𝑙𝑙𝑒𝑟    
𝑎𝑛𝑑   𝒄𝒔   𝑖𝑠   𝑡ℎ𝑒   𝑏𝑖𝑟𝑡ℎ𝑚𝑎𝑟𝑘   𝑜𝑓   𝑐𝑎𝑙𝑙   𝑠𝑖𝑡𝑒  
Inter-application  Context  Builder  
13  
•  Mark  the  IPC  behavior  of  interacted  
apps  
– Using  Binder  to  track  IPC  behaviors  
– Inter-Context:  UID  +  PCC  
App_1
App_1
(uid: pcc)
interaction
Context: None
App_1
(uid, pcc)
App_2 App_3
Linux Kernel
interaction
User Space
App_2
(uid: pcc)
App_1
(uid: pcc)
App_1
(uid: pcc)
App_2
(uid: pcc)
Context  Propagating  
14  
•  Complex  application  dynamics  may  
break  the  context  propagating  
•  Intent-level  
•  Solution:  bind  context  to  Intent  object  
App_A
(uid_A, pcc_A)
AMS
App_B
(uid_B, pcc_B)
Zygote
Spawn request
fork
(uid_B, pcc_B) (uid_AMS, pcc_AMS)
Binder request
App_A
(uid_A, pcc_A)
AMS App_B
(uid_A, pcc_A) (uid_AMS, pcc_AMS)
Binder request
(a) When App_B is started (b) When App_B is not started
Context  Propagating  
15  
•  Thread-level  
– New  thread  should  inherit  the  context  of  
its  parent  thread  
– New  resumed  thread  should  inherit  the  
context  of  the  initiator  thread  
•  Event-level  
– Async  behaviors  via  callbacks  
– e.g.,  OnClickListener,  OnLocationListener  
– Callbacks  should  inherit  the  context  of  its  
register  
Policy-driven  Permission  Framework  
16  
•  Permission  Interception  
– Goal:  intercepts  all  permission  use  and  
manages  the  requests  in  a  unified  point  
– Kernel-Enforced  Permission  
•  relies  on  UID/GID  isolation  
•  redirects  the  permission  requests  to  framework    
– Android-Enforced  Permission  
•  relies  on  PMS  to  check  permission  
•  queries  policy  manager  to  make  a  decision  
Policy-driven  Permission  Framework  
17  
•  Policy  Language  
– Declarative  language  to  specify  rules  
  
– Implemented  in  XML  format  
•  Tags:  policy,  uid-selector,  uid-context,  pcc-
selector,  method-sig,  or,  and,  not  
•  Details  can  be  found  in  the  paper  
•  Policy  Matching  
–  Find  a  policy  that  best  match  the  current  context  
policy := <action> <app> <permission> <context>
action := grant | deny | ...
修复Mms中的权限泄露漏洞  
18  
•  How  to  Fix?  
–  With  inter-application  context,  differ  public  use  or  
internal  use  
–  With  intra-application  context,  accurately  
describe  the  vulnerable  flow  
–  e.g,  Fix  SEND_SMS  permission  leak  in  
SmsReceiver  
<policy action=”deny” app=”com.android.mms” permission=”SEND_SMS” >
<uid-selector selector=”strictcontains” >
<uid-context uid=”^com.android.mms” pcc=”*” />
<uid-context uid=”com.android.mms” />
<pcc-selector selector=”contains” >
<method-sig className=”com.android.mms.transaction.SmsReceiver”
methodName=”beginStartingService” />
</pcc-selector>
</uid-context>
</uid-selector>
</policy>
修复规则自动生成  
19
•  基于漏洞检测工具  
–  CHEX  [CCS  2012]  
–  对检测日志分析,提取函数调用路径和组件信息  
应用名	
 泄露路径数	
 生成规则数	

com.gmail.traveldevel.android.vlc.app-131	
 2	
 2	

com.froogloid.kring.google.zxing.client.android-67	
 24	
 24	

de.cellular.tagesschau-5	
 361	
 361	

com.akbur.mathsworkout-92	
 2	
 2	

com.appspot.swisscodemonkeys.paintfx-4	
 2	
 2	

com.androidfu.torrents-26	
 1	
 1	

com.espn.score_center-141	
 6	
 6	

com.espn.score_center-142	
 6	
 6	

fr.pb.tvflash-9	
 2	
 2	

hu.tagsoft.ttorrent.lite-15	
 8	
 8	

总计	
 414	
 414	

原型系统  
20  
•  Android  4.1.1,  Nexus  Prime  and  
emulators  
•  Retrofitted  Modules  
– Linux  Kernel  
•  for  intra/inter  context  building  
•  for  Kernel  permission  interception  
– Android  Framework  
•  for  context  propagating  
•  for  policy  management  
– No  modification  to  apps  
性能测试  
21  
•  Overall  Performance  
–  less  than  2%,  in  Linpack,  AnTuTu,  CaffeineMark3  
性能测试  
22  
•  Permission  Requesting  Handling  
•  Policy  Matching  
Permission
Type
Origin
Android
FineDroid
w/o Context
FineDroid
w/ Context
Socket(KEP) 0.14ms 2.16ms Δ2.02ms 2.18ms Δ0.02ms
IMEI(AEP) 0.62ms 0.69ms Δ0.06ms 1.09ms Δ0.40ms
Permission
Type
FineDroid
w/o Policy
FineDroid
w/ Policy Overhead
Socket(KEP) 2.18 ms 3.06 ms 0.88 ms
IMEI(AEP) 1.09 ms 1.99 ms 0.90 ms
FineDroid的其他应用场景  
23
•  一、细粒度的权限授予机制  
– 程序中可能会有多个地方使用同一个权限  
– 程序为粒度的权限决策是否足够灵活?  
– 重打包(恶意)应用程序?  
– 安全性  vs  可用性  
FineDroid的其他应用场景  
24
•  二、进程间栈自省技术  
–  不同的代码模块具有不同的权限配置  
–  E.g.  地理位置权限  
•  广告库需要用到  
•  程序自身也需要用到  
•  可否只将权限授予给程序自身的代码?  
•  采用包含Flurry广告插件的应用程序Stock  Watch进行实验  
...
<fine-permission android:package="com.flurry.android">
<deny android:permission="android.permission.ACCESS_FINE_LOCATION" />
<deny android:permission="android.permission.ACCESS_COARSE_LOCATION" />
</fine-permission>
...
FineDroid的其他应用场景  
25
•  二、进程间栈自省技术  
–  不同的代码模块具有不同的权限配置  
–  E.g.  地理位置权限  
•  广告库需要用到  
•  程序自身也需要用到  
•  可否只将权限授予给程序自身的代码?  
•  采用包含Flurry广告插件的应用程序Stock  Watch进行实验  
•  原程序使用该权限不受影响  
–  FlexDroid:  In-app  Privilege  Separation[NDSS  2016]  
com.snapwork.finance(10053:914896) android.permission.ACCESS_FINE_LOCATION DENIED
com.flurry.android.e-e-LL-42
com.flurry.android.e-a-VLLZ-3
com.flurry.android.v-run-V-21
漏洞检测  
26
•  基于静态分析的漏洞检测  
–  Automatically  check  app  behaviors  at  runtime  
•  Check  attacker-controlled  input  will  influence  privileged  
actions  
–  Conservative  
•  Value  not  determined  at  static-phase  
•  Path  not  determined  at  static-phase  
•  …  
•  常用的分析手段  
–  CFG  
•  单个函数的行为和逻辑分析  
–  Call  Graph  
•  所有可能的执行流  
–  Data    Dependency  Graph  
•  在执行流的基础上所有可能的数据依赖情况  
现有分析工具  
27
•  FlowDroid  [PLDI  2014]  
–  Soot:  Java  Analysis  Framework  
–  SPARK:  point-to  analysis  
–  Dexpler:  dex->jimple  
–  IDE/IFDS-based  Information  Flow  Analysis  
–  context-,  flow-,  field-,  object-sensitive  and  lifecycle-
aware  
–  Heavyweight,  not  designed  for  Android  
•  Amandroid  [CCS  2014]  
–  Sireum:  static  analysis,  symbolic  execution,  etc  
–  context-,  flow-sensitive  and  handles  ICC  
–  written  in  Scala  
–  Hard  to  study,  limited  community  support  
Daf:  Dex  Analysis  Framework  
28
•  Overview  
–  Directly  analyze  dex,  build  from  dexlib  
–  Highly  customizable  
–  written  in  Java,  still  under  development  
–  context-,  flow-,  field-,  object-sensitive  
•  Modules  
–  Point-to  analysis  
–  Call  Graph  
–  Data  Dependency  Graph  
–  String  analysis  
–  Constant  analysis  
–  Exception  analysis  
–  ICC  Analysis  (to  do)  
漏洞检测框架  
29
CFG	
  Builder	
  
String	
  Analysis	
  
Class	
  
Hierarchy	
  
Pointer-­‐to	
   Call	
  Graph	
   Data	
  Dependency	
  Graph	
  
SDK	
  Model	
   Constant	
  Analysis	
  
Daf:  Dex  Analysis  Framework  
Dos	
  Checker	
  
XXX	
  Checker	
  
Permission	
  Leak	
  Checker	
  
Code	
  InjecDon	
  Checker	
   Crypto	
  Checker	
  
SSL	
  Checker	
  
Vulnerability  Checkers  
Control  Flow  Information   Data  Flow  Information  
以DosChecker为例  
30
•  Input-Validation  Flaws  in  Components  
– Intent-related  APIs  may  cause  exceptions  
– NullPointerException  
– ClassCastException  
– ClassNotFoundException  
检测方法  
31
•  静态检测  
–  Exception分析  
•  识别会触发Dos异常的语句(Intent相关API)  
•  判断是否有try-catch块  
–  Intent分析  
•  判断出现异常的点是否为攻击者可以控制的输入  
•  动态测试  
–  String分析  
•  Intent.setAction(String)  
•  Intent.putExtra(String,  Object)  
–  Intent注入器  
•  发送Intent到目标程序组件  
•  检测程序组件是否Crash  
案例分析-平安口袋银行  
32
•  SSL缺陷  
– ISF  2014  
– 登陆信息泄露  
– 转账信息泄露  
– 用户信息泄露  
– 转账交易泄露/劫持  
案例分析-中国电信翼支付  
33
•  支付授权缺陷  
– GeekPwn  2015  优胜奖  
– 任意账户金额远程盗刷  
– 自动遍历受害账户进行攻击  
总结  
34
漏洞检测  
漏洞修复  
代码分析  
漏洞特征描述  
漏洞特征报告  
根据漏洞细节修复漏洞  
Daf漏洞检测框架  
•  基于DEX的静态分析  
•  Plugin-based漏洞检测  
FineDroid安全框架  
•  程序上下文跟踪  
•  Policy-driven漏洞修复  
Q&A  
35

Más contenido relacionado

Destacado

Destacado (9)

Openstack
OpenstackOpenstack
Openstack
 
Lessons From Sport - Jon Reay, Aqueduct
Lessons From Sport - Jon Reay, AqueductLessons From Sport - Jon Reay, Aqueduct
Lessons From Sport - Jon Reay, Aqueduct
 
[KR, 한국어]Share job postings; 채용 공고 공유하기
[KR, 한국어]Share job postings; 채용 공고 공유하기[KR, 한국어]Share job postings; 채용 공고 공유하기
[KR, 한국어]Share job postings; 채용 공고 공유하기
 
The Jigsaw Puzzle of Tourism Online
The Jigsaw Puzzle of Tourism OnlineThe Jigsaw Puzzle of Tourism Online
The Jigsaw Puzzle of Tourism Online
 
Lessons From Sport at Internet World 2012 - Jon Reay, Aqueduct
Lessons From Sport at Internet World 2012 - Jon Reay, AqueductLessons From Sport at Internet World 2012 - Jon Reay, Aqueduct
Lessons From Sport at Internet World 2012 - Jon Reay, Aqueduct
 
网易蜂巢容器公有云的docker实践
网易蜂巢容器公有云的docker实践网易蜂巢容器公有云的docker实践
网易蜂巢容器公有云的docker实践
 
Contoh Soal Sistem Pencernaan Manusia
Contoh Soal Sistem Pencernaan ManusiaContoh Soal Sistem Pencernaan Manusia
Contoh Soal Sistem Pencernaan Manusia
 
Power poin de informatica educativa
Power poin de informatica educativaPower poin de informatica educativa
Power poin de informatica educativa
 
Struktur dan Fungsi Jaringan Hewan - Biologi SMA kelas XI
Struktur dan Fungsi Jaringan Hewan - Biologi SMA kelas XI Struktur dan Fungsi Jaringan Hewan - Biologi SMA kelas XI
Struktur dan Fungsi Jaringan Hewan - Biologi SMA kelas XI
 

Similar a 安卓软件漏洞修复与检测技术研究-zhangyuan

Cristian Barrientos - Auditando Aplicaciones Android [rooted2018]
Cristian Barrientos - Auditando Aplicaciones Android [rooted2018]Cristian Barrientos - Auditando Aplicaciones Android [rooted2018]
Cristian Barrientos - Auditando Aplicaciones Android [rooted2018]
RootedCON
 
Seguridad en servidores
Seguridad en servidoresSeguridad en servidores
Seguridad en servidores
Taty Millan
 

Similar a 安卓软件漏洞修复与检测技术研究-zhangyuan (20)

Testing Android Security
Testing Android SecurityTesting Android Security
Testing Android Security
 
Integración de Mecanismos de Seguridad en la arquitectura de Aplicaciones Sof...
Integración de Mecanismos de Seguridad en la arquitectura de Aplicaciones Sof...Integración de Mecanismos de Seguridad en la arquitectura de Aplicaciones Sof...
Integración de Mecanismos de Seguridad en la arquitectura de Aplicaciones Sof...
 
Deletreando Android
Deletreando AndroidDeletreando Android
Deletreando Android
 
Testing Android Security
Testing Android SecurityTesting Android Security
Testing Android Security
 
Dominio 8 grupo 11
Dominio 8  grupo 11Dominio 8  grupo 11
Dominio 8 grupo 11
 
Cristian Barrientos - Auditando Aplicaciones Android [rooted2018]
Cristian Barrientos - Auditando Aplicaciones Android [rooted2018]Cristian Barrientos - Auditando Aplicaciones Android [rooted2018]
Cristian Barrientos - Auditando Aplicaciones Android [rooted2018]
 
planificacion wireless -c2
planificacion wireless -c2planificacion wireless -c2
planificacion wireless -c2
 
Olivares
OlivaresOlivares
Olivares
 
Aplicaciones Web Seguras (Anti-SQLi)
Aplicaciones Web Seguras (Anti-SQLi)Aplicaciones Web Seguras (Anti-SQLi)
Aplicaciones Web Seguras (Anti-SQLi)
 
Web App Security, Ethical hacking for CodeCamp SDQ 5
Web App Security, Ethical hacking for CodeCamp SDQ 5Web App Security, Ethical hacking for CodeCamp SDQ 5
Web App Security, Ethical hacking for CodeCamp SDQ 5
 
Backend middleware frontend (2)
Backend middleware frontend (2)Backend middleware frontend (2)
Backend middleware frontend (2)
 
Edge_presentacion
Edge_presentacionEdge_presentacion
Edge_presentacion
 
Sistema de vigilancia automatizado t5
Sistema de vigilancia automatizado t5Sistema de vigilancia automatizado t5
Sistema de vigilancia automatizado t5
 
Estructura auditoria cobit
Estructura auditoria cobitEstructura auditoria cobit
Estructura auditoria cobit
 
Seguridad en servidores
Seguridad en servidoresSeguridad en servidores
Seguridad en servidores
 
Seguridad y auditoría de Apps o aplicaciones móviles
Seguridad y auditoría de Apps o aplicaciones móvilesSeguridad y auditoría de Apps o aplicaciones móviles
Seguridad y auditoría de Apps o aplicaciones móviles
 
Desarrollo de una aplicación Web para organizar Eventos Deportivos
Desarrollo de una aplicación Web para organizar Eventos DeportivosDesarrollo de una aplicación Web para organizar Eventos Deportivos
Desarrollo de una aplicación Web para organizar Eventos Deportivos
 
Redes ii
Redes iiRedes ii
Redes ii
 
Los 7 pecados del Desarrollo Web
Los 7 pecados del Desarrollo WebLos 7 pecados del Desarrollo Web
Los 7 pecados del Desarrollo Web
 
Tu banca móvil, en forma simple y ¿segura? Estado de la seguridad en apps móv...
Tu banca móvil, en forma simple y ¿segura? Estado de la seguridad en apps móv...Tu banca móvil, en forma simple y ¿segura? Estado de la seguridad en apps móv...
Tu banca móvil, en forma simple y ¿segura? Estado de la seguridad en apps móv...
 

Más de 正炎 高

Más de 正炎 高 (13)

Analyzingbitcoinsecurity
AnalyzingbitcoinsecurityAnalyzingbitcoinsecurity
Analyzingbitcoinsecurity
 
比特币分叉相关
比特币分叉相关比特币分叉相关
比特币分叉相关
 
他山之石可以攻御
他山之石可以攻御他山之石可以攻御
他山之石可以攻御
 
Mvvm及其组件体系@杨文坚
Mvvm及其组件体系@杨文坚Mvvm及其组件体系@杨文坚
Mvvm及其组件体系@杨文坚
 
一个前端的自我修养 Winter
一个前端的自我修养 Winter一个前端的自我修养 Winter
一个前端的自我修养 Winter
 
下一代Web前端技术 陈子舜
下一代Web前端技术 陈子舜下一代Web前端技术 陈子舜
下一代Web前端技术 陈子舜
 
Ch04 secure software development_lifecycle
Ch04 secure software development_lifecycleCh04 secure software development_lifecycle
Ch04 secure software development_lifecycle
 
Android混淆技巧与反混淆 小波
Android混淆技巧与反混淆 小波Android混淆技巧与反混淆 小波
Android混淆技巧与反混淆 小波
 
Android 软件安全攻防研究现状 claud isf2012
Android 软件安全攻防研究现状 claud isf2012Android 软件安全攻防研究现状 claud isf2012
Android 软件安全攻防研究现状 claud isf2012
 
移动客户端恶意行为分析系统
移动客户端恶意行为分析系统移动客户端恶意行为分析系统
移动客户端恶意行为分析系统
 
基于大数据的Web攻击溯源
基于大数据的Web攻击溯源基于大数据的Web攻击溯源
基于大数据的Web攻击溯源
 
钱林松-专业逆向人才培养模式探讨与实践 - 21日上午分论坛2
钱林松-专业逆向人才培养模式探讨与实践 - 21日上午分论坛2钱林松-专业逆向人才培养模式探讨与实践 - 21日上午分论坛2
钱林松-专业逆向人才培养模式探讨与实践 - 21日上午分论坛2
 
圈圈App
圈圈App圈圈App
圈圈App
 

Último

redes informaticas en una oficina administrativa
redes informaticas en una oficina administrativaredes informaticas en una oficina administrativa
redes informaticas en una oficina administrativa
nicho110
 

Último (11)

Buenos_Aires_Meetup_Redis_20240430_.pptx
Buenos_Aires_Meetup_Redis_20240430_.pptxBuenos_Aires_Meetup_Redis_20240430_.pptx
Buenos_Aires_Meetup_Redis_20240430_.pptx
 
redes informaticas en una oficina administrativa
redes informaticas en una oficina administrativaredes informaticas en una oficina administrativa
redes informaticas en una oficina administrativa
 
Guia Basica para bachillerato de Circuitos Basicos
Guia Basica para bachillerato de Circuitos BasicosGuia Basica para bachillerato de Circuitos Basicos
Guia Basica para bachillerato de Circuitos Basicos
 
Innovaciones tecnologicas en el siglo 21
Innovaciones tecnologicas en el siglo 21Innovaciones tecnologicas en el siglo 21
Innovaciones tecnologicas en el siglo 21
 
Avances tecnológicos del siglo XXI 10-07 eyvana
Avances tecnológicos del siglo XXI 10-07 eyvanaAvances tecnológicos del siglo XXI 10-07 eyvana
Avances tecnológicos del siglo XXI 10-07 eyvana
 
PROYECTO FINAL. Tutorial para publicar en SlideShare.pptx
PROYECTO FINAL. Tutorial para publicar en SlideShare.pptxPROYECTO FINAL. Tutorial para publicar en SlideShare.pptx
PROYECTO FINAL. Tutorial para publicar en SlideShare.pptx
 
investigación de los Avances tecnológicos del siglo XXI
investigación de los Avances tecnológicos del siglo XXIinvestigación de los Avances tecnológicos del siglo XXI
investigación de los Avances tecnológicos del siglo XXI
 
How to use Redis with MuleSoft. A quick start presentation.
How to use Redis with MuleSoft. A quick start presentation.How to use Redis with MuleSoft. A quick start presentation.
How to use Redis with MuleSoft. A quick start presentation.
 
EVOLUCION DE LA TECNOLOGIA Y SUS ASPECTOSpptx
EVOLUCION DE LA TECNOLOGIA Y SUS ASPECTOSpptxEVOLUCION DE LA TECNOLOGIA Y SUS ASPECTOSpptx
EVOLUCION DE LA TECNOLOGIA Y SUS ASPECTOSpptx
 
Resistencia extrema al cobre por un consorcio bacteriano conformado por Sulfo...
Resistencia extrema al cobre por un consorcio bacteriano conformado por Sulfo...Resistencia extrema al cobre por un consorcio bacteriano conformado por Sulfo...
Resistencia extrema al cobre por un consorcio bacteriano conformado por Sulfo...
 
Avances tecnológicos del siglo XXI y ejemplos de estos
Avances tecnológicos del siglo XXI y ejemplos de estosAvances tecnológicos del siglo XXI y ejemplos de estos
Avances tecnológicos del siglo XXI y ejemplos de estos
 

安卓软件漏洞修复与检测技术研究-zhangyuan

  • 1. 安卓软件漏洞   修复与检测技术研究   张源    博士   复旦大学系统软件与安全实验室  
  • 2. 软件漏洞   2 •  攻击目的:privilege   –  突破沙箱、访问控制等防护机制   –  Know  something  you  are  not  allowed  to  know   –  Do  something  you  are  not  allowed  to  do   •  Code  Injection/Reuse  Attack?   –  使用受害者的身份运行攻击者指定的代码逻辑   –  二进制:利用内存读写漏洞   •   Buffer  overflow,  Format  string,  User-after-free,   Information  disclosure,  etc   –  Web:  Cross  Site  Scripting,  SQL  Injection,  etc   •  Insecure  privileged  interface   –  利用没有保护好的具有特权的接口   –  e.g  Cross  Site  Request  Forgery  
  • 3. 安卓软件漏洞   3 •  Code  Injection/Reuse  is  Hard!   –  Java  is  sandboxed,  memory-safe   –  Android  app  is  not  a  server   •  TRUE  until  wormhole?   –  Limited  injection/reuse  attack  cases   •  Java代码加载漏洞   •  WebView导致js代码注入   •  Capability  Leak  (Privilege  Escalation)   –  权限泄露漏洞   •  Confused  deputy   •  Component  hijacking   –  Content  Provider漏洞   •  Bad  security  practice   •  Insecure  SSL   •  Insecure  Crypto   •  Vulnerability?  or  Risk?  
  • 4. 主题:漏洞防护   4 漏洞检测   漏洞修复   代码分析   漏洞特征描述   漏洞特征报告   根据漏洞细节修复漏洞  
  • 5. 如何修复漏洞?   5 •  人工修复   –  理解漏洞?   –  如何修改?   –  确保没有引入新漏洞?   •  自动化程序重写   –  如何使所有版本更新?   •  有没有更好的选择?   –  Policy-driven的漏洞修复   –  系统级的漏洞修复支持  
  • 6. 权限泄露漏洞   6 public class SmsReceiverService extends Service { public int onStartCommand(Intent intent, int flags, int startId) { ... ... Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId; msg.obj = intent; mServiceHandler.sendMessage(msg); ... ... } private final class ServiceHandler extends Handler { public void handleMessage(Message msg) { Intent intent = (Intent)msg.obj; if (intent != null) { String action = intent.getAction(); ... ... } else if (SMS_RECEIVED_ACTION.equals(action)) { handleSmsReceived(intent, error); } ... ... } } } private void handleSmsReceived(Intent intent, int error) { SmsMessage[] msgs = Intents.getMessagesFromIntent(intent); String format = intent.getStringExtra("format"); Uri messageUri = insertMessage(this, msgs, error, format); if (messageUri != null) { long threadId = MessagingNotification.getSmsThreadId(this, messageUri); MessagingNotification.blockingUpdateNewMessageIndicator(this, threadId, false); } } } AOSP中Mms程序存 在的WRITE_SMS权 限泄露漏洞 
  • 7. 权限泄露漏洞分析   7 SmsReceiverService SmsReceiver WRITE_SMS leak SEND_SMS leak public interface a b c •  漏洞利用程序   – 三条漏洞路径:a、b、c->b   – 编写测试程序,均可成功利用这些漏洞  
  • 8. 权限泄露漏洞分析   8 •  Why  permission  leak?     –  intra/inter  component  interaction  share  the  same   communication  channel   –  components  may  be  designed  for  both  public  use   and  internal  use   •  Key  to  fix  permission  leak   – Identify  vulnerable  path   – Differ  public  use  or  internal  use  
  • 9. FineDroid   9   •  Key  Idea   –  Permission  Request    <-->    Application  Context   –  New  Granularity   •  At  the  level  of  application  execution  context   •  Application  Execution  Context   –  Intra-application  context,  mark  the  execution  flow   inside  the  app   –  Inter-application  context,  mark  the  IPC  behavior   among  interacted  apps   •  Policy-driven  Permission  Framework   –  Unified  Permission  Interception   –  Extensible  Policy  Framework  
  • 10. 系统设计   10   Library Layer Android Framework Linux Kernel App_1 App_2 Context Builder Context API Policy Manager Permission Manager Security Extensions Permission Record install policy extend action •  Building  and  Propagating  Context  along  with   application  execution   •  Intercept  all  permission  requests  with  system-wide   application  execution  context   •  Query  policy  framework  to  handle  permission   request  in  a  context-sensitive  manner  
  • 11. 核心模块   11   •  Context  Builder   – Intra-application  context  builder   – Inter-application  context  builder   •  Context  Propagator   – Intent-level,  Thread-level,  Event-level   •  Policy-driven  Permission  Framework   – Permission  Interception   – Extensible  Policy  Framework  
  • 12. Intra-application  Context  Builder   12   •  Mark  the  execution  flow  inside  the  app   – using  Calling  Context  to  monitor  internal   flow   – Probabilistic  Calling  Context  (PCC)   •  An  integer  birthmark  based  on  all  the   functions  in  the  flow   •  Can  be  calculated  with  a  recursive  expression   •  Call-site  birthmark:  offset  of  the  invoke-site  in   DEX     𝒑𝒄𝒄=𝟑  ∗ 𝒑𝒄𝒄‘+   𝒄𝒔,   𝑤ℎ𝑒𝑟𝑒   𝒑𝒄​ 𝒄↑′ 𝑖𝑠   𝑃𝐶𝐶   𝑣𝑎𝑙𝑢𝑒   𝑜𝑓   𝑐𝑎𝑙𝑙𝑒𝑟     𝑎𝑛𝑑   𝒄𝒔   𝑖𝑠   𝑡ℎ𝑒   𝑏𝑖𝑟𝑡ℎ𝑚𝑎𝑟𝑘   𝑜𝑓   𝑐𝑎𝑙𝑙   𝑠𝑖𝑡𝑒  
  • 13. Inter-application  Context  Builder   13   •  Mark  the  IPC  behavior  of  interacted   apps   – Using  Binder  to  track  IPC  behaviors   – Inter-Context:  UID  +  PCC   App_1 App_1 (uid: pcc) interaction Context: None App_1 (uid, pcc) App_2 App_3 Linux Kernel interaction User Space App_2 (uid: pcc) App_1 (uid: pcc) App_1 (uid: pcc) App_2 (uid: pcc)
  • 14. Context  Propagating   14   •  Complex  application  dynamics  may   break  the  context  propagating   •  Intent-level   •  Solution:  bind  context  to  Intent  object   App_A (uid_A, pcc_A) AMS App_B (uid_B, pcc_B) Zygote Spawn request fork (uid_B, pcc_B) (uid_AMS, pcc_AMS) Binder request App_A (uid_A, pcc_A) AMS App_B (uid_A, pcc_A) (uid_AMS, pcc_AMS) Binder request (a) When App_B is started (b) When App_B is not started
  • 15. Context  Propagating   15   •  Thread-level   – New  thread  should  inherit  the  context  of   its  parent  thread   – New  resumed  thread  should  inherit  the   context  of  the  initiator  thread   •  Event-level   – Async  behaviors  via  callbacks   – e.g.,  OnClickListener,  OnLocationListener   – Callbacks  should  inherit  the  context  of  its   register  
  • 16. Policy-driven  Permission  Framework   16   •  Permission  Interception   – Goal:  intercepts  all  permission  use  and   manages  the  requests  in  a  unified  point   – Kernel-Enforced  Permission   •  relies  on  UID/GID  isolation   •  redirects  the  permission  requests  to  framework     – Android-Enforced  Permission   •  relies  on  PMS  to  check  permission   •  queries  policy  manager  to  make  a  decision  
  • 17. Policy-driven  Permission  Framework   17   •  Policy  Language   – Declarative  language  to  specify  rules     – Implemented  in  XML  format   •  Tags:  policy,  uid-selector,  uid-context,  pcc- selector,  method-sig,  or,  and,  not   •  Details  can  be  found  in  the  paper   •  Policy  Matching   –  Find  a  policy  that  best  match  the  current  context   policy := <action> <app> <permission> <context> action := grant | deny | ...
  • 18. 修复Mms中的权限泄露漏洞   18   •  How  to  Fix?   –  With  inter-application  context,  differ  public  use  or   internal  use   –  With  intra-application  context,  accurately   describe  the  vulnerable  flow   –  e.g,  Fix  SEND_SMS  permission  leak  in   SmsReceiver   <policy action=”deny” app=”com.android.mms” permission=”SEND_SMS” > <uid-selector selector=”strictcontains” > <uid-context uid=”^com.android.mms” pcc=”*” /> <uid-context uid=”com.android.mms” /> <pcc-selector selector=”contains” > <method-sig className=”com.android.mms.transaction.SmsReceiver” methodName=”beginStartingService” /> </pcc-selector> </uid-context> </uid-selector> </policy>
  • 19. 修复规则自动生成   19 •  基于漏洞检测工具   –  CHEX  [CCS  2012]   –  对检测日志分析,提取函数调用路径和组件信息   应用名  泄露路径数  生成规则数  com.gmail.traveldevel.android.vlc.app-131  2  2  com.froogloid.kring.google.zxing.client.android-67  24  24  de.cellular.tagesschau-5  361  361  com.akbur.mathsworkout-92  2  2  com.appspot.swisscodemonkeys.paintfx-4  2  2  com.androidfu.torrents-26  1  1  com.espn.score_center-141  6  6  com.espn.score_center-142  6  6  fr.pb.tvflash-9  2  2  hu.tagsoft.ttorrent.lite-15  8  8  总计  414  414 
  • 20. 原型系统   20   •  Android  4.1.1,  Nexus  Prime  and   emulators   •  Retrofitted  Modules   – Linux  Kernel   •  for  intra/inter  context  building   •  for  Kernel  permission  interception   – Android  Framework   •  for  context  propagating   •  for  policy  management   – No  modification  to  apps  
  • 21. 性能测试   21   •  Overall  Performance   –  less  than  2%,  in  Linpack,  AnTuTu,  CaffeineMark3  
  • 22. 性能测试   22   •  Permission  Requesting  Handling   •  Policy  Matching   Permission Type Origin Android FineDroid w/o Context FineDroid w/ Context Socket(KEP) 0.14ms 2.16ms Δ2.02ms 2.18ms Δ0.02ms IMEI(AEP) 0.62ms 0.69ms Δ0.06ms 1.09ms Δ0.40ms Permission Type FineDroid w/o Policy FineDroid w/ Policy Overhead Socket(KEP) 2.18 ms 3.06 ms 0.88 ms IMEI(AEP) 1.09 ms 1.99 ms 0.90 ms
  • 23. FineDroid的其他应用场景   23 •  一、细粒度的权限授予机制   – 程序中可能会有多个地方使用同一个权限   – 程序为粒度的权限决策是否足够灵活?   – 重打包(恶意)应用程序?   – 安全性  vs  可用性  
  • 24. FineDroid的其他应用场景   24 •  二、进程间栈自省技术   –  不同的代码模块具有不同的权限配置   –  E.g.  地理位置权限   •  广告库需要用到   •  程序自身也需要用到   •  可否只将权限授予给程序自身的代码?   •  采用包含Flurry广告插件的应用程序Stock  Watch进行实验   ... <fine-permission android:package="com.flurry.android"> <deny android:permission="android.permission.ACCESS_FINE_LOCATION" /> <deny android:permission="android.permission.ACCESS_COARSE_LOCATION" /> </fine-permission> ...
  • 25. FineDroid的其他应用场景   25 •  二、进程间栈自省技术   –  不同的代码模块具有不同的权限配置   –  E.g.  地理位置权限   •  广告库需要用到   •  程序自身也需要用到   •  可否只将权限授予给程序自身的代码?   •  采用包含Flurry广告插件的应用程序Stock  Watch进行实验   •  原程序使用该权限不受影响   –  FlexDroid:  In-app  Privilege  Separation[NDSS  2016]   com.snapwork.finance(10053:914896) android.permission.ACCESS_FINE_LOCATION DENIED com.flurry.android.e-e-LL-42 com.flurry.android.e-a-VLLZ-3 com.flurry.android.v-run-V-21
  • 26. 漏洞检测   26 •  基于静态分析的漏洞检测   –  Automatically  check  app  behaviors  at  runtime   •  Check  attacker-controlled  input  will  influence  privileged   actions   –  Conservative   •  Value  not  determined  at  static-phase   •  Path  not  determined  at  static-phase   •  …   •  常用的分析手段   –  CFG   •  单个函数的行为和逻辑分析   –  Call  Graph   •  所有可能的执行流   –  Data    Dependency  Graph   •  在执行流的基础上所有可能的数据依赖情况  
  • 27. 现有分析工具   27 •  FlowDroid  [PLDI  2014]   –  Soot:  Java  Analysis  Framework   –  SPARK:  point-to  analysis   –  Dexpler:  dex->jimple   –  IDE/IFDS-based  Information  Flow  Analysis   –  context-,  flow-,  field-,  object-sensitive  and  lifecycle- aware   –  Heavyweight,  not  designed  for  Android   •  Amandroid  [CCS  2014]   –  Sireum:  static  analysis,  symbolic  execution,  etc   –  context-,  flow-sensitive  and  handles  ICC   –  written  in  Scala   –  Hard  to  study,  limited  community  support  
  • 28. Daf:  Dex  Analysis  Framework   28 •  Overview   –  Directly  analyze  dex,  build  from  dexlib   –  Highly  customizable   –  written  in  Java,  still  under  development   –  context-,  flow-,  field-,  object-sensitive   •  Modules   –  Point-to  analysis   –  Call  Graph   –  Data  Dependency  Graph   –  String  analysis   –  Constant  analysis   –  Exception  analysis   –  ICC  Analysis  (to  do)  
  • 29. 漏洞检测框架   29 CFG  Builder   String  Analysis   Class   Hierarchy   Pointer-­‐to   Call  Graph   Data  Dependency  Graph   SDK  Model   Constant  Analysis   Daf:  Dex  Analysis  Framework   Dos  Checker   XXX  Checker   Permission  Leak  Checker   Code  InjecDon  Checker   Crypto  Checker   SSL  Checker   Vulnerability  Checkers   Control  Flow  Information   Data  Flow  Information  
  • 30. 以DosChecker为例   30 •  Input-Validation  Flaws  in  Components   – Intent-related  APIs  may  cause  exceptions   – NullPointerException   – ClassCastException   – ClassNotFoundException  
  • 31. 检测方法   31 •  静态检测   –  Exception分析   •  识别会触发Dos异常的语句(Intent相关API)   •  判断是否有try-catch块   –  Intent分析   •  判断出现异常的点是否为攻击者可以控制的输入   •  动态测试   –  String分析   •  Intent.setAction(String)   •  Intent.putExtra(String,  Object)   –  Intent注入器   •  发送Intent到目标程序组件   •  检测程序组件是否Crash  
  • 32. 案例分析-平安口袋银行   32 •  SSL缺陷   – ISF  2014   – 登陆信息泄露   – 转账信息泄露   – 用户信息泄露   – 转账交易泄露/劫持  
  • 33. 案例分析-中国电信翼支付   33 •  支付授权缺陷   – GeekPwn  2015  优胜奖   – 任意账户金额远程盗刷   – 自动遍历受害账户进行攻击  
  • 34. 总结   34 漏洞检测   漏洞修复   代码分析   漏洞特征描述   漏洞特征报告   根据漏洞细节修复漏洞   Daf漏洞检测框架   •  基于DEX的静态分析   •  Plugin-based漏洞检测   FineDroid安全框架   •  程序上下文跟踪   •  Policy-driven漏洞修复