如果使用未驗證的用戶輸入來指定頁面中包含的文件路徑,會使攻擊者能夠在服務器中注入惡意代碼或查看敏感文件。
在以下情況中會發生 Unauthorized Include 漏洞:
1. 數據從一個不可信賴的數據源(最常見的是一個 Web 請求)進入 Web 應用程序。
2. 數據是字符串的一部分,該字符串指明了 <cfinclude> 標簽的 template 屬性。
示例:以下代碼利用來自 Web 表單的輸入構造了一條路徑,通過這條路徑可以找到用來設定用戶主頁格式的特殊文件。由此可以看出,程序員沒有考慮到攻擊者可能會提供惡意文件名,如 "../../users/wileyh/malicious",從而導致該應用程序執行攻擊者主目錄下文件的惡意內容。
<cfinclude template =
"C:\\custom\\templates\\#Form.username#.cfm">
<cfinclude> 標簽所包含的文件,他們就可能使應用程序在當前頁上包含服務器 file system 中幾乎所有文件的內容。這至少會對兩個方面產生重大影響。如果攻擊者可以在服務器的 file system 上某個位置(如用戶的主目錄或一個通用的上傳目錄)進行寫入,那么他們可能會使應用程序在頁面中包含一個惡意文件,并將由服務器執行該文件。即使得不到服務器 file system 的寫權限,攻擊者通常也能通過指定服務器上某個文件的路徑,對敏感或私人信息進行訪問。
[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, APP3600 CAT II
[5] Standards Mapping - Security Technical Implementation Guide Version 3.4 - (STIG 3.4) APP3510 CAT I, APP3600 CAT II
[6] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 94
[7] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 - (PCI 1.2) Requirement 6.3.1.1, Requirement 6.5.2, Requirement 6.5.3
[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 - SANS Top 25 2009 - (SANS 2009) Risky Resource Management - CWE ID 094
[11] Standards Mapping - FIPS200 - (FISMA) SI