Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

false positive for CRLF_INJECTION_LOGS #425

Closed
geoHeil opened this issue Jul 24, 2018 · 1 comment
Closed

false positive for CRLF_INJECTION_LOGS #425

geoHeil opened this issue Jul 24, 2018 · 1 comment

Comments

@geoHeil
Copy link

geoHeil commented Jul 24, 2018

Even when setting

log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss.SSS} %marker [%t] %-5level %logger{36} - %encode{replace(%msg){'[\r\n]', ''}}%n

in log4j properties section as recommended by

Solution:
You can manually sanitize each parameter.

log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function.

%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging has an implementation for Logback and Log4j.

and additionally replacing the values:

logger.warn(s"some text ${someInteger.toString.replaceAll("[\r\n]", "")} more text")

I still keep getting CRLF_INJECTION_LOGS errors.

Note, I am using scala.

@h3xstream
Copy link
Member

h3xstream commented Jul 30, 2018

Once, you have configured LogBack, you need to disable the rule "CRLF_INJECTION_LOGS".
At the moment, Find Security Bugs is not able to analyze other files than the class files (spotbugs/spotbugs#186).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants