当前位置: 首页 > 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.gsyq.cn/news/18749.html

相关文章:

  • 实用指南:APache shiro-550 CVE-2016-4437复现
  • Spark - deprecated registerTempTable() function
  • 自然语言处理在风险识别中的应用
  • cat
  • .net9.0 JWT AUTH2.0 添加身份认证授权
  • 实用指南:同时使用ReactUse 、 ahooks与性能优化
  • 解决vscode中用npm报错
  • 2025 年中频炉厂商最新推荐排行榜权威发布,深度剖析应达电气等优质企业核心优势及选购要点节能/智能/自动化成套/高效率/智能感应加热中频炉厂家推荐
  • 详细介绍:Day52 串口通信原理与IMX6ULL UART驱动开发
  • vue3实现抓拍并上传
  • 2025不锈钢管件厂家推荐榜:技术实力与诚信口碑双重保障
  • 【Qt开发】输入类控件(二)-> QTextEdit - 详解
  • 基于MATLAB的禁忌搜索算法解决物流网络枢纽选址问题
  • 详细揭秘:详细揭秘:集合划分容斥的容斥系数
  • 学好微积分特别是偏微分方程的数值求解对于学习CFD的好处?
  • 基于Logistic映射与Chen超混沌系统结合DNA分块编解码的图像加密技术
  • Web前端入门第 88 问:引入 JavaScript 的 script 标签究竟有多少用法?
  • 我如何控制新增的节点是 leader 还是follower呢?
  • 2025 年全屋定制 / 高端 / 装修收纳设计 / 不锈钢橱柜 / 别墅 / 大平层装修公司推荐:苏州伍德家居与百能家居的优质定制解决方案解析
  • SAS重要证明结论
  • 2025 年蒸汽发生器厂家最新推荐排行榜:含 800KG 燃气 / 超低氮冷凝 / 400KG 燃气等多类型设备企业优选指南
  • 全网首发/Qt结合ffmpeg实现rist推拉流/可信赖的互联网流媒体协议/跨平台支持各个系统
  • 2025 年灌装机厂家最新推荐权威榜单:聚焦全自动液体定量灌装设备,精选饮用水 / 纯净水 / 矿泉水灌装领域优质企业
  • 2025 年灌装生产线厂家最新推荐排行榜:覆盖饮料 / 矿泉水 / 纯净水 / 桶装水 / 全自动生产线,助力企业精准选购优质设备权威榜单
  • Vue 创建项目的几种方式
  • C# 使用WebView2加载本地资源
  • 从零开始部署Android环境的Jenkins CI/CD流水线(docker环境,Win强大的系统)
  • 集群、分布式、微服务
  • 改了 Nacos 一行配置,搞崩线上支付系统!
  • Gitee Insight领跑DevSecOps赛道:2025研发效能工具全景评测