SubmittedCWE-476 — NULL Pointer Dereference
FirstUseDialog::SendSaveEventHandler 未检查 secHandler_ 空指针
View Upstream Issuegitcode.com/openharmony/security_security_component_manager/issues/395CWE:CWE-476 — NULL Pointer Dereference
Repository:security_security_component_manager
Date:2026-05-07
Reporter:Zirui
漏洞概述
FirstUseDialog::SendSaveEventHandler 直接调用 secHandler_->ProxyPostTask(delayed) 而未检查 secHandler_ 是否为 nullptr。同类中其他函数(如 NotifyFirstUseDialog line 520)对 secHandler_ 有 nullptr 检查,证明该成员可能为空。
漏洞详情
问题代码
文件: services/security_component_service/sa/sa_main/first_use_dialog.cpp:469-477
void FirstUseDialog::SendSaveEventHandler(void)
{
std::function<void()> delayed = ([this]() {
this->SaveFirstUseRecord();
});
SC_LOG_INFO(LABEL, "Delay first_use_record json");
secHandler_->ProxyPostTask(delayed); // ← 无 null check
}
对比:同类正确实现
文件: first_use_dialog.cpp:520-523
int32_t FirstUseDialog::NotifyFirstUseDialog(...)
{
// ...
if (secHandler_ == nullptr) { // ← 正确:检查了 nullptr
SC_LOG_ERROR(LABEL, "event handler invalid.");
return SC_SERVICE_ERROR_VALUE_INVALID;
}
// ...
}
触发条件
FirstUseDialog对象的secHandler_成员未初始化或已被置空- 调用
SendSaveEventHandler时解引用 nullptr → SIGSEGV - 可能在服务初始化阶段或异常恢复路径中触发
影响
- security_component_service 服务进程崩溃
- 安全组件首次使用记录丢失
- 服务重启期间安全组件功能不可用
修复建议
void FirstUseDialog::SendSaveEventHandler(void)
{
std::function<void()> delayed = ([this]() {
this->SaveFirstUseRecord();
});
SC_LOG_INFO(LABEL, "Delay first_use_record json");
+ if (secHandler_ == nullptr) {
+ SC_LOG_ERROR(LABEL, "secHandler_ is nullptr in SendSaveEventHandler");
+ return;
+ }
secHandler_->ProxyPostTask(delayed);
}
涉及文件
services/security_component_service/sa/sa_main/first_use_dialog.cpp(line 476) — 缺失 null check