界: Time and State

分布式计算是关于时间和状态的。也就是说,为了让多个组件相互通信,必须共享状态,所有这些都需要时间。

大多数程序员都会将其工作拟人化。他们会让一个控制线程以同样的方式(他们必须自己完成工作时采取的方式)执行整个程序。然而,现代计算机不同任务之间切换得非常快,在多核、多 CPU 或分布式系统中,两个事件可能完全同时发生。程序员预期的程序执行过程与实际情况之间存在差距,即存在缺陷。这些缺陷与线程、流程、时间和信息之间的意外交互有关。这些交互是通过共享状态发生的:信号量、变量、文件系统,以及总而言之,可以存储信息的任何内容。

19 个项目已找到
弱点
Abstract
开发人员正在使用 Windows.Storage.ApplicationData 类的 RoamingFolderRoamingSettings 属性。
Explanation
RoamingFolderRoamingSettings 属性可从漫游应用程序数据存储器中获取一个容器,然后可以使用此容器在两台以上的设备之间共享数据。如果写入和读取漫游应用程序数据存储器中存储的对象,开发人员会增加遭受危害的风险。通过此漫游应用程序数据存储器共享这些对象的数据、应用程序和系统的机密性、完整性和可用性都将受到影响。

如果预先没有实施必要的技术控制,开发人员应避免使用此功能。
References
[1] ApplicationData.RoamingFolder | roamingFolder property
[2] ApplicationData.RoamingSettings | roamingSettings property
[3] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1
[4] Standards Mapping - CIS Microsoft Azure Foundations Benchmark complete
[5] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 5
[6] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 5
[7] Standards Mapping - CIS Google Kubernetes Engine Benchmark integrity
[8] Standards Mapping - CIS Kubernetes Benchmark partial
[9] Standards Mapping - Common Weakness Enumeration CWE ID 362, CWE ID 367
[10] Standards Mapping - Common Weakness Enumeration Top 25 2022 [22] CWE ID 362
[11] Standards Mapping - Common Weakness Enumeration Top 25 2023 [21] CWE ID 362
[12] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-003178
[13] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[14] Standards Mapping - OWASP Top 10 2021 A04 Insecure Design
[15] Standards Mapping - OWASP Application Security Verification Standard 4.0 1.11.2 Business Logic Architectural Requirements (L2 L3), 1.11.3 Business Logic Architectural Requirements (L3), 11.1.6 Business Logic Security Requirements (L2 L3)
[16] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[17] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[21] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[22] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[23] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[24] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 362
[25] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 362
[26] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3630.1 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3630.1 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3630.1 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3630.1 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3630.1 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3630.1 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3630.1 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001995 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001995 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001995 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001995 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001995 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001995 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001995 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001995 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001995 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001995 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001995 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001995 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001995 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001995 CAT II
desc.structural.dotnet.race_condition_roaming_data_access
Abstract
为多重信号安装相同的信号处理函数的话,当在短时间内连续收到不同的信号时,会导致 race condition。
Explanation
当安装作为信号处理函数的函数属于非可重入函数时,信号处理就会发生 race condition。非可重入函数会保留一些内部状态,或调用其他同样如此的函数。当安装同一函数去处理多重信号时,很有可能发生这种 race condition。

信号处理 race condition 很有可能在以下情况中出现:

1. 程序为多重信号仅安装一个信号处理函数。

2. 在短时间内,信号处理函数收到两种不同的信号,导致该信号处理函数中出现 race condition。

示例:以下代码为两个不同的信号仅安装了一个简单的、非折返信号处理函数。如果攻击者使信号在适当的时间内一起发送,信号处理函数就会遭受 double free 漏洞威胁。针对同一个值两次调用 free(),会导致 buffer overflow。当程序使用同一参数两次调用 free() 时,程序中的内存管理数据结构会遭到破坏。这种破坏会导致程序崩溃。有时在某些情况下,还会导致两次调用 malloc() 延迟,而返回相同的指针。如果 malloc() 两次都返回同一个值,稍候程序便会允许攻击者控制整个已经写入双倍分配内存的数据,从而使程序更加容易受到 buffer overflow 的攻击。


void sh(int dummy) {
...
free(global2);
free(global1);
...
}

