在Java web项目中显示BLOB对象以避免持久的跨站点脚本?
如何在Java web项目中显示存储为在Java web项目中显示BLOB对象以避免持久的跨站点脚本?,java,database,security,blob,xss,Java,Database,Security,Blob,Xss,如何在Java web项目中显示存储为BLOB对象的数据并避免持久的跨站点脚本漏洞 ViewDeliveredReportsPage.java中的方法respond()将未经验证的数据发送到第2775行的web浏览器,这可能导致浏览器执行恶意代码 2773 byte[] barray = new byte[byteLen]; 2774 barray = blob.getBytes(1,byteLen); 2775 httpResponse.getOutputStream().write(barr
BLOB
对象的数据并避免持久的跨站点脚本漏洞
ViewDeliveredReportsPage.java
中的方法respond()
将未经验证的数据发送到第2775行的web浏览器,这可能导致浏览器执行恶意代码
2773 byte[] barray = new byte[byteLen];
2774 barray = blob.getBytes(1,byteLen);
2775 httpResponse.getOutputStream().write(barray);
2776 } catch (SQLException e) {
2777 logger.error("ERROR onSelectionChanged
在传递要显示的数据之前,需要对其进行转义。OWASP ESAPI库似乎是一个不错的选择。你可以在这里找到它:
这张备忘单值得一读:
byte[] barray = new byte[byteLen];
barray = blob.getBytes(1,byteLen);
//You'll probably have to convert this to a string first - I am not too
//familiar with Java, but the principal is the same.
String output = ESAPI.encoder().encodeForHTML(barray);
httpResponse.getOutputStream().write(output);
} catch (SQLException e) {
logger.error("ERROR onSelectionChanged