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

    XPath Injection

    ABSTRACT

    利用用戶輸入構建動態的 XPath 查詢使攻擊者可借機修改語句的含義。

    EXPLANATION

    XPath injection 會在以下情況中出現:

    1. 數據從一個不可信賴的數據源進入程序。



    2. 數據用于動態構造一個 XPath 查詢。



    例 1:下列代碼可動態地構建并執行一個 XPath 查詢,為指定的帳戶 ID 檢索電子郵件地址。由于該帳戶 ID 是從 HTTP 請求中讀取的,因此不可信賴。


    ...
    <?php
    load('articles.xml');
     
    $xpath = new DOMXPath($doc);
    $emailAddrs = $xpath->query(&quot;/accounts/account[acctID='&quot; .$_GET[&quot;test1&quot;] .&quot;']/email/text()&quot;);
    //$arts = $xpath->evaluate(&quot;/accounts/account[acctID='&quot; .$_GET[&quot;test1&quot;] .&quot;']/email/text()&quot;)
     
    foreach ($emailAddrs as $email)
    {
    echo $email->nodeValue."";
    }
    ?>
    ...


    在正常情況下(例如搜索屬于帳號 1 的電子郵件地址),此代碼所執行的查詢如下所示:

    /accounts/account[acctID='1']/email/text()

    但是,由于這個查詢語句是動態構建的,由一個不變的基查詢字符串和一個用戶輸入字符串連接而成,因而僅當 acctID 不含單引號字符時,查詢才會正確執行。如果攻擊者為 acctID 輸入字符串 1' or '1' = '1,則該查詢會變成:

    /accounts/account[acctID='1' or '1' = '1']/email/text()

    添加條件 1' or '1' = '1 會使 where 從句永遠評估為 true,因此,該查詢在邏輯上等同于更簡單的查詢:

    //email/text()

    這種查詢簡化會使攻擊者繞過以下要求:查詢只能返回經過驗證的用戶所擁有的條目;現在,查詢可返回文檔中存儲的所有電子郵件地址,不論它們的指定所有者是是誰。

    REFERENCES

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

    [2] Standards Mapping - OWASP Top 10 2007 - (OWASP 2007) A2 Injection Flaws

    [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 643

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

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

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

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

    [11] Standards Mapping - Web Application Security Consortium 24 + 2 - (WASC 24 + 2) XPath Injection


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

    97av