|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CWE-628: Function Call with Incorrectly Specified Arguments
Description Summary The product calls a function, procedure, or routine with arguments that are not correctly specified, leading to always-incorrect behavior and resultant weaknesses.
Extended Description There are multiple ways in which this weakness can be introduced, including:
Example 1 The following PHP method authenticates a user given a username/password combination but is called with the parameters in reverse order. (Bad Code) Example
Language: PHP function authenticate($username, $password) { // authenticate user
...
} authenticate($_POST['password'], $_POST['username']); Example 2 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 Code) Example
Language: 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();
} Example 3 In the following Java snippet, the accessGranted() method is accidentally called with the static ADMIN_ROLES array rather than the user roles. (Bad Code) Example
Language: Java private static final String[] ADMIN_ROLES = ...; public boolean void accessGranted(String resource, String user)
{ String[] userRoles = getUserRoles(user);
return accessGranted(resource, ADMIN_ROLES);
} private boolean void accessGranted(String resource, String[]
userRoles) { // grant or deny access based on user roles
...
}
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Page Last Updated:
February 20, 2013
|
|
CWE is co-sponsored by the office of Cybersecurity and Communications at the U.S. Department of Homeland Security. This Web site is sponsored and managed by The MITRE Corporation to enable stakeholder collaboration. Copyright © 2006-2013, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation. Contact cwe@mitre.org for more information. |
|||



