Download of Code Without Integrity Check

The product downloads source code or an executable from a remote location and executes the code without sufficiently verifying the origin and integrity of the code.


An attacker can execute malicious code by compromising the host server, performing DNS spoofing, or modifying the code in transit.


The following examples help to illustrate the nature of this weakness and describe methods or techniques which can be used to mitigate the risk.

Note that the examples here are by no means exhaustive and any given weakness may have many subtle varieties, each of which may require different detection methods or runtime controls.

Example One

This example loads an external class from a local subdirectory.

URL[] classURLs= new URL[]{
  new URL("file:subdir/")
URLClassLoader loader = new URLClassLoader(classURLs);
Class loadedClass = Class.forName("loadMe", true, loader);

This code does not ensure that the class loaded is the intended one, for example by verifying the class's checksum. An attacker may be able to modify the class file to execute malicious code.

Example Two

This code includes an external script to get database credentials, then authenticates a user against the database, allowing access to the application.

//assume the password is already encrypted, avoiding CWE-312

function authenticate($username,$password){


  //dbInfo.php makes $dbhost, $dbuser, $dbpass, $dbname available
  mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
  $query = 'Select * from users where username='.$username.' And password='.$password;
  $result = mysql_query($query);

  if(mysql_numrows($result) == 1){
    return true;
    return false;


This code does not verify that the external domain accessed is the intended one. An attacker may somehow cause the external domain name to resolve to an attack server, which would provide the information for a false database. The attacker may then steal the usernames and encrypted passwords from real user login attempts, or simply allow themself to access the application without a real user account.

This example is also vulnerable to a MITM (CWE-300) attack.

See Also

Data Integrity Issues

Weaknesses in this category are related to a software system's data integrity components. Frequently these deal with the ability to ensure the integrity of data, such ...

Verify Message Integrity

Weaknesses in this category are related to the design and architecture of a system's data integrity components. Frequently these deal with ensuring integrity of data, ...

SFP Secondary Cluster: Tainted Input to Environment

This category identifies Software Fault Patterns (SFPs) within the Tainted Input to Environment cluster (SFP27).

Comprehensive CWE Dictionary

This view (slice) covers all the elements in CWE.

CWE Cross-section

This view contains a selection of weaknesses that represent the variety of weaknesses that are captured in CWE, at a level of abstraction that is likely to be useful t...

Weaknesses Introduced During Implementation

This view (slice) lists weaknesses that can be introduced during implementation.

Common Weakness Enumeration content on this website is copyright of The MITRE Corporation unless otherwise specified. Use of the Common Weakness Enumeration and the associated references on this website are subject to the Terms of Use as specified by The MITRE Corporation.