【问题标题】:Display BLOB object in Java web project avoiding persistent cross site scripting?在 Java Web 项目中显示 BLOB 对象,避免持久的跨站点脚本?
【发布时间】:2015-12-18 04:19:05
【问题描述】:

如何在 Java Web 项目中显示存储为 BLOB 对象的数据并避免持久的跨站点脚本漏洞?

ViewDeliveredReportsPage.java 中的方法respond() 将未经验证的数据发送到line 2775 上的网络浏览器,这可能导致浏览器执行恶意代码。

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

【问题讨论】:

    标签: java database security blob xss


    【解决方案1】:

    在传递要显示的数据之前,需要对其进行转义。 OWASP ESAPI 库似乎是一个不错的选择。你可以在这里找到它:https://code.google.com/p/owasp-esapi-java/downloads/list

    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
    

    这份备忘单值得一读:https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多