感谢提交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.


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


【问题描述】
在 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(跨用户拒绝 + 同用户放行)。