Dashboard/Issues/OH-2026-ARK-001
SubmittedCWE-306 — Missing Authentication for Critical Function

AotCompilerInterfaceStub::OnRemoteRequest 缺少调用者身份验证

View Upstream Issuegitcode.com/openharmony/arkcompiler_ets_runtime/issues/12884
CWE:CWE-306 — Missing Authentication for Critical Function
Date:2026-04-29
Reporter:Zirui

您好,

arkcompiler_ets_runtime 的 AOT 编译服务存在调用者身份验证缺失。

文件: compiler_service/interface/aot_compiler_interface_stub.cpp CWE: CWE-306 (Missing Authentication for Critical Function)

背景

调用类似于 OnRemoteRequest 功能的函数,理论上需要进行身份验证。

security_access_token 仓库的 TokenSyncManagerStub 为参照:

// TokenSyncManagerStub::OnRemoteRequest
if (!IPCSkeleton::IsLocalCalling()) {        // 拒绝远程调用
    return ERR_PERMISSION_DENIED;
}
// 每个 handler 方法中:
if (!IsNativeProcessCalling()) { ... }       // TokenID 验证
if (!IsRootCalling()) { ... }                // UID 验证

问题描述

AotCompilerInterfaceStub::OnRemoteRequest(aot_compiler_interface_stub.cpp:21-50)仅通过 ReadInterfaceToken() 进行接口描述符校验,未调用任何调用者身份验证 API(如 GetCallingPid/GetCallingUid/GetCallingTokenID/VerifyAccessToken)。

整个调用链:

OnRemoteRequest (无身份检查)
  → CommandAOTCompiler (无身份检查)
    → AotCompilerService::AotCompiler (无身份检查)
      → AotCompilerImpl::EcmascriptAotCompiler (无身份检查)
        → fork + execv("/system/bin/ark_aot_compiler", argsMap)

CommandAOTCompiler(line 52-86)从 IPC 读取 argsMapSize 和键值对参数,直接传递给 AOT 编译器执行。BUNDLE_UIDBUNDLE_GID 由调用者提供的 argsMap 决定(DropCapabilities 使用这些值),而非系统级身份验证。

经确认,compiler_service/ 目录下对 GetCallingPidGetCallingUidGetCallingTokenIDVerifyCallingPermissionVerifyAccessTokenCheckPermission 的调用数量为

攻击者可触发的操作

  • CommandAOTCompiler: 触发 AOT 编译,消耗 CPU/磁盘资源,可能覆盖其他应用的编译产物
  • CommandStopAOTCompiler: 终止正在进行的合法编译(拒绝服务)
  • CommandGetAOTVersion / CommandNeedReCompile: 查询编译状态信息

与标准模式的对比

security_access_token 仓库的 TokenSyncManagerStub 为参照:

// TokenSyncManagerStub::OnRemoteRequest
if (!IPCSkeleton::IsLocalCalling()) {        // 拒绝远程调用
    return ERR_PERMISSION_DENIED;
}
// 每个 handler 方法中:
if (!IsNativeProcessCalling()) { ... }       // TokenID 验证
if (!IsRootCalling()) { ... }                // UID 验证

AotCompilerInterfaceStub 未实现上述任何检查。

建议修复

OnRemoteRequestCommandAOTCompiler 入口处添加调用者身份验证:

  • 方案一:调用 IPCSkeleton::GetCallingUid() 验证调用者是否为系统进程
  • 方案二:调用 IPCSkeleton::IsLocalCalling() 限制仅本地调用
  • 方案三:添加 AccessTokenKit::VerifyAccessToken() 权限令牌验证