CWE-602 服务端安全的客户端实施

Client-Side Enforcement of Server-Side Security

结构: Simple

Abstraction: Base

状态: Draft

被利用可能性: Medium

基本描述

The software is composed of a server that relies on the client to implement a mechanism that is intended to protect the server.

扩展描述

When the server relies on protection mechanisms placed on the client side, an attacker can modify the client-side behavior to bypass the protection mechanisms resulting in potentially unexpected interactions between the client and server. The consequences will vary, depending on what the mechanisms are trying to protect.

相关缺陷

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

  • cwe_Nature: ChildOf cwe_CWE_ID: 693 cwe_View_ID: 1000

  • cwe_Nature: CanPrecede cwe_CWE_ID: 471 cwe_View_ID: 1000

  • cwe_Nature: PeerOf cwe_CWE_ID: 290 cwe_View_ID: 1000

  • cwe_Nature: PeerOf cwe_CWE_ID: 300 cwe_View_ID: 1000

适用平台

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

Paradigm: {'cwe_Name': 'Client Server', 'cwe_Prevalence': 'Sometimes'}

常见的影响

范围 影响 注释
['Access Control', 'Availability'] ['Bypass Protection Mechanism', 'DoS: Crash, Exit, or Restart'] Client-side validation checks can be easily bypassed, allowing malformed or unexpected input to pass into the application, potentially as trusted data. This may lead to unexpected states, behaviors and possibly a resulting crash.
Access Control ['Bypass Protection Mechanism', 'Gain Privileges or Assume Identity'] Client-side checks for authentication can be easily bypassed, allowing clients to escalate their access levels and perform unintended actions.

可能的缓解方案

Architecture and Design

策略:

For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server. Even though client-side checks provide minimal benefits with respect to server-side security, they are still useful. First, they can support intrusion detection. If the server receives input that should have been rejected by the client, then it may be an indication of an attack. Second, client-side error-checking can provide helpful feedback to the user about the expectations for valid input. Third, there may be a reduction in server-side processing time for accidental input errors, although this is typically a small savings.

Architecture and Design

策略:

If some degree of trust is required between the two entities, then use integrity checking and strong authentication to ensure that the inputs are coming from a trusted source. Design the product so that this trust is managed in a centralized fashion, especially if there are complex or numerous communication channels, in order to reduce the risks that the implementer will mistakenly omit a check in a single code path.

Testing

策略:

Use dynamic tools and techniques that interact with the software using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The software's operation may slow down, but it should not become unstable, crash, or generate incorrect results.

Testing

策略:

Use tools and techniques that require manual (human) analysis, such as penetration testing, threat modeling, and interactive tools that allow the tester to record and modify an active session. These may be more effective than strictly automated techniques. This is especially the case with weaknesses that are related to design and business rules.

示例代码

This example contains client-side code that checks if the user authenticated successfully before sending a command. The server-side code performs the authentication in one step, and executes the command in a separate step.

CLIENT-SIDE (client.pl)

good Perl

$server = "server.example.com";
$username = AskForUserName();
$password = AskForPassword();
$address = AskForAddress();
$sock = OpenSocket($server, 1234);
writeSocket($sock, "AUTH $username $password\n");
$resp = readSocket($sock);
if ($resp eq "success") {

# username/pass is valid, go ahead and update the info!
writeSocket($sock, "CHANGE-ADDRESS $username $address\n";
}
else {
print "ERROR: Invalid Authentication!\n";
}

SERVER-SIDE (server.pl):

bad

$sock = acceptSocket(1234);
($cmd, $args) = ParseClientRequest($sock);
if ($cmd eq "AUTH") {
($username, $pass) = split(/\s+/, $args, 2);
$result = AuthenticateUser($username, $pass);
writeSocket($sock, "$result\n");
# does not close the socket on failure; assumes the

# user will try again
}
elsif ($cmd eq "CHANGE-ADDRESS") {
if (validateAddress($args)) {
$res = UpdateDatabaseRecord($username, "address", $args);
writeSocket($sock, "SUCCESS\n");
}
else {
writeSocket($sock, "FAILURE -- address is malformed\n");
}
}

The server accepts 2 commands, "AUTH" which authenticates the user, and "CHANGE-ADDRESS" which updates the address field for the username. The client performs the authentication and only sends a CHANGE-ADDRESS for that user if the authentication succeeds. Because the client has already performed the authentication, the server assumes that the username in the CHANGE-ADDRESS is the same as the authenticated user. An attacker could modify the client by removing the code that sends the "AUTH" command and simply executing the CHANGE-ADDRESS.

分析过的案例

标识 说明 链接
CVE-2006-6994 ASP program allows upload of .asp files by bypassing client-side checks. http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-6994
CVE-2007-0163 steganography products embed password information in the carrier file, which can be extracted from a modified client. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-0163
CVE-2007-0164 steganography products embed password information in the carrier file, which can be extracted from a modified client. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-0164
CVE-2007-0100 client allows server to modify client's configuration and overwrite arbitrary files. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-0100

Notes

分类映射

映射的分类名 ImNode ID Fit Mapped Node Name
OWASP Top Ten 2004 A1 CWE More Specific Unvalidated Input

相关攻击模式

  • CAPEC-162
  • CAPEC-202
  • CAPEC-207
  • CAPEC-208
  • CAPEC-21
  • CAPEC-31
  • CAPEC-383
  • CAPEC-384
  • CAPEC-385
  • CAPEC-386
  • CAPEC-387
  • CAPEC-388

引用