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.2p0 CONFIDENTIAL CodeSecure Inc
C and C++
Binaries


MISC.TIMEBOMB : Potential Timebomb

Summary

A system-generated time is compared to a value that is not a system-generated time (and thus may be tainted or otherwise suspicious). Such comparisons can potentially lead to time bombs: behavior that is intended to execute only at a specific relative or absolute time.

Properties

Class Name Potential Timebomb
Significance style
Mnemonic MISC.TIMEBOMB
Categories
MisraC2025 MisraC2025:21.10 The Standard Library time and date functions shall not be used
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.
MisraC++2023 MisraC++2023:0.3.2 A function call shall not violate the function's preconditions
CWE CWE:511 Logic/Time Bomb
OWASP-2021 OWASP-2021:A8 Software and data integrity failures
OWASP-2025 OWASP-2025:A08 Software or Data Integrity Failures
Availability Available for C and C++.
Enabling 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.
  • Add the following rules.
    DISABLED_TAINT_KINDS =  
    WARNING_FILTER += allow class="Potential Timebomb"
    
    and,
  • For any taint kinds that you wish to disable (since the rule you just added enables all kinds), add a DISABLED_TAINT_KINDS+= rule after DISABLED_TAINT_KINDS="".

Example

#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.

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.

 

To report problems with this documentation, please visit https://support.codesecure.com/.