VariantDraft

CWE-558Use of getlogin() in Multithreaded Application

Category: other

Description

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.

Common consequences· 1

  • Integrity / Access Control / Other — Modify Application Data, Bypass Protection Mechanism, Other

Potential mitigations· 2

  • [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.

References

  1. https://cwe.mitre.org/data/definitions/558.html

Related by meaning· 6

Nearest entities by semantic similarity across the cs-graph corpus.

CWE
Use of a Non-reentrant Function in a Concurrent Context
CWE
Incorrect Synchronization
CWE
Unsynchronized Access to Shared Data in a Multithreaded Context
CWE
Incorrect Use of Privileged APIs
CWE
Improper Synchronization
CWE
Use of Singleton Pattern Without Synchronization in a Multithreaded Context
Sourced from MITRE CWE 4.20. Curated for EU compliance use cases by Adam Lundqvist, Founder at SQUR.