Skip to main content

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

VariantDraft

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

View on MITRE
Back to CWE Lookup

Extended Description

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.

Technical Details

Structure
Simple

Applicable To

Languages
CC++
Platforms

Frequently Asked Questions

What is CWE-558: Use of getlogin() in Multithreaded Application?+

CWE-558: Use of getlogin() in Multithreaded Application is a Common Weakness Enumeration (CWE) entry maintained by MITRE. 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.

What are the security consequences of Use of getlogin() in Multithreaded Application?+

If exploited, CWE-558 (Use of getlogin() in Multithreaded Application) it can compromise Integrity, Access Control and Other, leading to outcomes such as Modify Application Data, Bypass Protection Mechanism and Other.

How do you prevent or mitigate Use of getlogin() in Multithreaded Application?+

Recommended mitigations for CWE-558 include: Using names for security purposes is not advised. Names are easy to forge and can have overlapping user IDs, potentially causing confusion or impersonation. Use getlogin_r() instead, which is reentrant, meaning that other processes are locked out from changing the username.

Which programming languages are affected by Use of getlogin() in Multithreaded Application?+

CWE-558 commonly affects C and C++. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.

What is the difference between a CWE and a CVE?+

A CWE (Common Weakness Enumeration) like CWE-558 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.

Learn More