JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.0p0 Hot Tips | CONFIDENTIAL | CodeSecure Inc |
ファイル名をチェックする関数 (check) を実行し、その後その同じファイル名を使用するための関数 (use) を実行したとき、ファイルシステムの競合条件の脆弱性の可能性があります。 ソースコード内では、'check' と 'use' の間で実際のファイルが変更された場合でも、この二つのファイルが同じものと見なしています。 例えば、オリジナルファイルへのリンクを機密情報を含んだファイルへのリンクへ入れ替えてしまうような攻撃が考えられます。
| クラス名 | File System Race Condition | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | ファイルシステム競合状態 | ||||||||||||||||||||||||||||||||||||
| クラス分類 | セキュリティ (security) | ||||||||||||||||||||||||||||||||||||
| ニーモニック | IO.RACE | ||||||||||||||||||||||||||||||||||||
| カテゴリー |
|
||||||||||||||||||||||||||||||||||||
| 対応言語 | C および C++ で利用可能です。 |
||||||||||||||||||||||||||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル
(configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="File System Race Condition" |
CodeSonar ships with library models that allow it to a large number of functions that take a file name or directory name argument. If a file/directory name is passed to one of these functions (the check) and later the same name is passed to another of these functions (the use), a warning will be issued.
If you have created a custom library model for some function f() in terms of one of these existing models, calls to f() will also be capable of triggering File System Race Condition warnings.
| Functions that can trigger warnings include... | |
|---|---|
| gcc Builtins | __builtin_execl(), __builtin_execv(), |
| libc | chmod(), open(), stat() |
| Win32 | CanShareFolderW(), PathMakeUniqueName(), freopen_s() |
TOCTTOU(time of check to time of use)脆弱性は、攻撃者に権限のないファイルシステムへのアクセスを許します。 例えば以下のような open 前の unlink は攻撃に関して脆弱です。
#include <fcntl.h>
#include <unistd.h>
void tocttou(const void *secret, size_t secret_size){
int fdesc;
/* choose a filename for recording sensitive data */
char *fname = "myfile.txt";
/* unlink to ensure that fname isn't already in use by someone else */
unlink(fname);
/* DANGER */
/* open the file and write the data to it */
fdesc = open(fname, O_CREAT|O_RDWR); /* 'File System Race Condition' warning issued here */
if (fdesc < 0){return;}
(void) write(fdesc, secret, secret_size);
(void) close(fdesc);
}
の箇所は、攻撃者が myfile.txt ファイルを作成することが可能で、ファイルの所有権を獲得し中身へのアクセスが可能になります。
さらに問題となるのは、 myfile.txt を /etc/passwd にリンクすることにより、システムパスワードを壊すことが可能な点です。
多くの TOCTTOU 脆弱性は、ソフトウェアが決められた名前をつけたファイルを攻撃者が使用することで起こります。 これはファイル名ではなくファイルディスクリプタやファイルストリームを参照することで避けることが可能です。
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。