Variant · Low-Medium

CWE-687: Function Call With Incorrectly Specified Argument Value

The product calls a function, procedure, or routine, but the caller specifies an argument that contains the wrong value, which may lead to resultant weaknesses.

CWE-687 · Variant Level

Description

The product calls a function, procedure, or routine, but the caller specifies an argument that contains the wrong value, which may lead to resultant weaknesses.

Potential Impact

Other

Quality Degradation

Demonstrative Examples

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.
Bad
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();}

Detection Methods

  • Manual Static Analysis — This might require an understanding of intended program behavior or design to determine whether the value is incorrect.

Taxonomy Mappings

  • CERT C Secure Coding: MEM04-C — Do not perform zero length allocations
  • Software Fault Patterns: SFP24 — Tainted input to command

Frequently Asked Questions

What is CWE-687?

CWE-687 (Function Call With Incorrectly Specified Argument Value) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Variant-level weakness. The product calls a function, procedure, or routine, but the caller specifies an argument that contains the wrong value, which may lead to resultant weaknesses.

How can CWE-687 be exploited?

Attackers can exploit CWE-687 (Function Call With Incorrectly Specified Argument Value) to quality degradation. This weakness is typically introduced during the Implementation phase of software development.

How do I prevent CWE-687?

Follow secure coding practices, conduct code reviews, and use automated security testing tools (SAST/DAST) to detect this weakness early in the development lifecycle.

What is the severity of CWE-687?

CWE-687 is classified as a Variant-level weakness (Low-Medium abstraction). Its actual severity depends on the specific context and how the weakness manifests in your application.