CWE-940 通信信道源的不正确验证

Improper Verification of Source of a Communication Channel

结构: Simple

Abstraction: Base

状态: Incomplete

被利用可能性: unkown

基本描述

The software establishes a communication channel to handle an incoming request that has been initiated by an actor, but it does not properly verify that the request is coming from the expected origin.

扩展描述

When an attacker can successfully establish a communication channel from an untrusted origin, the attacker may be able to gain privileges and access unexpected functionality.

相关缺陷

  • cwe_Nature: ChildOf cwe_CWE_ID: 923 cwe_View_ID: 1000 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 923 cwe_View_ID: 699 cwe_Ordinal: Primary

适用平台

Language: {'cwe_Class': 'Language-Independent', 'cwe_Prevalence': 'Undetermined'}

Paradigm: {'cwe_Name': 'Mobile', 'cwe_Prevalence': 'Undetermined'}

常见的影响

范围 影响 注释
['Access Control', 'Other'] ['Gain Privileges or Assume Identity', 'Varies by Context'] An attacker can access any functionality that is inadvertently accessible to the source.

可能的缓解方案

Architecture and Design

策略:

Use a mechanism that can validate the identity of the source, such as a certificate, and validate the integrity of data to ensure that it cannot be modified in transit using a man-in-the-middle attack. When designing functionality of actions in the URL scheme, consider whether the action should be accessible to all mobile applications, or if a whitelist of applications to interface with is appropriate.

示例代码

This Android application will remove a user account when it receives an intent to do so:

bad Java

IntentFilter filter = new IntentFilter("com.example.RemoveUser");
MyReceiver receiver = new MyReceiver();
registerReceiver(receiver, filter);

public class DeleteReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
int userID = intent.getIntExtra("userID");
destroyUserData(userID);
}
}

This application does not check the origin of the intent, thus allowing any malicious application to remove a user. Always check the origin of an intent, or create a whitelist of trusted applications using the manifest.xml file.

These Android and iOS applications intercept URL loading within a WebView and perform special actions if a particular URL scheme is used, thus allowing the Javascript within the WebView to communicate with the application:

bad Java


// Android
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url){
if (url.substring(0,14).equalsIgnoreCase("examplescheme:")){
if(url.substring(14,25).equalsIgnoreCase("getUserInfo")){
writeDataToView(view, UserData);
return false;
}
else{
return true;
}
}
}

bad Objective-C


// iOS
-(BOOL) webView:(UIWebView )exWebView shouldStartLoadWithRequest:(NSURLRequest )exRequest navigationType:(UIWebViewNavigationType)exNavigationType
{
NSURL URL = [exRequest URL];
if ([[URL scheme] isEqualToString:@"exampleScheme"])
{
NSString functionString = [URL resourceSpecifier];
if ([functionString hasPrefix:@"specialFunction"])
{

// Make data available back in webview.
UIWebView *webView = [self writeDataToView:[URL query]];
}
return NO;
}
return YES;
}

A call into native code can then be initiated by passing parameters within the URL:

attack JavaScript

window.location = examplescheme://method?parameter=value

Because the application does not check the source, a malicious website loaded within this WebView has the same access to the API as a trusted site.

分析过的案例

标识 说明 链接
CVE-2000-1218 DNS server can accept DNS updates from hosts that it did not query, leading to cache poisoning https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2000-1218
CVE-2005-0877 DNS server can accept DNS updates from hosts that it did not query, leading to cache poisoning https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-0877
CVE-2001-1452 DNS server caches glue records received from non-delegated name servers https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2001-1452

Notes

相关攻击模式

  • CAPEC-594
  • CAPEC-595
  • CAPEC-596

引用