CWE一覧に戻る
CWE-558

マルチスレッド・アプリケーションでの getlogin() の使用

Use of getlogin() in Multithreaded Application
脆弱性 レビュー中
JA

この製品は、マルチスレッド環境で getlogin() 関数を使用するため、不正な値を返す可能性があります。

getlogin()関数は、呼び出したプロセスに関連付けられたユーザー名を含む文字列へのポインタを返す。この関数はリエントラントではありません。つまり、他のプロセスから呼び出された場合、その内容はロックアウトされず、文字列の値は他のプロセスによって変更される可能性があります。このため、ユーザー名が他のプロセスによって変更される可能性があり、関数の結果が信頼できないため、使用するのは非常に危険です。

EN

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.

Scope: Integrity, Access Control, Other / Impact: Modify Application Data; Bypass Protection Mechanism; Other
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.
MITRE公式ページ — CWE-558