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

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

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

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

            Often Misused: File Upload

            ABSTRACT

            允許用戶上傳文件可能會讓攻擊者注入危險內容或惡意代碼,并在服務器上運行。

            EXPLANATION

            無論編寫程序所用的語言是什么,最具破壞性的攻擊通常都會涉及執行遠程代碼,攻擊者借此可在程序上下文中成功執行惡意代碼。如果允許攻擊者向某個可通過 Web 訪問的目錄上傳文件,并能夠將這些文件傳遞給 PHP 解釋器,他們就能促使這些文件中包含的惡意代碼在服務器上執行。

            例 1:以下代碼會處理上傳的文件,并將它們移到 Web 根目錄下的一個目錄中。攻擊者可以將惡意的 PHP 源文件上傳到該程序中,并隨后從服務器中請求這些文件,這會促使 PHP 解析器執行這些文件。


            <?php
            $udir = 'upload/'; // Relative path under Web root
            $ufile = $udir . basename($_FILES['userfile']['name']);
            if (move_uploaded_file($_FILES['userfile']['tmp_name'], $ufile)) {
            echo "Valid upload received\n";
            } else {
            echo "Invalid upload rejected\n";
            } ?>


            即使程序將上傳的文件存儲在一個無法通過 Web 訪問的目錄中,攻擊者仍然有可能通過向服務器環境引入惡意內容來發動其他攻擊。如果程序容易出現 path manipulation、command injection 或 remote include 漏洞,那么攻擊者就可能上傳帶惡意內容的文件,并利用另一種漏洞促使程序讀取或執行該文件。

            REFERENCES

            [1] Standards Mapping - OWASP Top 10 2010 - (OWASP 2010) A1 Injection

            [2] Standards Mapping - OWASP Top 10 2007 - (OWASP 2007) A3 Malicious File Execution

            [3] Standards Mapping - OWASP Top 10 2004 - (OWASP 2004) A6 Injection Flaws

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

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

            [6] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 434

            [7] Standards Mapping - SANS Top 25 2010 - (SANS 2010) Insecure Interaction - CWE ID 434

            [8] Standards Mapping - SANS Top 25 2011 - (SANS Top 25 2011) Insecure Interaction - CWE ID 434

            [9] M. Achour et al. PHP Manual

            [10] PHP Security Consortium PhpSecInfo Test Information

            [11] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 - (PCI 1.2) Requirement 6.3.1.1, Requirement 6.5.3

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

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

            [14] Alla Bezroutchko Secure file upload in PHP web applications

            [15] Standards Mapping - FIPS200 - (FISMA) SI


            Copyright 2013 Fortify Software - All rights reserved.
            (Generated from version 2013.1.1.0008 of the Fortify Secure Coding Rulepacks)
            desc.semantic.php.often_misused_file_upload

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

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

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

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

                      亚洲欧美在线