C and C++ Binaries


MISC.TIMEBOMB : タイムボムの可能性

要旨

システム生成された時間が、システム生成されていない (したがって、汚染されている若しくは怪しいと疑われる)時間と比較されています。 このような比較は、潜在的にタイムボム(特定の絶対時間か相対時間でのみ 実行される振る舞いのこと)を引き起こす可能性があります。

プロパティ

クラス名 Potential Timebomb
日本語クラス名 タイムボムの可能性
クラス分類 スタイル (style)
ニーモニック MISC.TIMEBOMB
カテゴリー
MisraC2023 MisraC2023:21.10 The Standard Library time and date functions shall not be used
Misra2012 Misra2012:21.10 The Standard Library time and date functions shall not be used
Misra2004 Misra2004:20.12 The time handling functions of library <time.h> shall not be used
AUTOSARC++14 AUTOSARC++14:M18-0-4 The time handling functions of library <ctime> shall not be used.
MisraC++2008 MisraC++2008:18-0-4 The time handling functions of library <ctime> shall not be used.
CWE CWE:511 Logic/Time Bomb
対応言語 C および C++ で利用可能です。
有効/無効設定 Checks for this warning class are disabled by default, and it tracks 'time' taint which is also disabled by default. To enable the checks, make the following changes to the project configuration file.

#include <time.h>

void misc_timebomb(void){
    time_t deadline = 1893456000;
    time_t now = time(NULL);

    if (now > time(NULL)){               /* ok: time value compared against another time value */
        return;
    }

    if (now < deadline){ /* 'Potential Timebomb' warning issued: time value compared against non-time value */
        return;
    }

    /* An inside attacker could put malicious code here:
     * it would only be executed once the deadline was past. */
}

Functions that Generate System Times

CodeSonar ships with library models that allow it to recognize a functions such as libc mktime() and Win32 GetTickCount() that produce system time values by returning such values, writing them through an argument pointer, or both.

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 treated as producing system time values under the same circumstances.

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。