CWE-778: Insufficient Logging

Description:
When a security-critical event occurs, the product either does not record the event or omits important details about the event when logging it.

Extended Description:
When security-critical events are not logged properly, such as a failed login attempt, this can make malicious behavior more difficult to detect and may hinder forensic analysis after an attack succeeds. 
	  As organizations adopt cloud storage resources, these technologies often require configuration changes to enable detailed logging information, since detailed logging can incur additional costs. This could lead to telemetry gaps in critical audit logs. For example, in Azure, the default value for logging is disabled.

Affected languages: Not Language-Specific
Affected technologies: Cloud Computing, Not Technology-Specific
Parent weaknesses: CWE-223

Consequences:
  - Non-Repudiation: Hide Activities

Detection methods:
  - Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without havin

Mitigations:
  - [Architecture and Design] Use a centralized logging mechanism that supports multiple levels of detail.
  - [Implementation] Ensure that all security-related successes and failures can be logged. When storing data in the cloud (e.g., AWS S3 buckets, Azure blobs, Google Cloud Storage, etc.), use the provider's controls to enable and capture detailed logging information.
  - [Operation] Be sure to set the level of logging appropriately in a production environment. Sufficient data should be logged to enable system administrators to detect attacks, diagnose errors, and recover from attacks. At the same time, logging too much data (CWE-779) can cause the same problems, including unexp
  - [Operation] To enable storage logging using Azure's Portal, navigate to the name of the Storage Account, locate Monitoring (CLASSIC) section, and select Diagnostic settings (classic). For each of the various properties (blob, file, table, queue), ensure the status is properly set for the desired logging data. I

Demonstrative examples:
The example below shows a configuration for the service security audit feature in the Windows Communication Foundation (WCF).
The previous configuration file has effectively disabled the recording of security-critical events, which would force the administrator to look to other sources during debug or recovery efforts.
<system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="NewBehavior"> <serviceSecurityAudit auditLogLocation="Default" suppressAuditFailure="false" serviceAuthorizationAuditLevel="None" messageAuthenticationAuditLevel="None" /> ... 
                         
                      </system.serviceModel>
<system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="NewBehavior"> <serviceSecurityAudit auditLogLocation="Default" suppressAuditFailure="false" s

In the following Java example the code attempts to authenticate the user. If the login fails a retry is made. Proper restrictions on the number of login attempts are of course part of the retry functionality. Unfortunately, the failed login is not recorded and there would be no record of an adversary attempting to brute force the program.
It is recommended to log the failed login action. Note that unneutralized usernames should not be part of the log message, and passwords should never be part of the log message.
if LoginUser(){
                      // Login successful 
		     RunProgram(); 
                  } else {
                      // Login unsuccessful 
		     LoginRetry(); 
                  }
if LoginUser(){
                      // Login successful 
		     log.warn("Login by u

Real-world examples:
  - CVE-2008-4315: server does not log failed authentication attempts, making it easier for attackers to perform brute force password guessing without being detected
  - CVE-2008-1203: admin interface does not log failed authentication attempts, making it easier for attackers to perform brute force password guessing without being detected
  - CVE-2007-3730: default configuration for POP server does not log source IP or username for login attempts
  - CVE-2007-1225: proxy does not log requests without "http://" in the URL, allowing web surfers to access restricted web content without detection
  - CVE-2003-1566: web server does not log requests for a non-standard request type