int main(int argc,char* argv[]) {
...
signal(SIGHUP,sh);
signal(SIGTERM,sh);
...
}
References
[1] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1
[2] Standards Mapping - CIS Microsoft Azure Foundations Benchmark partial
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 4
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[6] Standards Mapping - Common Weakness Enumeration CWE ID 362, CWE ID 364
[7] Standards Mapping - Common Weakness Enumeration Top 25 2022 [22] CWE ID 362
[8] Standards Mapping - Common Weakness Enumeration Top 25 2023 [21] CWE ID 362
[9] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-003178
[10] Standards Mapping - General Data Protection Regulation (GDPR) Indirect Access to Sensitive Data
[11] Standards Mapping - Motor Industry Software Reliability Association (MISRA) C Guidelines 2012 Rule 21.5
[12] Standards Mapping - Motor Industry Software Reliability Association (MISRA) C++ Guidelines 2008 Rule 18-7-1
[13] Standards Mapping - OWASP Top 10 2021 A04 Insecure Design
[14] Standards Mapping - OWASP Application Security Verification Standard 4.0 1.11.2 Business Logic Architectural Requirements (L2 L3)
[15] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[16] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[17] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[20] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[21] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[22] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[23] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 362
[24] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 362
[25] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3630.1 CAT II
[26] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3630.1 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3630.1 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3630.1 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3630.1 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3630.1 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3630.1 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001995 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001995 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001995 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001995 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001995 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001995 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001995 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001995 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001995 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001995 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001995 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001995 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001995 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001995 CAT II
desc.structural.cpp.race_condition_signal_handling
Abstract
Servlet 成员字段可能允许一个用户查看其他用户的数据。
Explanation
许多 Servlet 开发人员都不了解 Servlet 为单例模式。Servlet 只有一个实例,并通过使用和重复使用该单个实例来处理需要由不同线程同时处理的多个请求。

这种误解的共同后果是,开发者使用 Servlet 成员字段的这种方式会导致某个用户可能在无意中看到其他用户的数据。换言之,即把用户数据存储在 Servlet 成员字段中会引发数据访问的 race condition。

例 1:以下 Servlet 把请求参数值存储在成员字段中,然后将参数值返回给响应输出流。


public class GuestBook extends HttpServlet {

String name;

protected void doPost (HttpServletRequest req, HttpServletResponse res) {
name = req.getParameter("name");
...
out.println(name + ", thanks for visiting!");
}
}


当该代码在单一用户环境中正常运行时,如果有两个用户几乎同时访问 Servlet,可能会导致这两个请求以如下方式处理线程的插入:

线程 1: 将“Dick”分配给 name
线程 Jane”分配给 name
线程 1: print“Jane, thanks for visiting!
线程 2: print“Jane, thanks for visiting!

