界: Input Validation and Representation

输入验证与表示问题是由元字符、交替编码和数字表示引起的。安全问题源于信任输入。这些问题包括:“Buffer Overflows”、“Cross-Site Scripting”攻击、“SQL Injection”等其他问题。

Same-Origin Method Execution

Abstract
应用程序会将用户可控制的参数显示为由浏览器执行的 JavaScript 回调函数,该浏览器可能允许攻击者在同一端点域中的任何页面上执行任意 JavaScript 函数。
Explanation
应用程序会将受攻击者控制的参数用作浏览器将执行的 JavaScript 函数的名称。 攻击者可能会创建一个恶意站点,该站点先在同一应用程序的域中构建目标页面,然后引用漏洞页面,以便在该目标页面上执行任意 JavaScript 函数。 尽管存在一些重要的漏洞限制,但此攻击的效果类似于 Cross-Site Scripting。 如果允许将字母数字和句点字符用作回调名称,攻击者将能够引用页面元素并进行交互。

示例 1: 以下代码将构造回调函数名称可由用户控制的 JSONP 响应。


@ControllerAdvice
public class JsonpAdvice extends AbstractJsonpResponseBodyAdvice {
public JsonpAdvice() {
super("callback");
}
}


对于诸如 GET /api/latest.json?callback=myCallbackFunction 等请求,控制器方法将生成如下响应:


HTTP/1.1 200 Ok
Content-Type: application/json; charset=utf-8
Date: Tue, 12 Dec 2017 16:16:04 GMT
Server: nginx/1.12.1
Content-Length: 225
Connection: Close

myCallbackFunction({<json>})


攻击者可以使用 JavaScript Script 标记从 JSONP 端点加载该响应,从而转变为执行 myCallbackFunction 函数。 攻击者可以使用其他回调名称导航 DOM 并与其交互。 例如,opener.document.body.someElemnt.firstChild.nextElementSibling.submit 可用于查找目标页面中的表格并进行提交。
References
[1] Ben Hayak Same Origin Method Execution (SOME)
[2] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001310
[3] Standards Mapping - NIST Special Publication 800-53 Revision 4 SI-10 Information Input Validation (P1)
[4] Standards Mapping - NIST Special Publication 800-53 Revision 5 SI-10 Information Input Validation
[5] Standards Mapping - OWASP Mobile 2024 M4 Insufficient Input/Output Validation
[6] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection, Control Objective 5.4 - Authentication and Access Control
[7] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective 5.4 - Authentication and Access Control, Control Objective B.3.1 - Terminal Software Attack Mitigation, Control Objective B.3.1.1 - Terminal Software Attack Mitigation
[8] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective 5.4 - Authentication and Access Control, 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
[9] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002530 CAT II
[10] Standards Mapping - Security Technical Implementation Guide Version 6.1 APSC-DV-002530 CAT II
desc.semantic.java.same_origin_method_execution
Abstract
应用程序会将用户可控制的参数显示为由浏览器执行的 JavaScript 回调函数,该浏览器可能允许攻击者在同一端点域中的任何页面上执行任意 JavaScript 函数。
Explanation
应用程序会将受攻击者控制的参数用作浏览器将执行的 JavaScript 函数的名称。 攻击者可能会创建一个恶意站点,该站点先在同一应用程序的域中构建目标页面,然后引用漏洞页面,以便在该目标页面上执行任意 JavaScript 函数。 尽管存在一些重要的漏洞限制,但此攻击的效果类似于 Cross-Site Scripting。 如果允许将字母数字和句点字符用作回调名称,攻击者将能够引用页面元素并进行交互。

示例 1: 以下代码将构造回调函数名称可由用户控制的 JSONP 响应。


def myJSONPService(callback: String) = Action {
val json = getJSONToBeReturned()
Ok(Jsonp(callback, json))
}


对于诸如 GET /api/latest.json?callback=myCallbackFunction 等请求,Example 1 中所述的控制器方法将生成如下响应:


HTTP/1.1 200 Ok
Content-Type: application/json; charset=utf-8
Date: Tue, 12 Dec 2017 16:16:04 GMT
Server: nginx/1.12.1
Content-Length: 225
Connection: Close

myCallbackFunction({<json>})


攻击者可以使用 JavaScript Script 标记从 JSONP 端点加载该响应,从而转变为执行 myCallbackFunction 函数。 攻击者可以使用其他回调名称导航 DOM 并与其交互。 例如,opener.document.body.someElemnt.firstChild.nextElementSibling.submit 可用于查找目标页面中的表格并进行提交。
References
[1] Ben Hayak Same Origin Method Execution (SOME)
[2] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001310
[3] Standards Mapping - NIST Special Publication 800-53 Revision 4 SI-10 Information Input Validation (P1)
[4] Standards Mapping - NIST Special Publication 800-53 Revision 5 SI-10 Information Input Validation
[5] Standards Mapping - OWASP Mobile 2024 M4 Insufficient Input/Output Validation
[6] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection, Control Objective 5.4 - Authentication and Access Control
[7] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective 5.4 - Authentication and Access Control, Control Objective B.3.1 - Terminal Software Attack Mitigation, Control Objective B.3.1.1 - Terminal Software Attack Mitigation
[8] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective 5.4 - Authentication and Access Control, 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
[9] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002530 CAT II
[10] Standards Mapping - Security Technical Implementation Guide Version 6.1 APSC-DV-002530 CAT II
desc.dataflow.scala.same_origin_method_execution