How to fix Veracode CWE 117 (Improper Output Neutralization for Logs)

后端 未结 5 1642
遥遥无期
遥遥无期 2021-02-02 01:21

There is an Spring global @ExceptionHandler(Exception.class) method which logs exception like that:

@ExceptionHandler(Exception.class)
void handleEx         


        
5条回答
  •  名媛妹妹
    2021-02-02 01:33

    In order to avoid Veracode CWE 117 vulnerability I have used a custom logger class which uses HtmlUtils.htmlEscape() function to mitigate the vulnerablity. Recommended solution to this problem by Veracode is to use ESAPI loggers but if you dont want to add an extra dependency to your project this should work fine. https://github.com/divyashree11/VeracodeFixesJava/blob/master/spring-annotation-logs-demo/src/main/java/com/spring/demo/util/CustomLogger.java

提交回复
热议问题