Missing output neutralization for logs

Description

Logging untrusted and unsanitized input could lead to log injection vulnerabilities.

Remediations

❌ Do not log unsanitized external input directly

✅ Use printf methods with %q format for logging external input

  dangerousInput := os.Args[0]

logger.Printf("Args: %q", dangerousInput)

✅ Use manual method to escape external strings before logging

  dangerousInput := os.Args[0]
sanitizedInput := strconv.Quote(dangerousInput)

logger.Print(sanitizedInput)

Associated CWE

OWASP Top 10

Configuration

To skip this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --skip-rule=go_lang_log_output_neutralization

To run only this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --only-rule=go_lang_log_output_neutralization