CWE-567 在多现场上下文中未能对共享数据进行同步访问
Unsynchronized Access to Shared Data in a Multithreaded Context
结构: Simple
Abstraction: Base
状态: Draft
被利用可能性: unkown
基本描述
The product does not properly synchronize shared data, such as static variables across threads, which can lead to undefined behavior and unpredictable data changes.
扩展描述
Within servlets, shared static variables are not protected from concurrent access, but servlets are multithreaded. This is a typical programming mistake in J2EE applications, since the multithreading is handled by the framework. When a shared variable can be influenced by an attacker, one thread could wind up modifying the variable to contain data that is not valid for a different thread that is also using the data within the variable.
Note that this weakness is not unique to servlets.
相关缺陷
-
cwe_Nature: ChildOf cwe_CWE_ID: 820 cwe_View_ID: 1000 cwe_Ordinal: Primary
-
cwe_Nature: CanPrecede cwe_CWE_ID: 488 cwe_View_ID: 1000
适用平台
Language: {'cwe_Name': 'Java', 'cwe_Prevalence': 'Undetermined'}
常见的影响
范围 | 影响 | 注释 |
---|---|---|
['Confidentiality', 'Integrity', 'Availability'] | ['Read Application Data', 'Modify Application Data', 'DoS: Instability', 'DoS: Crash, Exit, or Restart'] | If the shared variable contains sensitive data, it may be manipulated or displayed in another user session. If this data is used to control the application, its value can be manipulated to cause the application to crash or perform poorly. |
可能的缓解方案
Implementation
策略:
Remove the use of static variables used between servlets. If this cannot be avoided, use synchronized access for these variables.
示例代码
例
The following code implements a basic counter for how many times the page has been accesed.
bad Java
protected void doGet(HttpServletRequest in, HttpServletResponse out)
throws ServletException, IOException {
PrintWriter p = out.getWriter();
count++;
p.println(count + " hits so far!");
}
}
Consider when two separate threads, Thread A and Thread B, concurrently handle two different requests:
None
At this point, both Thread A and Thread B print that one hit has been seen, even though two separate requests have been processed. The value of count should be 2, not 1.
While this example does not have any real serious implications, if the shared variable in question is used for resource tracking, then resource consumption could occur. Other scenarios exist.
分类映射
映射的分类名 | ImNode ID | Fit | Mapped Node Name |
---|---|---|---|
The CERT Oracle Secure Coding Standard for Java (2011) | VNA00-J | Ensure visibility when accessing shared primitive variables | |
The CERT Oracle Secure Coding Standard for Java (2011) | VNA02-J | Ensure that compound operations on shared variables are atomic | |
Software Fault Patterns | SFP19 | Missing Lock |
相关攻击模式
- CAPEC-25
文章来源于互联网:scap中文网
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论