已关闭
【安全漏洞】AppMgrService ClearUpApplicationData 缺少 callerUser==userId 归属校验,PC 普通用户可跨用户清除其他用户应用数据 #16399
张昊峥创建于  27 天前关闭于  19 天前
张昊峥
张昊峥
27 天前 创建

【问题描述】

在 PC 多用户场景下,新建的普通用户(如 u100)可以通过 hishell 执行 bm 命令,指定其他 userId(如管理员用户、u0/u1),跨用户清除不归属本用户的应用数据。

【根因分析】

AppMgrServiceInner::ClearUpApplicationData(services/appmgr/src/app_mgr_service_inner.cpp)在显式指定 userId >= 0 时,仅依赖调用方权限校验(CLEAN_APPLICATION_DATA / 开发者模式 + ALLOW_USE_BM),缺少 callerUser == userId 的归属校验:

  • 调用方归属用户 GetUserIdByUid(callerUid) 与目标 userId 不一致时不拦截;
  • ClearUpApplicationDataBySelf 显式传入其他 userId 时同样可越界清除同包名在其他用户下的数据(清权限、删数据、杀进程)。

【修复方案】

在 AppMgrServiceInner::ClearUpApplicationData 与 ClearUpApplicationDataBySelf 入口增加归属校验:非系统用户(callerUserId > U1)且显式指定 userId >= 0 时,要求 GetUserIdByUid(callerUid) == userId,否则返回 CHECK_PERMISSION_FAILED。u0/u1 系统侧调用(含 root/shell)保持原有行为,不引入功能回归。

【影响】

  • 越权清除其他用户应用数据(数据破坏 + 授权回收 + 进程终止)。
  • 修复后普通用户仅能清除归属本用户的应用数据。

【用例】

补充 TDD 单测用例:ClearUpApplicationData_002(跨用户拒绝 + 同用户放行)。

likedislike
openharmony_ci
openharmony_ci成员
27 天前 评论:

感谢提交Issue!关于Issue的交互操作,请访问OpenHarmony社区支持命令清单。如果有问题,请联系 [@jayleehw](https://gitcode.com/jayleehw) [@zhangyafei-echo](https://gitcode.com/zhangyafei-echo) [@littlejerry1](https://gitcode.com/littlejerry1) [@jsjzju](https://gitcode.com/jsjzju) [@wkljy](https://gitcode.com/wkljy) [@yzkp](https://gitcode.com/yzkp) [@ccllee1](https://gitcode.com/ccllee1) [@yangxuguang-huawei](https://gitcode.com/yangxuguang-huawei) [@li-weifeng2024](https://gitcode.com/li-weifeng2024) [@wendel](https://gitcode.com/wendel) 。如果需要调整订阅PR、Issue的变更状态,请访问链接。


Thanks for submitting the issue. For more commands, please visit OpenHarmony Command List. If you have any questions, please refer to committer gitcode for help. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
openharmony_ciopenharmony_ci成员
27 天前 添加了label:waiting_for_assign
张昊峥
张昊峥
27 天前 评论:

�޸� PR �Ѵ�����https://gitcode.com/openharmony/ability_ability_runtime/merge_requests/20637
�޸��������� AppMgrServiceInner::ClearUpApplicationData / ClearUpApplicationDataBySelf ������� callerUser == userId ����У�飬��ϵͳ�û����û������ݷ��� CHECK_PERMISSION_FAILED��

likedislike
openharmony_ciopenharmony_ci成员
19 天前 关闭了 issue
openharmony_ciopenharmony_ci成员
19 天前 issue状态由 待办的 改变为 已完成