zoukankan      html  css  js  c++  java
  • 修复UNIGUI安全扫描出现“启用了不安全的 HTTP 方法”

      使用unigui编译的应用安全扫描时有“启用了不安全的 HTTP 方法”漏洞,这个漏洞的影响是:可能会在 Web 服务器上上载、修改或删除 Web 页面、脚本和文件。

    如果使用 Tomcat修复很简单,直接修改 的 web.xml 就可以,但UNIGUI编译的程序不能按照Tomcat方法修复。

     <security-constraint>
     <web-resource-collection>
     <web-resource-name>fortune</web-resource-name>
        <url-pattern>/*</url-pattern>
        <http-method>PUT</http-method>
        <http-method>DELETE</http-method>
        <http-method>HEAD</http-method>
        <http-method>OPTIONS</http-method>
        <http-method>TRACE</http-method>
     </web-resource-collection>
     <auth-constraint></auth-constraint>
     </security-constraint>

            需然用AWS能扫出这漏洞,经验证后发现unigui本身就没实现HEAD、DELETEPUT、TRACE和OPTION这些功能,但默认返回200,安全工具根据返回状态判断命令执行成功。知道原因后解决起来很简单,当执行HEAD、DELETE、PUT、TRACE和OPTION等命令时直接返回403就可以。在ServerModule单元HTTPCommand添加下面的代码。

    procedure TUniServerModule.UniGUIServerModuleHTTPCommand(
      ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
      var Handled: Boolean);
    begin
      if (ARequestInfo.CommandType =hcHEAD) or
       (ARequestInfo.CommandType =hcPUT) or
       (ARequestInfo.CommandType =hcTRACE) or
       (ARequestInfo.CommandType =hcOPTION) or
       (ARequestInfo.CommandType =hcDELETE) then
      begin
          Handled := false;
          AResponseInfo.ResponseNo:=403;
          AResponseInfo.CloseConnection:=true;
          AResponseInfo.CharSet := 'UTF-8';
          AResponseInfo.ContentType := 'Text';
          AResponseInfo.ContentText := '本软件不支持HEAD,DELETE,PUT,TRACE,OPTION等命令!';
      end;
    end;

  • 相关阅读:
    Codeforces 1045C Hyperspace Highways (看题解) 圆方树
    Codeforces 316E3 线段树 + 斐波那切数列 (看题解)
    Codeforces 803G Periodic RMQ Problem 线段树
    Codeforces 420D Cup Trick 平衡树
    Codeforces 295E Yaroslav and Points 线段树
    Codeforces 196E Opening Portals MST (看题解)
    Codeforces 653F Paper task SA
    Codeforces 542A Place Your Ad Here
    python基础 异常与返回
    mongodb 删除
  • 原文地址:https://www.cnblogs.com/qiufeng2014/p/13969263.html
Copyright © 2011-2022 走看看