【问题标题】:Nessus vulnerability scanner reports my classic ASP site still exposed to XSS attackNessus 漏洞扫描器报告我的经典 ASP 站点仍然受到 XSS 攻击
【发布时间】:2014-08-02 19:12:38
【问题描述】:

我正在寻找我网站上报告的一个漏洞,该漏洞主要是用带有 VBscript 的经典 ASP 编写的。我认为我所做的修复应该已经足够了,但是“重新扫描”仍然在端口 80/tcp 上显示“中等风险”项目:

51972 - CGI Generic Cross-Site Scripting (Parameters Names)

这是来自此报告项目的 sn-p:

    -------- request --------
GET /stagedmds/marketshare/ParmsV2.asp?<<<<<<<<<<foo"bar'314>>>>>=1 HTTP/1.1 
Host: www.mortgagedataweb.com 
Accept-Charset: iso-8859-1,utf-8;q=0.9,*;q=0.1 
Accept-Language: en 
Connection: Close 
Cookie: ASPSESSIONIDSQQQBDTB=MCJAMHCACGEHCNCCGDDPOEAI; ASPSESSIONIDQSSQDCTB=JAFAABIAONBOMMAMJILMMLGL; ASPSESSIONIDQSQQBDTB=IBJAMHCAIGIGCEKMBNPOMCPN 
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0) 
Pragma: no-cache 
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*
------------------------

-------- output --------

<button type="button" onclick=
"location.href='/stagedmds/marketshare/ParmsV2.asp?<<<<<<<<<<foo"bar'314
>>>>>=1&Doc=Y';"
ONMOUSEOVER="this.className = 'over';"
ONMOUSEOUT="this.className = '';"
------------------------

/stagedmds/marketshare/ParmsV2.ASP?<<<<<<<<<<foo"bar'314>>>>>=1

当我查看此服务器端脚本页面时,我注意到我对参数的检索并没有“清理”输入,如下所示:

implied_Menu = UCase(Request.QueryString("Menu"))

因此,我将其更改如下:

implied_Menu = getUserInput(UCase(Request.QueryString("Menu"))) 

新添加的函数应该“清理”parm 值,如下所示:

Function getUserInput(input)    
    dim newString
    newString=input  
    newString    = replace(newString,"--","")
    newString    = replace(newString,";","")          
    newString    = replace(newString,chr(34),"'") 
    newString    = replace(newString,"'","") 
    newString    = replace(newString,"=","=") 
    newString    = replace(newString,"(","[") 
    newString    = replace(newString,")","]")
    newString = replace(newString,"'","''")
    newString = replace(newString,"<","[")
    newString = replace(newString,">","]")  
    newString = replace(newString,"/*","/") 
    newString = replace(newString,"*/","/")
    getUserInput = newString
End Function 

这个名为implicit_Menu 的变量永远不会以任何方式输出到页面。它仅使用某些案例逻辑进行评估以设置其他变量,如本例所示:

    Select Case implied_Menu
        Case "C_ST" 
            implied_PromptType = ByCounty
            implied_DataSubset = iConventional
            implied_ReportName = Conventional

我看不出还有什么可以在这里做的。我读过Protect from cross-site scripting attacks?,其中一些漏洞扫描程序无法识别我采取的措施。

扫描器在看到从查询字符串中检索时是否总是会报告 XSS 违规?

【问题讨论】:

    标签: security asp-classic xss nessus


    【解决方案1】:

    在我看来,问题在于当您的代码生成此按钮时,您如何生成 location.href 的值:

    <button type="button" onclick=
    "location.href='/stagedmds/marketshare/ParmsV2.asp?<<<<<<<<<<foo"bar'314
    >>>>>=1&Doc=Y';"
    ONMOUSEOVER="this.className = 'over';"
    ONMOUSEOUT="this.className = '';"
    

    我猜您正在使用 ServerVariable 或 Request.QueryString 生成 URL。您需要对此进行更改,使其仅包含您允许的参数。

    如果您发布这部分代码,它可能会有所帮助。

    【讨论】:

    • 谢谢。你是对的。我发现了一堆分散的地方,我必须添加对 Server.URLPathEncode 的调用,传递通常是连接的字符串,例如 Request.ServerVariables("SCRIPT_NAME")& "?" & Request.ServerVariables("QUERY_STRING")
    【解决方案2】:

    @John's answer 是正确的 - 这是由于您的按钮的 onclick 中使用的文本。

    查看OWASP XSS (Cross Site Scripting) Prevention Cheat Sheet,了解如何防止 XSS 的提示。

    RULE #3 - JavaScript Escape Before Inserting Untrusted Data into JavaScript Data Values 在这里适用:-

    除了字母数字字符,使用 \xHH 格式转义所有小于 256 的字符,以防止将数据值切换到脚本上下文或其他属性中。

    所以在这种情况下你的价值

    /stagedmds/marketshare/ParmsV2.asp?<<<<<<<<<<foo"bar'314>>>>>=1&Doc=Y
    

    应该编码为

    \x2fstagedmds\x2fmarketshare\x2fParmsV2\x2easp\x3f\x3c\x3c\x3c\x3c\x3c\x3c\x3c\x3c\x3c\x3cfoo\x22bar\x27314\x3e\x3e\x3e\x3e\x3e\x3d1\x26Doc\x3dY
    

    【讨论】:

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