<pre id="vvttv"><mark id="vvttv"><progress id="vvttv"></progress></mark></pre>
    <pre id="vvttv"></pre>

      <p id="vvttv"></p>

          <p id="vvttv"></p>

                <p id="vvttv"></p>

                <pre id="vvttv"><cite id="vvttv"><progress id="vvttv"></progress></cite></pre>

                  <output id="vvttv"><dfn id="vvttv"><th id="vvttv"></th></dfn></output>

                    <p id="vvttv"></p>

                    Unsafe Native Invoke

                    ABSTRACT

                    Platform Invocation Service 使用不當會導致受管應用程序很容易受到其他語言的安全漏洞攻擊。

                    EXPLANATION

                    當受管應用程序使用 P/Invoke 調用以其他編程語言編寫的本機(非受管)代碼時,會發生 Unsafe Native Invoke 漏洞。



                    例如:以下 C# 代碼定義了一個名為 Echo 的類。這個類聲明了一個本地方法(下文定義),使用 C 語言將控制臺上輸入的命令回顯給用戶。


                    class Echo
                    {
                    [DllImport("mylib.dll")]
                    internal static extern void RunEcho();

                    static void main(String[] args)
                    {
                    RunEcho();
                    }
                    }


                    以下 C 語言代碼定義了在 Echo 類中實現的本地方法:


                    #include <stdio.h>

                    void __stdcall RunEcho()
                    {
                    char* buf = (char*) malloc(64 * sizeof(char));
                    gets(buf);
                    printf(buf);
                    }


                    因為 Echo 是在受管代碼中實現的,所以看上去似乎可以避免諸如 buffer overflow 漏洞之類的內存問題。雖然受管環境在確保內存操作安全方面確實能起到很好的作用,但是這種保護沒有擴大到使用 P/Invoke 訪問的本機代碼中發生的漏洞。盡管有受管運行時環境提供的內存保護機制,但是這個例子中的本機代碼仍然很容易受到 buffer overflow 的攻擊,因為它在沒有執行任何輸入檢查的情況下就使用了 gets()。同樣,雖然 buf 得到分配但并未被釋放,因此也是一個 memory leak。

                    通過檢查本地方法實現的源代碼,可以輕松地發現上述例子中存在的漏洞。根據是否有源代碼和項目構建方式,這種方式可能在某些情況下不可行或無法實現,但是多數情況下還是可行的。然而,這種能夠在受管和本地環境間共享對象的能力會進一步加大潛在的風險。在受管代碼中數據處理不當時,可能會導致本地代碼出現意想不到的漏洞,同樣本地代碼中的不安全操作會破壞受管代碼的數據結構。

                    通過受管應用程序訪問的本地代碼中出現的漏洞,通常與由本地語言編寫的應用程序中存在的漏洞是一樣的。這種攻擊面臨的唯一挑戰是:攻擊者需要確定受管應用程序是否使用了本地代碼執行某些特定的操作。可以用多種方法實現上述目的,包括識別那些通常用本地代碼實現的某些特定行為,或者利用受管應用程序中 system information leak 的漏洞(表明系統使用了 P/Invoke) 。

                    REFERENCES

                    [1] Standards Mapping - OWASP Top 10 2004 - (OWASP 2004) A1 Unvalidated Input

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

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

                    [4] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 111

                    [5] How to:Call Native DLLs from Managed Code Using PInvoke

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

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

                    [8] 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.dataflow.dotnet.unsafe_native_invoke

                      <pre id="vvttv"><mark id="vvttv"><progress id="vvttv"></progress></mark></pre>
                      <pre id="vvttv"></pre>

                        <p id="vvttv"></p>

                            <p id="vvttv"></p>

                                  <p id="vvttv"></p>

                                  <pre id="vvttv"><cite id="vvttv"><progress id="vvttv"></progress></cite></pre>

                                    <output id="vvttv"><dfn id="vvttv"><th id="vvttv"></th></dfn></output>

                                      <p id="vvttv"></p>

                                      这里只有精品视频