<dd id="sga4y"><optgroup id="sga4y"></optgroup></dd>
<nav id="sga4y"><code id="sga4y"></code></nav>
  • <optgroup id="sga4y"></optgroup>

    Cross-Site Request Forgery

    ABSTRACT

    HTTP 請求必須包含用戶特有的機密,以防止攻擊者發出未經授權的請求。

    EXPLANATION

    跨站點偽裝請求 (CSRF) 漏洞會在以下情況下發生:
    1. Web 應用程序使用會話 cookie。

    2. 應用程序未驗證請求是否經過用戶同意便處理 HTTP 請求。



    如果該請求未包含證明其來源的 nonce,則處理該請求的代碼將易受到 CSRF 攻擊(除非它并未更改應用程序的狀態)。這意味著使用會話 cookie 的 Web 應用程序必須采取特殊的預防措施,確保攻擊者無法誘騙用戶提交偽請求。假設有一個 Web 應用程序,它允許管理員修改現有帳戶,如下所示:


    public class UserProfileController :Controller
    {
    public ViewResult SubmitUpdate()
    {
    // Get the user's existing profile data
    ProfileData profile = GetUserProfile();

    // Update the user object
    profile.EmailAddress = Request.Form["email"];
    profile.Password = Request.Form["password"];
    SaveUserProfile(profile);

    ViewData["message"] = "Your profile was updated.";
    return View();
    }
    }


    上述方法缺少 [ValidateAntiForgeryToken] 屬性。攻擊者可以設置一個惡意網站,將以下頁面發送給用戶。


    <body onload="document.getElementById('fm1').submit()">
    <form id="fm1" action="http://yoursite/UserProfile/SubmitUpdate" method="post">
    <input name="email" value="hacker@somewhere.evil" />
    <input name="password" value="powned" />
    </form>
    </body>


    如果這個存在漏洞的網站的管理員在具有活動會話時訪問了包含此代碼的網頁,則她會在毫不知情的情況下為攻擊者更新她自己的帳戶。這就是 CSRF 攻擊。正是由于該應用程序無法確定請求的來源,才有可能受到 CSRF 攻擊。任何請求都有可能是用戶選定的合法操作,也有可能是攻擊者設置的偽操作。攻擊者無法查看偽請求生成的網頁,因此,這種攻擊技術僅適用于篡改應用程序狀態的請求。

    大多數 Web 瀏覽器會隨每次請求發送一個名為 referer 的 HTTP 頭文件。referer 頭文件應該包含參考頁面的 URL,但攻擊者可以偽造,因此無法利用 referer 頭文件確定請求的來源。

    CSRF 在 2007 OWASP Top 10 排行榜上名列第 5。

    REFERENCES

    [1] OWASP 2007 OWASP Top 10

    [2] Standards Mapping - OWASP Top 10 2007 - (OWASP 2007) A5 Cross Site Request Forgery (CSRF)

    [3] Standards Mapping - OWASP Top 10 2010 - (OWASP 2010) A5 Cross-Site Request Forgery (CSRF)

    [4] Standards Mapping - Security Technical Implementation Guide Version 3 - (STIG 3) APP3585 CAT II

    [5] Standards Mapping - Security Technical Implementation Guide Version 3.4 - (STIG 3.4) APP3585 CAT II

    [6] Standards Mapping - Web Application Security Consortium 24 + 2 - (WASC 24 + 2) Cross-Site Request Forgery

    [7] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 352

    [8] A. Klein Divide and Conquer:HTTP Response Splitting, Web Cache Poisoning Attacks, and Related Topics

    [9] Standards Mapping - SANS Top 25 2009 - (SANS 2009) Insecure Interaction - CWE ID 352

    [10] Standards Mapping - SANS Top 25 2010 - (SANS 2010) Insecure Interaction - CWE ID 352

    [11] Standards Mapping - SANS Top 25 2011 - (SANS Top 25 2011) Insecure Interaction - CWE ID 352

    [12] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 - (PCI 1.2) Requirement 6.5.5

    [13] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 - (PCI 2.0) Requirement 6.5.9


    Copyright 2013 Fortify Software - All rights reserved.
    (Generated from version 2013.1.1.0008 of the Fortify Secure Coding Rulepacks)
    desc.structural.dotnet.csrf

    97av