Use of getlogin() in Multithreaded Application |
Weakness ID: 558 (Weakness Variant) | Status: Draft |
Description Summary
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.
Example 1
The following code relies on getlogin() to determine whether or not a user is trusted. It is easily subverted.
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. |
Nature | Type | ID | Name | View(s) this relationship pertains to![]() |
---|---|---|---|---|
ChildOf | ![]() | 227 | Failure to Fulfill API Contract ('API Abuse') | Seven Pernicious Kingdoms (primary)700 |
ChildOf | ![]() | 557 | Concurrency Issues | Development Concepts (primary)699 |
ChildOf | ![]() | 663 | Use of a Non-reentrant Function in an Unsynchronized Context | Research Concepts (primary)1000 |
Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
---|---|---|---|
7 Pernicious Kingdoms | Often Misused: Authentication |
Submissions | ||||
---|---|---|---|---|
Submission Date | Submitter | Organization | Source | |
Anonymous Tool Vendor (under NDA) | Externally Mined | |||
Modifications | ||||
Modification Date | Modifier | Organization | Source | |
2008-07-01 | Eric Dalci | Cigital | External | |
updated Time of Introduction | ||||
2008-09-08 | CWE Content Team | MITRE | Internal | |
updated Applicable Platforms, Description, Relationships, Taxonomy Mappings | ||||
2009-05-27 | CWE Content Team | MITRE | Internal | |
updated Demonstrative Examples, Taxonomy Mappings | ||||
Previous Entry Names | ||||
Change Date | Previous Entry Name | |||
2008-04-11 | Misused Authentication: getlogin() | |||