CodeQL 文档

在 SECURITY_DESCRIPTOR 中将 DACL 设置为 NULL

ID: cpp/unsafe-dacl-security-descriptor
Kind: problem
Security severity: 7.8
Severity: error
Precision: high
Tags:
   - security
   - external/cwe/cwe-732
Query suites:
   - cpp-code-scanning.qls
   - cpp-security-extended.qls
   - cpp-security-and-quality.qls

单击以查看 CodeQL 仓库中的查询

此查询表明调用正在将 SECURITY_DESCRIPTOR 中的 DACL 字段设置为 null。

使用 SetSecurityDescriptorDacl 设置任意访问控制列表 (DACL) 时,将 bDaclPresent 参数设置为 TRUE 表示参数 pDacl 中的安全描述符中存在 DACL。

pDacl 参数不指向 DACL(即它为 NULL)并且 bDaclPresent 标志为 TRUE 时,将指定 NULL DACL

NULL DACL 会向请求访问权限的任何用户授予完全访问权限;不会针对对象执行正常的安全检查。

建议

你不应该对对象使用 NULL DACL,因为任何用户都可以更改安全描述符的 DACL 和所有者。

示例

在以下示例中,对 SetSecurityDescriptorDacl 的调用正在将不安全的 DACL (NULL DACL) 设置为安全描述符。

SECURITY_DESCRIPTOR  pSD;
SECURITY_ATTRIBUTES  SA;

if (!InitializeSecurityDescriptor(&pSD, SECURITY_DESCRIPTOR_REVISION))
{
    // error handling
}
if (!SetSecurityDescriptorDacl(&pSD,
    TRUE,   // bDaclPresent - this value indicates the presence of a DACL in the security descriptor
    NULL,   // pDacl - the pDacl parameter does not point to a DACL. All access will be allowed
    FALSE))
{
    // error handling
}

要修复此问题,pDacl 参数应指向一个 ACL 结构,该结构指定安全描述符的 DACL。

参考

  • ©GitHub, Inc.
  • 条款
  • 隐私