Leakage of sensitive information in logger message

Overview

  • Rule ID: java_lang_logger

  • Applicable Languages: Java

  • Weakness ID: CWE-532

Description

The exposure of sensitive information in logger messages can jeopardize user privacy and security. This vulnerability arises when confidential data, such as personally identifiable information (PII), is included in log messages, potentially granting unauthorized access to this information.

Remediation Guidelines

  • Avoid including sensitive data in logger messages to prevent unintentional exposure of personal or confidential information.

    logger.info(user.email) // unsafe
    
  • Instead, use non-sensitive, unique identifiers like UUIDs to reference users or entities in log messages. This approach preserves privacy while ensuring effective logging.

    logger.info(user.uuid)
    
  • Also, log static messages that do not contain dynamic variables or attributes to minimize the risk of inadvertently logging sensitive information.

    logger.info("user signed in")

References

Configuration

To omit this rule during a scan, and to provide you with continuous 24/7 code-level scanning, you can employ our SAST TOOL

Last updated