当前位置: 首页 > news >正文

Binder.getCallingPid()和Binder.getCallingUid()漏洞分析

最近在学习安卓漏挖,在分析ghera数据集时发现一个很有意思的binder特性,但还没搞懂底层原理,先挖个坑

漏洞分析

EnforceCallingOrSelfPermission-PrivilegeEscalation-Lean

以下代码使用Binder.getCallingPid()和Binder.getCallingUid()对调用方进行了权限检查

// MyService.java
public int onStartCommand(Intent intent, int flags, int startId) {Log.d("MyService", "Calling PID = " + Binder.getCallingPid() + " Calling UID  = " + Binder.getCallingUid());if (checkPermission("santos.benign.permission", Binder.getCallingPid(), Binder.getCallingUid()) == PackageManager.PERMISSION_GRANLog.d("MyService", "Service Started");Intent activityIntent = new Intent(this, SensitiveActivity.class);activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);activityIntent.putExtra("status_msg", "SUCCESS");this.startActivity(activityIntent);} else {Log.d("MyService", "Failed to start the service");}return super.onStartCommand(intent, flags, startId);
}

其中调用方如下

// MainActivity.java
protected void onResume() {super.onResume();if (checkPermission("santos.benign.permission", android.os.Process.myPid(), android.os.Process.myUid()) == PackageMLog.d("MyService", "permission to service already granted");startService(new Intent(getApplicationContext(), MyService.class));} else {Log.d("MyService", "component does not have permission to call service");ActivityCompat.requestPermissions(this, new String[]{"santos.benign.permission"}, 100);}
}

可以看到,MyService是由MainActivity启动的,也就是他们都属于主线程。而在主线程调用Binder.getCallingPid()和Binder.getCallingUid()不会返回调用方的信息,只会返回自身进程的信息,这样上面代码的权限校验相当于只对自身权限做了检查,正确的做法应该是在manifest中静态声明权限或使用EnforceCallingPermission方法进行校验

http://www.jsqmd.com/news/11498/

相关文章:

  • 详细介绍:golang基础语法(五)切片
  • 让博客园设置支持PlantUml画图
  • jj
  • 光谱相机的未来趋势 - 详解
  • 面向对象抽象,接口多态综合-动物模拟系统
  • 实用指南:APache shiro-550 CVE-2016-4437复现
  • Spark - deprecated registerTempTable() function
  • MinGW-即时入门-全-
  • 个人微信开发文档
  • Splay学习笔记
  • 象棋图片转FEN字符串详细教程
  • 自然语言处理在风险识别中的应用
  • 详细介绍:正点原子【第四期】Linux之驱动开发学习笔记-6.1 pinctrl和gpio子系统
  • cat
  • 深入解析:可持续金融的新范式:拆解欧盟ESG监管体系及其全球影响力
  • Docker和K8S的区别详解 - 指南
  • qt everywhere souce code编译 - 实践
  • 2023 CCPC final G
  • 完整教程:微软 Azure AI 视频翻译服务助力 JowoAI 实现短剧高效出海
  • 2025 年高可靠性测试设备/HALT/HASS/Halt/Hass/厂家制造商推荐榜:聚焦高效质量解决方案,助力企业产品升级
  • 八字手链人物传记计划——旭
  • 详细介绍:c# datagridview添加list内容
  • 20232309 2025-2026-1 《网络与系统攻防技术》实验一实验报告
  • 亚马逊发布基于Linux的Vega OS电视系统,禁止侧载应用
  • .net9.0 JWT AUTH2.0 添加身份认证授权
  • 扣子系列教程
  • 实用指南:同时使用ReactUse 、 ahooks与性能优化
  • 解决vscode中用npm报错
  • MATLAB复杂曲线曲面造型及导函数实现
  • 2025 年最新月嫂培训机构推荐榜单:短期 / 精英 / 金牌 / 高端月嫂培训及就业推荐,精选优质机构