已开启
常驻应用按需拉起支持SA #20370
常驻应用按需拉起支持SA #20370
已开启
zhangtao创建于 4 天前
zhangtao
zhangtao
4 天前

IssueNo:
https://gitcode.com/openharmony/ability_ability_runtime/issues/16136
Description:
常驻应用按需拉起支持SA
稳定性自检:

自检项 自检结果
涉及跨进程调用的相关操作需要抛至主线程或加锁防止并发
成员变量进行赋值或创建需要排查并发
谨慎在lambda表达式中使用引用捕获
谨慎在未经拷贝的情况下使用外部传入的string、C字符串
map\vector\list\set等stl模板类使用时需要排查并发
谨慎考虑加锁范围
在IPC通信中谨慎使用同步通信方式
禁止传递this指针至其他模块或线程(特别是eventhandler任务)
禁止将外部传入的裸指针在内部直接构造智能指针
禁止多个独立创建的智能指针管理同一地址
禁止在析构函数中抛异步任务
禁止js对象在非js线程(例如在IPC线程)创建、使用或销毁
禁止在对外接口中未经判空直接使用外部传入的指针
禁止接口返回局部变量引用
禁止在信号函数中加锁
禁止在关键流程(SA启动、应用启动等主流程)执行耗时的操作
禁止将同一个cpp编译在不同的so中

安全编码自检:

自检项 自检结果
裸指针避免通过隐式转换构造为sptr
json对象在取值之前必须先判断类型,避免类型不匹配
序列化时必须对传入的数组大小进行校验,避免出现超大数组
避免使用未明确位宽的整型,选择使用int8_t、uint8_t等类型
外部传入的路径要做规范化校验,对路径中的.、..、../等特殊字符严格校验
指针变量、表示资源描述符的变量、bool变量必须赋初值
readParcelable获取的对象使用前需要判空
分配和释放内存的函数需要成对出现
申请内存后异常退出前需要及时进行内存释放
内存申请前必须对内存大小进行合法性校验
内存分配后必须判断是否成功
禁止使用realloc、alloca函数
禁止打印文件路径、口令等敏感信息,如有需要,使用private修饰
禁止打印内存地址
整数之间运算时必须严格检查,确保不会出现溢出、反转、除0
禁止对有符号整数进行位操作符运算
禁止对指针进行逻辑或位运算
循环次数如果收外部数据控制,需要检验其合法性
禁止使用内存操作类危险函数,需要使用安全函数
谨慎使用不可重入函数
必须检查安全函数的返回值,并进行正确处理
禁止仅通过TokenType类型判断绕过权限校验

TDD Result:

XTS Result:

是否已执行L0用例

AI检视评分(使用本地代码检视skills扫描):

likedislike
合并受阻
afwk_helper成员
4 天前 评论:

开始进行AI检视!

AI review has been started, please wait...

likedislike
afwk_helper成员
4 天前 评论:
check type result report
start ai_review pass -
likedislike
openharmony_ciopenharmony_ci成员
4 天前 添加了label:waiting_on_author
openharmony_ci
openharmony_ci成员
4 天前 评论:

感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接


Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
openharmony_ciopenharmony_ci成员
4 天前 添加了label:dco检查成功
afwk_helper成员
4 天前 评论:

⚠️ 🤖 AI 代码检视报告 ⚠️

总体评估: NEEDS_ATTENTION

问题统计:

  • 总问题数: 2
  • 严重问题: 0
  • 高危问题: 0

摘要:
PR支持SA拉起常驻应用,但将bundleName直接作为callerName绕过权限校验的设计存在潜在安全风险,且测试用例存在变量遮蔽问题。

📊 详细报告
查看完整的审查详情,包括具体的问题描述、建议和代码位置:
🔗 查看详细报告


此评论由 OpenHarmony Insight 代码审查系统自动生成

likedislike
afwk_helper成员4 天前进行代码检视2
services/abilitymgr/src/ability_manager_service.cpp
已过期
@@ -16185,3 +16186,1 @@
16185- int32_t uid = 0;
16186- auto callerPid = IPCSkeleton::GetCallingPid();
16187- DelayedSingleton<AppScheduler>::GetInstance()->GetBundleNameByPid(callerPid, callerName, uid);
16186+ if (isSACall) {
afwk_helper4 天前评论:

🤖 AI 代码检视意见(回复本评论可解决检视意见,点击被检视代码行左侧的小头像可收起检视意见)


🟡 SA调用者通过bundleName绕过权限校验存在安全风险

位置: L16186-L16193 | 严重程度: Medium

❓ 问题描述

SetResidentProcessEnabled 中,当 isSACall 为 true 时,直接将 bundleName 赋值给 callerName。由于后续 VerifyConfigurationPermissions 会使用 callerName 进行权限校验,这种做法等同于让任意 System Ability (SA) 能够绕过应用级别的权限校验,对任意 bundleName 的常驻进程进行启停操作。如果 IsSACall() 的判定过于宽泛,或者某个 SA 被攻破,将导致非预期的应用被拉起或系统资源耗尽。

💡 修复建议

修改建议:确认 IsSACall() 是否对 SA 调用者进行了严格的身份校验。当前实现允许任意 SA 通过传入任意 bundleName 绕过 VerifyConfigurationPermissions 校验。建议在代码中补充安全设计说明,或为 SA 调用者增加更细粒度的权限校验,避免非预期 SA 滥用此接口。

16186: if (isSACall) {
16187: // SA process is not managed by appmgr, use bundleName as callerName to pass permission check.
16188: // 建议:增加对特定SA权限的校验,或在注释中明确说明此操作的安全前提。
16189: callerName = bundleName;
16190: } else {


likedislike
System
系统消息系统
3 天前 评论:

changed this line on 3abf66c4 view diff detail

zhangtaozhangtao
4 天前 审查状态已重置,审查人: afwk_helper
zhangtaozhangtao
4 天前 推送  1 个提交:8af30130-去掉不必要的注释
openharmony_ci
openharmony_ci成员
4 天前 评论:

感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接


Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
zhangtao
zhangtao
4 天前 评论:

static-check

likedislike
openharmony_ci
openharmony_ci成员
4 天前 评论:


静态检查:

# check type result report
1 codeCheck pass >>>

likedislike
zhangtaozhangtao
4 天前 修改了pull request 的描述
zhangtaozhangtao
3 天前 审查状态已重置,审查人: afwk_helper
zhangtaozhangtao
3 天前 推送  1 个提交:3abf66c4-检视修改
openharmony_ci
openharmony_ci成员
3 天前 评论:

感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接


Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
zhangtao
zhangtao
3 天前 评论:

static-check

likedislike
openharmony_ci
openharmony_ci成员
3 天前 评论:


静态检查:

# check type result report
1 codeCheck pass >>>

likedislike
zhangtaozhangtao
3 天前 审查状态已重置,审查人: afwk_helper
zhangtaozhangtao
3 天前 推送  1 个提交:070dd54c-修复编译
openharmony_ci
openharmony_ci成员
3 天前 评论:

感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接


Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
zhangtao
zhangtao
3 天前 评论:

static-check

likedislike
openharmony_ci
openharmony_ci成员
3 天前 评论:


静态检查:

# check type result report
1 codeCheck pass >>>

likedislike
zhangtaozhangtao
2 天前 审查状态已重置,审查人: afwk_helper
zhangtaozhangtao
2 天前 强制推送  1 个提交:ec49e460-初步实现按需常驻支持SA
openharmony_ci
openharmony_ci成员
2 天前 评论:

感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接


Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike