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


HARDCODED.KEY : Hardcoded Crypto Key

Summary

A function that should have a cryptographic key passed in a particular argument position has been passed a hardcoded value.

Properties

Class Name Hardcoded Crypto Key
Significance security
Mnemonic HARDCODED.KEY
Categories
CWE CWE:318 Cleartext Storage of Sensitive Information in Executable
  CWE:321 Use of Hard-coded Cryptographic Key
  CWE:540 Inclusion of Sensitive Information in Source Code
  CWE:547 Use of Hard-coded, Security-relevant Constants
  CWE:798 Use of Hard-coded Credentials
CERT-C CERT-C:MSC18-C Be careful while handling sensitive data, such as passwords, in program code
  CERT-C:MSC41-C Never hard code sensitive information
OWASP-2017 OWASP-2017:A5 Broken access control
  OWASP-2017:A6 Security misconfiguration
OWASP-2021 OWASP-2021:A1 Broken access control
  OWASP-2021:A2 Cryptographic failures
  OWASP-2021:A4 Insecure design
  OWASP-2021:A5 Security misconfiguration
  OWASP-2021:A7 Identification and authorization failures
OWASP-2025 OWASP-2025:A01 Broken Access Control
  OWASP-2025:A02 Security Misconfiguration
  OWASP-2025:A04 Cryptographic Failures
  OWASP-2025:A06 Insecure Design
Availability Available for C and C++.
Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Hardcoded Crypto Key"

Example

#include <crypt.h>

void hardcoded_key(const char *p, const char *q){
    crypt("password", q); /* 'Hardcoded Crypto Key' warning issued here
                           * ('Use of crypt' warning also issued)
                           */
    crypt(p, q);                       /* ok: not hardcoded */
                          /* ('Use of crypt' warning issued here) */
}

Notes

This class is defined using HARDCODED_ARGS_* rules in the general template configuration file, and covers many common procedures that take cryptographic key parameters. For a full list, see the "Factory Settings" in the documentation for HARDCODED_ARGS_*.

Relevant Configuration File Parameters

This class is implemented using a HARDCODED_ARGS_* rule set in the general template configuration file.

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

 

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