CWE-687 Variante Rascunho

Function Call With Incorrectly Specified Argument Value

This vulnerability occurs when a function is called with an argument that holds an incorrect or unexpected value, leading to unintended program behavior or security flaws.

Definição

What is CWE-687?

This vulnerability occurs when a function is called with an argument that holds an incorrect or unexpected value, leading to unintended program behavior or security flaws.
Incorrect argument values often happen due to simple mistakes like mixing up parameter order, using hard-coded magic numbers, or passing a variable that hasn't been properly validated. For example, calling a file permission function with a value meant for a buffer size can expose sensitive data or crash the application. These errors are subtle because the code compiles and runs, but the logic is fundamentally broken, creating a gap between what the developer intended and what actually executes. Finding these mismatches manually in a large codebase is like searching for a needle in a haystack. While SAST tools can flag suspicious patterns, Plexicus uses AI to not only detect these flaws but also generate the precise code fix, transforming a generic warning into an actionable correction. This saves significant manual review time and helps ensure that the function receives the exact value it was designed to handle, closing the door on a wide range of downstream vulnerabilities.
Impacto no mundo real

Real-world CVEs caused by CWE-687

Ainda não há referências CVE públicas associadas a este CWE no catálogo da MITRE.

Como os atacantes a exploram

Trajeto do atacante passo a passo

  1. 1

    Identificar um caminho de código que trata input não confiável sem validação.

  2. 2

    Criar um payload que explora o comportamento inseguro — injeção, traversal, overflow ou abuso de lógica.

  3. 3

    Entregar o payload através de um pedido normal e observar a reação da aplicação.

  4. 4

    Iterar até que a resposta exponha dados, execute código do atacante ou escale privilégios.

Exemplo de código vulnerável

Vulnerable Perl

This Perl code intends to record whether a user authenticated successfully or not, and to exit if the user fails to authenticate. However, when it calls ReportAuth(), the third argument is specified as 0 instead of 1, so it does not exit.

Vulnerável Perl
sub ReportAuth {
  	my ($username, $result, $fatal) = @_;
  	PrintLog("auth: username=%s, result=%d", $username, $result);
  	if (($result ne "success") && $fatal) {
  		die "Failed!\n";
  	}
  }
  sub PrivilegedFunc
  {
  	my $result = CheckAuth($username);
  	ReportAuth($username, $result, 0);
  	DoReallyImportantStuff();
  }
Exemplo de código seguro

Secure pseudo

Seguro pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
  const safe = validateAndEscape(input);
  return executeWithGuards(safe);
}
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-687

  • Architecture Use safe-by-default frameworks and APIs that prevent the unsafe pattern from being expressible.
  • Implementation Validate input at trust boundaries; use allowlists, not denylists.
  • Implementation Apply the principle of least privilege to credentials, file paths, and runtime permissions.
  • Testing Cover this weakness in CI: SAST rules + targeted unit tests for the data flow.
  • Operation Monitor logs for the runtime signals listed in the next section.
Sinais de deteção

How to detect CWE-687

Manual Static Analysis

This might require an understanding of intended program behavior or design to determine whether the value is incorrect.

Correção automática do Plexicus

O Plexicus deteta automaticamente o CWE-687 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-687?

This vulnerability occurs when a function is called with an argument that holds an incorrect or unexpected value, leading to unintended program behavior or security flaws.

Qual a gravidade do CWE-687?

A MITRE não publicou uma classificação de probabilidade de exploração para esta fraqueza. Trate-a como impacto médio até o seu modelo de ameaças provar o contrário.

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

A MITRE não especificou as plataformas afetadas por este CWE — pode aplicar-se à maioria das stacks de aplicações.

Como posso prevenir o CWE-687?

Use safe-by-default frameworks, validate untrusted input at trust boundaries, and apply the principle of least privilege. Cover the data-flow signature in CI with SAST.

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

O motor SAST do Plexicus correlaciona a assinatura de fluxo de dados do CWE-687 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-687?

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

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.