CWE-602 Classe Rascunho Medium likelihood

Client-Side Enforcement of Server-Side Security

This vulnerability occurs when a server incorrectly trusts the client to enforce critical security rules, such as input validation or access controls, instead of performing these checks itself.

Definição

What is CWE-602?

This vulnerability occurs when a server incorrectly trusts the client to enforce critical security rules, such as input validation or access controls, instead of performing these checks itself.
This flaw creates a fundamental trust issue. Since an attacker has full control over their own client—whether it's a browser, mobile app, or API client—they can easily bypass, remove, or manipulate any client-side security checks. The server, operating under the false assumption that these checks are reliable, then processes malicious or unauthorized requests. The impact depends entirely on what the client was supposed to protect. Common consequences include unauthorized data access, privilege escalation, data corruption, or complete system compromise. The root cause is a design error: security must always be enforced at the point where trust is established and data is ultimately processed—the server.
Impacto no mundo real

Real-world CVEs caused by CWE-602

  • SCADA system only uses client-side authentication, allowing adversaries to impersonate other users.

  • ASP program allows upload of .asp files by bypassing client-side checks.

  • steganography products embed password information in the carrier file, which can be extracted from a modified client.

  • steganography products embed password information in the carrier file, which can be extracted from a modified client.

  • client allows server to modify client's configuration and overwrite arbitrary files.

Como os atacantes a exploram

Trajeto do atacante passo a passo

  1. 1

    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.

  2. 2

    CLIENT-SIDE (client.pl)

  3. 3

    SERVER-SIDE (server.pl):

  4. 4

    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.

  5. 5

    In 2022, the OT:ICEFALL study examined products by 10 different Operational Technology (OT) vendors. The researchers reported 56 vulnerabilities and said that the products were "insecure by design" [REF-1283]. If exploited, these vulnerabilities often allowed adversaries to change how the products operated, ranging from denial of service to changing the code that the products executed. Since these products were often used in industries such as power, electrical, water, and others, there could even be safety implications.

Exemplo de código vulnerável

Vulnerable Perl

SERVER-SIDE (server.pl):

Vulnerável Perl
$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");
  	}
  }
Exemplo de código seguro

Secure Perl

CLIENT-SIDE (client.pl)

Seguro 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";
  }
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Lista de verificação de prevenção

How to prevent CWE-602

  • 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.
Sinais de deteção

How to detect CWE-602

SAST High

Executar análise estática (SAST) na base de código à procura do padrão inseguro no fluxo de dados.

DAST Moderate

Executar testes dinâmicos de segurança de aplicações (DAST) contra o endpoint em execução.

Runtime Moderate

Monitorizar os registos em tempo de execução para traços de exceção invulgares, input malformado ou tentativas de contornar a autorização.

Code review Moderate

Revisão de código: sinalizar qualquer novo código que trate input desta superfície sem usar os ajudantes validados do framework.

Correção automática do Plexicus

O Plexicus deteta automaticamente o CWE-602 e abre um PR de correção em menos de 60 segundos.

O Codex Remedium analisa cada commit, identifica esta fraqueza exata e entrega um pull request pronto para revisão com o patch. Sem tickets. Sem transferências.

Perguntas frequentes

Frequently asked questions

O que é o CWE-602?

This vulnerability occurs when a server incorrectly trusts the client to enforce critical security rules, such as input validation or access controls, instead of performing these checks itself.

Qual a gravidade do CWE-602?

A MITRE classifica a probabilidade de exploração como Média — a exploração é realista mas normalmente requer condições específicas.

Que linguagens ou plataformas são afetadas pelo CWE-602?

MITRE lists the following affected platforms: ICS/OT, Mobile.

Como posso prevenir o CWE-602?

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…

Como é que o Plexicus deteta e corrige o CWE-602?

O motor SAST do Plexicus correlaciona a assinatura de fluxo de dados do CWE-602 em cada commit. Quando é encontrada uma correspondência, o nosso agente Codex Remedium abre um PR de correção com o código corrigido, testes e um resumo de uma linha para o revisor.

Onde posso saber mais sobre o CWE-602?

A MITRE publica a definição canónica em https://cwe.mitre.org/data/definitions/602.html. Pode também consultar a documentação da OWASP e do NIST para orientações adjacentes.

Fraquezas relacionadas

Weaknesses related to CWE-602

CWE-693 Pai

Protection Mechanism Failure

This weakness occurs when software either lacks a necessary security control, implements one that is too weak, or fails to activate an…

CWE-1039 Irmão

Inadequate Detection or Handling of Adversarial Input Perturbations in Automated Recognition Mechanism

This vulnerability occurs when a system uses automated AI or machine learning to classify complex inputs like images, audio, or text, but…

CWE-1248 Irmão

Semiconductor Defects in Hardware Logic with Security-Sensitive Implications

A security-critical hardware component contains physical flaws in its semiconductor material, which can cause it to malfunction and…

CWE-1253 Irmão

Incorrect Selection of Fuse Values

This vulnerability occurs when a hardware security fuse is incorrectly programmed to represent a 'secure' state as logic 0 (unblown). An…

CWE-1269 Irmão

Product Released in Non-Release Configuration

This vulnerability occurs when a product ships to customers while still configured with its pre-production or manufacturing settings,…

CWE-1278 Irmão

Missing Protection Against Hardware Reverse Engineering Using Integrated Circuit (IC) Imaging Techniques

This vulnerability occurs when hardware lacks safeguards against physical inspection, allowing attackers to extract sensitive data by…

CWE-1291 Irmão

Public Key Re-Use for Signing both Debug and Production Code

This vulnerability occurs when the same cryptographic key is used to sign both development/debug software builds and final production…

CWE-1318 Irmão

Missing Support for Security Features in On-chip Fabrics or Buses

This vulnerability occurs when the communication channels (fabrics or buses) within a chip lack built-in or enabled security features,…

CWE-1319 Irmão

Improper Protection against Electromagnetic Fault Injection (EM-FI)

This vulnerability occurs when a hardware device lacks sufficient shielding against electromagnetic interference, allowing attackers to…

Pronto quando você estiver

Pare de pagar por desenvolvedor.
Comece a fechar o ciclo.

O Plexicus é o ASPM nativo de IA que verifica, filtra, corrige, pentesta e explica — de forma autónoma. Programadores ilimitados, repos ilimitados, ações de IA de utilização justa. Nível gratuito real, €269/mo anual quando estiver pronto.