CodeCheck Documentation
CodeCheck Documentation - SEI CERT C

Standard: SEI CERT C

This standard provides rules for secure coding in the C programming language.

The rules and recommendations in this standard are a work in progress and reflect the current thinking of the secure coding community. As rules and recommendations mature, they are published in report or book form as official releases. These releases are issued as dictated by the needs and interests of the secure software development community.

The list of rules and recommendations in this tool were last updated on 2023/05/23.

Check IDCheck NameSupportedSeverity
ARR30-CDo not form or use out-of-bounds pointers or array subscriptsNoHigh
ARR32-CEnsure size arguments for variable length arrays are in a valid rangeNoHigh
ARR36-CDo not subtract or compare two pointers that do not refer to the same arrayYesMedium
ARR37-CDo not add or subtract an integer to a pointer to a non-array objectYesMedium
ARR38-CGuarantee that library functions do not form invalid pointersNoHigh
ARR39-CDo not add or subtract a scaled integer to a pointerYesHigh
CON30-CClean up thread-specific storageYesMedium
CON31-CDo not destroy a mutex while it is lockedYesMedium
CON32-CPrevent data races when accessing bit-fields from multiple threadsNoMedium
CON33-CAvoid race conditions when using library functionsYesMedium
CON34-CDeclare objects shared between threads with appropriate storage durationsNoMedium
CON35-CAvoid deadlock by locking in a predefined orderNoLow
CON36-CWrap functions that can spuriously wake up in a loopYesLow
CON37-CDo not call signal() in a multithreaded programYesLow
CON38-CPreserve thread safety and liveness when using condition variablesYesLow
CON39-CDo not join or detach a thread that was previously joined or detachedYesLow
CON40-CDo not refer to an atomic variable twice in an expressionYesMedium
CON41-CWrap functions that can fail spuriously in a loopYesLow
CON43-CDo not allow data races in multithreaded codeNoMedium
DCL30-C-ADeclare objects with appropriate storage durations - assigning addressesYesHigh
DCL30-C-BDeclare objects with appropriate storage durations - returning addressesYesHigh
DCL31-CDeclare identifiers before using themYesLow
DCL36-CDo not declare an identifier with conflicting linkage classificationsYesMedium
DCL37-CDo not declare or define a reserved identifierYesLow
DCL38-CUse the correct syntax when declaring a flexible array memberYesLow
DCL39-CAvoid information leakage when passing a structure across a trust boundaryNoLow
DCL40-CDo not create incompatible declarations of the same function or object YesLow
DCL41-CDo not declare variables inside a switch statement before the first case labelYesMedium
ENV30-CDo not modify the object referenced by the return value of certain functionsYesLow
ENV31-CDo not rely on an environment pointer following an operation that may invalidate itYesLow
ENV32-CAll exit handlers must return normallyYesMedium
ENV33-CDo not call system()YesHigh
ENV34-CDo not store pointers returned by certain functionsYesLow
ERR30-CTake care when reading errnoYesMedium
ERR32-CDo not rely on indeterminate values of errnoNoLow
ERR33-CDetect and handle standard library errorsYesHigh
ERR34-CDetect errors when converting a string to a numberYesMedium
EXP30-C-ADo not depend on the order of evaluation for side effects - callsYesMedium
EXP30-C-BDo not depend on the order of evaluation for side effects - otherYesMedium
EXP32-CDo not access a volatile object through a nonvolatile referenceYesLow
EXP33-CDo not read uninitialized memoryYesHigh
EXP34-CDo not dereference null pointersYesHigh
EXP35-CDo not modify objects with temporary lifetimeNoLow
EXP36-CDo not cast pointers into more strictly aligned pointer typesYesLow
EXP37-CCall functions with the correct number and type of argumentsYesMedium
EXP39-CDo not access a variable through a pointer of an incompatible typeYesMedium
EXP40-CDo not modify constant objectsNoLow
EXP42-CDo not compare padding dataYesMedium
EXP43-CAvoid undefined behavior when using restrict-qualified pointersNoMedium
EXP44-CDo not rely on side effects in operands to sizeof, _Alignof, or _GenericYesLow
EXP45-CDo not perform assignments in selection statementsYesLow
EXP46-CDo not use a bitwise operator with a Boolean-like operandYesLow
EXP47-CDo not call va_arg with an argument of the incorrect typeYesMedium
FIO30-CExclude user input from format stringsYesHigh
FIO32-CDo not perform operations on devices that are only appropriate for filesNoMedium
FIO34-CDistinguish between characters read from a file and EOF or WEOFNoHigh
FIO37-CDo not assume that fgets() or fgetws() returns a nonempty string when successfulYesHigh
FIO38-CDo not copy a FILE objectYesLow
FIO39-CDo not alternately input and output from a stream without an intervening flush or positioning callYesLow
FIO40-CReset strings on fgets() or fgetws() failureYesLow
FIO41-CDo not call getc(), putc(), getwc(), or putwc() with a stream argument that has side effectsYesLow
FIO42-CClose files when they are no longer neededYesMedium
FIO44-COnly use values for fsetpos() that are returned from fgetpos()YesMedium
FIO45-CAvoid TOCTOU race conditions while accessing filesYesHigh
FIO46-CDo not access a closed fileYesMedium
FIO47-CUse valid format stringsYesHigh
FLP30-CDo not use floating-point variables as loop countersYesLow
FLP32-CPrevent or detect domain and range errors in math functionsNoMedium
FLP34-CEnsure that floating-point conversions are within range of the new typeNoLow
FLP36-CPreserve precision when converting integral values to floating-point typeNoLow
FLP37-CDo not use object representations to compare floating-point valuesYesLow
INT30-CEnsure that unsigned integer operations do not wrapYesHigh
INT31-CEnsure that unsigned integer operations do not result in lost or misinterpreted dataYesHigh
INT32-CEnsure that operations on signed integers do not result in overflowNoHigh
INT33-CDivision by ZeroYesLow
INT34-CDo not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operandNoLow
INT35-CUse correct integer precisionsNoLow
INT36-CConverting a pointer to integer or integer to pointerYesLow
MEM30-CDo not access freed memoryNoHigh
MEM31-CFree dynamically allocated memory when no longer neededYesMedium
MEM33-CAllocate and copy structures containing a flexible array member dynamicallyYesLow
MEM34-COnly free memory allocated dynamicallyYesHigh
MEM35-CAllocate sufficient memory for an objectYesHigh
MEM36-CDo not modify the alignment of objects by calling realloc()NoLow
MSC30-CDo not use the rand() function for generating pseudorandom numbersYesMedium
MSC32-CProperly seed pseudorandom number generatorsYesMedium
MSC33-CDo not pass invalid data to the asctime() functionYesHigh
MSC37-CEnsure that control never reaches the end of a non-void functionYesHigh
MSC38-CDo not treat a predefined identifier as an object if it might only be implemented as a macroYesLow
MSC39-CDo not call va_arg() on a va_list that has an indeterminate valueYesLow
MSC40-CDo not violate constraintsYesLow
MSC41-CNever hard code sensitive informationNoHigh
POS30-CUse the readlink() function properlyYesHigh
POS34-CDo not call putenv() with a pointer to an automatic variable as the argumentYesHigh
POS35-CAvoid race conditions while checking for the existence of a symbolic linkYesHigh
POS36-CObserve correct revocation order while relinquishing privilegesYesHigh
POS37-CEnsure that privilege relinquishment is successfulYesHigh
POS38-CBeware of race conditions when using fork and file descriptorsYesMedium
POS39-CUse the correct byte ordering when transferring data between systemsYesMedium
POS44-CDo not use signals to terminate threadsYesLow
POS47-CDo not use threads that can be canceled asynchronouslyYesMedium
POS48-CDo not unlock or destroy another POSIX thread's mutexYesMedium
POS49-CWhen data must be accessed by multiple threads, provide a mutex and guarantee no adjacent data is also accessedNoMedium
POS50-CDeclare objects shared between POSIX threads with appropriate storage durationsYesMedium
POS51-CAvoid deadlock with POSIX threads by locking in predefined orderYesLow
POS52-CDo not perform operations that can block while holding a POSIX lockYesLow
POS53-CDo not use more than one mutex for concurrent waiting operations on a condition variableYesMedium
POS54-CDetect and handle POSIX library errorsYesHigh
PRE30-CDo not create a universal character name through concatenationYesLow
PRE31-CAvoid side effects in arguments to unsafe macrosYesLow
PRE32-CDo not use preprocessor directives in invocations of function-like macrosYesLow
SIG30-CCall only asynchronous-safe functions within signal handlersYesHigh
SIG31-CDo not access shared objects in signal handlersYesHigh
SIG34-CDo not call signal() from within interruptible signal handlersYesLow
SIG35-CDo not return from a computational exception signal handlerNoLow
STR30-CDo not attempt to modify string literalsYesLow
STR31-CGuarantee that storage for strings has sufficient space for character data and the null terminatorYesHigh
STR32-CNull-terminated strings passed to library functionsYesHigh
STR34-CCast characters to unsigned char before converting to larger integer sizesNoMedium
STR37-CArguments to character-handling functions must be representable as an unsigned charYesLow
STR38-CDo not confuse narrow and wide character strings and functionsYesHigh
WIN30-CProperly pair allocation and deallocation functionsYesLow