<span id="7ztzv"></span>
<sub id="7ztzv"></sub>

<span id="7ztzv"></span><form id="7ztzv"></form>

<span id="7ztzv"></span>

        <address id="7ztzv"></address>

            Race Condition: Singleton Member Field

            ABSTRACT

            Servlet 成員字段可能允許一個用戶查看其他用戶的數據。

            EXPLANATION

            許多 Servlet 開發人員都不了解 Servlet 為單例模式。Servlet 只有一個實例,并通過使用和重復使用該單個實例來處理需要由不同線程同時處理的多個請求。

            這種誤解的共同后果是,開發者使用 Servlet 成員字段的這種方式會導致某個用戶可能在無意中看到其他用戶的數據。換言之,即把用戶數據存儲在 Servlet 成員字段中會引發數據訪問的 race condition。

            例 1:以下 Servlet 把請求參數值存儲在成員字段中,然后將參數值返回給響應輸出流。


            public class GuestBook extends HttpServlet {

            String name;

            protected void doPost (HttpServletRequest req,
            HttpServletResponse res) {
            name = req.getParameter("name");
            ...
            out.println(name + ", thanks for visiting!");
            }
            }


            當該代碼在單一用戶環境中正常運行時,如果有兩個用戶幾乎同時訪問 Servlet,可能會導致這兩個請求以如下方式處理線程的插入:

            線程 1: assign "Dick" to name
            線程 2: assign "Jane" to name
            線程 1: print "Jane, thanks for visiting!"
            線程 2: print "Jane, thanks for visiting!"

            因此會向第一個用戶顯示第二個用戶的用戶名。

            REFERENCES

            [1] Standards Mapping - OWASP Top 10 2007 - (OWASP 2007) A6 Information Leakage and Improper Error Handling

            [2] Standards Mapping - Security Technical Implementation Guide Version 3 - (STIG 3) APP3630.1 CAT II

            [3] Standards Mapping - Security Technical Implementation Guide Version 3.4 - (STIG 3.4) APP3630.1 CAT II

            [4] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 362, CWE ID 488

            [5] Standards Mapping - SANS Top 25 2009 - (SANS 2009) Insecure Interaction - CWE ID 362

            [6] Standards Mapping - SANS Top 25 2010 - (SANS 2010) Insecure Interaction - CWE ID 362

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

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

            [9] The Java Servlet Specification Sun Microsystems


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

            <span id="7ztzv"></span>
            <sub id="7ztzv"></sub>

            <span id="7ztzv"></span><form id="7ztzv"></form>

            <span id="7ztzv"></span>

                  <address id="7ztzv"></address>

                      亚洲欧美在线