Possible CLRF injection detected

Description

CRLF (Carriage Return Line Feed) injection vulnerability occurs when an attacker is able to insert a sequence of line termination characters into a log message. This can lead to forged log entries, compromising the integrity of log files.

Remediations

  • Do strip any carriage return and line feed characters from user input data before logging it. This prevents attackers from injecting malicious CRLF sequences.
    logger.info(userInput.replaceAll("[\r\n]+", ""));

References

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=java_lang_crlf_injection

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

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