因此会向第一个用户显示第二个用户的用户名。
References
[1] The Java Servlet Specification Sun Microsystems
[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 5
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark confidentiality
[6] Standards Mapping - CIS Kubernetes Benchmark partial
[7] Standards Mapping - Common Weakness Enumeration CWE ID 362, CWE ID 488
[8] Standards Mapping - Common Weakness Enumeration Top 25 2022 [22] CWE ID 362
[9] Standards Mapping - Common Weakness Enumeration Top 25 2023 [21] CWE ID 362
[10] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001090, CCI-003178
[11] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[12] Standards Mapping - NIST Special Publication 800-53 Revision 4 SC-4 Information in Shared Resources (P1)
[13] Standards Mapping - NIST Special Publication 800-53 Revision 5 SC-4 Information in Shared System Resources
[14] Standards Mapping - OWASP Top 10 2007 A6 Information Leakage and Improper Error Handling
[15] Standards Mapping - OWASP Top 10 2021 A04 Insecure Design
[16] Standards Mapping - OWASP Application Security Verification Standard 4.0 1.11.2 Business Logic Architectural Requirements (L2 L3)
[17] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 6.5.6
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 6.5.5
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[21] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[22] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[23] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[24] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[25] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[26] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[27] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 362
[28] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 362
[29] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3630.1 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3630.1 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3630.1 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3630.1 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3630.1 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3630.1 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3630.1 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[49] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[50] Standards Mapping - Web Application Security Consortium Version 2.00 Information Leakage (WASC-13)
[51] Standards Mapping - Web Application Security Consortium 24 + 2 Information Leakage
desc.structural.java.singleton_member_field_race_condition
Abstract
存储在静态字段中的数据库连接会被不同的线程共享。
Explanation
对于与事务相关联的资源对象(比如数据库连接),一次只能与一个事务相关联。出于这个原因,一个连接不应该被多个线程共享,并且不应该存储在静态字段中。要获取更多详细信息,请参见 J2EE 规范中的第 4.2.3 节。

例 1:

public class ConnectionManager {

private static Connection conn = initDbConn();
...
}
References
[1] Java 2 Platform Enterprise Edition Specification, v1.4 Sun Microsystems
[2] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 3.1
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark confidentiality
[6] Standards Mapping - CIS Kubernetes Benchmark partial
[7] Standards Mapping - Common Weakness Enumeration CWE ID 362, CWE ID 567
[8] Standards Mapping - Common Weakness Enumeration Top 25 2022 [22] CWE ID 362
[9] Standards Mapping - Common Weakness Enumeration Top 25 2023 [21] CWE ID 362
[10] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001090, CCI-003178
[11] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[12] Standards Mapping - NIST Special Publication 800-53 Revision 4 SC-4 Information in Shared Resources (P1)
[13] Standards Mapping - NIST Special Publication 800-53 Revision 5 SC-4 Information in Shared System Resources
[14] Standards Mapping - OWASP Top 10 2021 A04 Insecure Design
[15] Standards Mapping - OWASP Application Security Verification Standard 4.0 1.11.2 Business Logic Architectural Requirements (L2 L3)
[16] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[17] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[21] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[22] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[23] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[24] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 362
[25] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 362
[26] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3630.1 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3630.1 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3630.1 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3630.1 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3630.1 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3630.1 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3630.1 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
desc.structural.java.race.dbconn
Abstract
在未释放当前会话标识符的情况下验证用户会给攻击者窃取验证会话的机会。
Explanation
Session Fixation 漏洞会在以下情况中出现:

1.当 Web 应用程序验证某一用户时,没有首先释放当前会话,而是继续使用已经与该用户关联的会话。
2.攻击者能够夺取已知的用户会话标识符,因此,一旦该用户进行验证,攻击者便可以访问经过验证的会话。

在通常情况下,攻击者会利用 Session Fixation 漏洞在 Web 应用程序中创建一个新会话,并且记录与之关联的会话标识符。然后,攻击者会设法使受害者在服务器中的验证失败,从而通过当前会话来访问用户帐号。

Spring Security 等部分框架会在创建新会话时自动释放当前会话。若不采取此行为,应用程序将易遭受此类攻击。

示例 1:以下示例显示受 Spring Security 保护的应用程序的代码段,该应用程序中的会话固定保护已禁用。


<http auto-config="true">
...
<session-management session-fixation-protection="none"/>
</http>


即便是易受攻击的应用程序,此处描述的特定攻击是否成功仍取决于诸多对攻击者有利的因素:访问未受监控的公用终端;能够维持当前已遭受攻击的会话;受害者有兴趣通过公用终端登录易受攻击的应用程序。在多数情况下,只要肯花时间,前面两个因素是可以实现的。只要站点比较受欢迎,那么寻找一个既使用公用终端又有兴趣登录易受攻击的应用程序的受害者,也是可以实现的。站点越不受欢迎,感兴趣的受害者使用公用终端的几率就越低,上述攻击成功的可能性也就越小。

攻击者利用 Session Fixation 漏洞所面临的最大挑战是,诱导受害者使用攻击者已知的会话标识符向易受攻击的应用程序进行身份验证。在Example 1 中,攻击者使用直接明显的方法并不高明,对于攻击不太出名的网站并不适用。然而,千万不要麻痹大意,攻击者有许多手段可以帮助他们避免上述攻击的局限性。攻击者最常用的技术包括:利用目标站点中的 Cross-Site Scripting 或者 HTTP Response Splitting 漏洞 [1]。攻击者诱使受害者向易受攻击的应用程序提交恶意请求,应用程序将相应的 JavaScript 或者其他代码返回到受害者的浏览器,借助于这种方式,攻击者便可以创建一个 Cookie,使受害者重新使用已受攻击者控制的会话标识符。

值得注意的是,Cookie 常常会与某个已知 URL 所关联的顶级域绑定到一起。如果多个应用程序位于同一顶级域(如 bank.example.comrecipes.example.com),其中一个应用程序存在漏洞,则攻击者可以通过此漏洞设置一个 Cookie,并在其中包含一个已被修改的会话标识符,且该会话标识符可以在与 example.com [2] 域中所有应用程序的交互中使用。

其他攻击手段还包括 DNS Poisoning 和其他基于网络的攻击形式,攻击者通过重定向对有效站点的请求,诱使用户访问恶意站点。基于网络的攻击方式通常包括:现身于攻击对象的网络中或是控制网络中的目标主机。虽然通过远程的方式进行此种攻击要更难一些,但也不应当忽视。安全性较差的会话管理机制(例如在 Apache Tomcat 中默认实现),可以将通常存储在 Cookie 中的会话标识符也指定给 URL。这样,攻击者只要通过电子邮件发送一个恶意的 URL,就可以诱使受害者使用已被修改的会话标识符。
desc.config.java.session_fixation
Abstract
在未释放当前会话标识符的情况下验证用户会给攻击者窃取验证会话的机会。
Explanation
Session Fixation 漏洞会在以下情况中出现:

1.当 Web 应用程序验证某一用户时,没有首先释放当前会话,而是继续使用已经与该用户关联的会话。

2.攻击者能够夺取已知的用户会话标识符,因此,一旦该用户进行验证,攻击者便可以访问经过验证的会话。

在通常情况下,攻击者会利用 Session Fixation 漏洞在 Web 应用程序中创建一个新会话,并且记录与之关联的会话标识符。然后,攻击者会设法使受害者在服务器中的验证失败,从而通过当前会话来访问用户帐号。

示例 1:以下代码将对会话 Cookie 禁用 use_strict_mode 属性。

session.use_strict_mode=0
References
[1] D. Whalen The Unofficial Cookie FAQ
[2] The PHP Group PHP Use Strict Mode Documentation
desc.config.php.session_fixation