java - Can't resolve Log Forging Fortify issue -


i having trouble fixing log forging issue in fortify. issue, "writes unvalidated user input log", being raised both of logging calls in getlongfromtimestamp() method.

public long getlongfromtimestamp(final string value) {     logger.info("getlongfromtimestamp(" + cleanlogstring(value) + ")");      long longval = 0;     date tempdate = null;     try {                     tempdate = new simpledateformat(format_yyyymmddhhmmss, locale.us).parse(value);     } catch (parseexception e) {         logger.warn("failed convert date: " + cleanlogstring(value) + " exception: " + cleanlogstring(e.getmessage()));         throw new exception(e);     }      if (tempdate != null) {         longval = tempdate.gettime();     }     return longval; }  private cleanlogstring(string logstring) {     string clean = logstring.replaceall("[^a-za-z0-9]", "");      if(!logstring.equals(clean)) {         clean += " (cleaned)";     }      return clean; } 

the cleanlogstring() method has fixed other log forging fortify issues in project, has no effect on 2 above.

any appreciated!

i know have run situations complexity of application stop malicious input working intended; fortify not consider secure. bet running same thing.

you stripping useful characters out of log message, see happens if encoding on output prior writing log.

http://www.jtmelton.com/2010/09/21/preventing-log-forging-in-java/

// ensure no crlf injection logs forging records string clean = message.replace( '\n', '_' ).replace( '\r', '_' ); if ( esapi.securityconfiguration().getlogencodingrequired() ) {     clean = esapi.encoder().encodeforhtml(message);     if (!message.equals(clean)) {         clean += " (encoded)";     } } 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -