User-provided inputs must be sanitized before they are logged. An attacker can use unsanitized input to break a log's integrity, forge log entries, or bypass log monitors.
1// Noncompliant: Unsanitized user data is being written to the logs
2fun noncompliant(request: ServletRequest) {
3 val xValue = request.getParameter("x")
4 logger.info("Value is: {}", xValue)
5}
1// Compliant: There is no user input being written to the logs.
2fun compliant(input: String) {
3 logger.info("Value is: {}", input)
4}