CWE-558: Use of getlogin() in Multithreaded Application

Variant Draft Simple

CWE版本: 4.18

更新日期: 2025-09-09

弱点描述

The product uses the getlogin() function in a multithreaded context, potentially causing it to return incorrect values.

扩展描述

The getlogin() function returns a pointer to a string that contains the name of the user associated with the calling process. The function is not reentrant, meaning that if it is called from another process, the contents are not locked out and the value of the string can be changed by another process. This makes it very risky to use because the username can be changed by other processes, so the results of the function cannot be trusted.

常见后果

影响范围: Integrity Access Control Other

技术影响: Modify Application Data Bypass Protection Mechanism Other

潜在缓解措施

阶段: Architecture and Design

描述: Using names for security purposes is not advised. Names are easy to forge and can have overlapping user IDs, potentially causing confusion or impersonation.

阶段: Implementation

描述: Use getlogin_r() instead, which is reentrant, meaning that other processes are locked out from changing the username.

引入模式

阶段 说明
Implementation -

适用平台

编程语言
C (Undetermined) C++ (Undetermined)

分类映射

分类名称 条目ID 条目名称 映射适配度
7 Pernicious Kingdoms - Often Misused: Authentication -
Software Fault Patterns SFP3 Use of an improper API -
关键信息

CWE ID: CWE-558

抽象级别: Variant

结构: Simple

状态: Draft

相关弱点