敏感系统数据可能暴露于未经授权的控制范围¶
ID: cpp/potential-system-data-exposure
Kind: path-problem
Security severity: 6.5
Severity: warning
Precision: medium
Tags:
- security
- external/cwe/cwe-497
Query suites:
- cpp-security-extended.qls
- cpp-security-and-quality.qls
暴露系统数据或调试信息可能会帮助恶意用户了解系统并制定攻击计划。攻击者可以利用揭示技术、操作系统和产品版本的错误消息来调整其针对软件中已知漏洞的攻击。
此查询查找特别敏感的系统配置信息可能泄露给用户的位置。
建议¶
不要向用户暴露系统配置信息。注意区分可能对用户有用的信息和可能对恶意用户有用的不必要细节。
示例¶
在此示例中,当发生特定错误时,PATH
环境变量的值会完整地泄露给用户。这可能会向无权访问该信息的恶意用户泄露系统上安装的软件等信息。
char* key = getenv("APP_KEY");
//...
fprintf(stderr, "Key not recognized: %s\n", key);
应在不包含此信息的情况下重新表述消息,例如
char* key = getenv("APP_KEY");
//...
fprintf(stderr, "Application key not recognized. Please ensure the key is correct or contact a system administrator.\n", key);
参考¶
常见漏洞枚举:CWE-497。