界: Environment

本节包括的所有内容均与源代码无关,但对所创建产品的安全性仍然至关重要。因为本节涉及的问题与源代码没有直接关系,所以我们将它与其他章节分开。

J2EE Misconfiguration: Insufficient Session ID Length

Abstract
会话标识符的长度应至少为 128 比特,以防止暴力破解会话攻击。
Explanation
WebLogic 部署描述符应指定长度至少为 24 个字节的会话标识符。较短的会话标识符使应用程序容易受到暴力破解会话攻击。如果攻击者可以猜测出经过身份验证的用户的会话标识符,他就可以接管该用户的会话。接下来的内容将详细说明使用 24 字节会话标识符的深层合理性。

会话标识符是一个从 62 个英文或数字中产生的伪随机结果,这意味着,如果这个字符串的每一个字节都是真正随机生成的,那么它就能产生一个最大 6 比特的熵。

猜测有效会话标识符所需的预期秒数通过以下等式得出:

(2^B+1) / (2*A*S)

其中:

- B 是会话标识符中熵的比特数。

- A 是攻击者每秒可能尝试猜测的次数。

- S 是在任意指定时间内可供猜测的有效会话标识符数。

会话标识符中熵的比特数始终小于总比特数。例如,如果会话标识符按升序给出,那么不管标识符的长度如何,在会话标识符中都有接近 0 比特的熵。假设会话标识符都是通过一个正常的随机数值源产生的,我们将能估算出会话标识符中熵的比特数是总比特数的一半。现实中这样长度的标识符是有可能存在的,虽然这一看法不免可能有些乐观。

如果攻击者使用由数百或数千台计算机组成的僵尸网络 (botnet),那么我们有理由相信他们能够完成每秒几万次的猜测。如果这个存在问题的网站规模大且受欢迎,大量的猜测行为可能在一段时间内被忽略。

可供猜测的有效会话标识符数的下限是在任意指定时间内,站点上的活动用户数量。但是,任何没有注销就丢弃会话的用户行为都将增加这个数量。(这就是为什么要设置较短的非活动会话超时时间的原因之一。)

对于一个 64 比特的会话标识符,假设有 32 比特的熵。对于一个大型网站,假设攻击者每秒可以尝试 1,000 次猜测,并且在任意给定时间内有 10,000 个有效的会话标识符。根据这些假设,攻击者成功猜测出一个有效会话标识符的预期时间少于 4 分钟。

现在假设有一个提供了 64 比特熵的 128 比特会话标识符。对于一个超大型网站,可供猜测的有效会话标识符有 100,000 个,攻击者可能尝试进行每秒 10,000 次的猜测。基于这些假设,攻击者成功破解出一个有效会话标识符的预期时间将大于 292 年。

将比特数换算成字节数,就会得出会话标识符为 128/6,即大约 21 字节。而且,实验表明,会话标识符的前三个字节不会随机产生,这就意味着,要实现所需的 64 比特熵,我们需要将 WebLogic 配置为使用一个长度为 24 字节的会话标识符。
References
[1] Standards Mapping - Common Weakness Enumeration CWE ID 6
[2] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001941, CCI-001942
[3] Standards Mapping - FIPS200 IA
[4] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[5] Standards Mapping - NIST Special Publication 800-53 Revision 4 IA-2 Identification and Authentication (Organizational Users) (P1), SC-23 Session Authenticity (P1)
[6] Standards Mapping - NIST Special Publication 800-53 Revision 5 IA-2 Identification and Authentication (Organizational Users), SC-23 Session Authenticity
[7] Standards Mapping - OWASP API 2023 API8 Security Misconfiguration
[8] Standards Mapping - OWASP Application Security Verification Standard 4.0 14.1.3 Build (L2 L3)
[9] Standards Mapping - OWASP Mobile 2014 M9 Improper Session Handling
[10] Standards Mapping - OWASP Top 10 2004 A3 Broken Authentication and Session Management
[11] Standards Mapping - OWASP Top 10 2007 A7 Broken Authentication and Session Management
[12] Standards Mapping - OWASP Top 10 2010 A3 Broken Authentication and Session Management
[13] Standards Mapping - OWASP Top 10 2013 A2 Broken Authentication and Session Management
[14] Standards Mapping - OWASP Top 10 2017 A2 Broken Authentication
[15] Standards Mapping - OWASP Top 10 2021 A05 Security Misconfiguration
[16] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.3
[17] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 6.5.7
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 6.5.8
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.10
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.10
[21] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.10
[22] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.10
[23] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[24] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0.1 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
[27] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection
[28] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3405 CAT I
[29] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3405 CAT I
[30] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3405 CAT I
[31] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3405 CAT I
[32] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3405 CAT I
[33] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3405 CAT I
[34] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3405 CAT I
[35] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[49] Standards Mapping - Security Technical Implementation Guide Version 6.1 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II
[50] Standards Mapping - Web Application Security Consortium Version 2.00 Insufficient Authentication (WASC-01)
[51] Standards Mapping - Web Application Security Consortium 24 + 2 Insufficient Authentication
desc.config.java.j2ee_misconfiguration_insufficient_session_id_length