1186
Detection Methods
Manual Analysis
This weakness can be detected using 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. Specifically, manual static analysis is typically required to
find the behavior that triggers the download of code, and to determine whether integrity-checking
methods are in use.
Black Box
Use monitoring tools that examine the software's process as it interacts with the operating
system and the network. This technique is useful in cases when source code is unavailable, if the
software was not developed by you, or if you want to verify that the build phase did not introduce
any new weaknesses. Examples include debuggers that directly attach to the running process;
system-call tracing utilities such as truss (Solaris) and strace (Linux); system activity monitors
such as FileMon, RegMon, Process Monitor, and other Sysinternals utilities (Windows); and
sniffers and protocol analyzers that monitor network traffic. Attach the monitor to the process
and also sniff the network connection. Trigger features related to product updates or plugin
installation, which is likely to force a code download. Monitor when files are downloaded and
separately executed, or if they are otherwise read back into the process. Look for evidence of
cryptographic library calls that use integrity checking.
Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST),
can find some instances of this weakness by analyzing source code (or binary/compiled code)
without having to execute it. Typically, this is done by building a model of data flow and control
flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input)
with "sinks" (destinations where the data interacts with external components, a lower layer such
as the OS, etc.)
Effectiveness = High
Potential Mitigations
Phase: Implementation
Perform proper forward and reverse DNS lookups to detect DNS spoofing.
Phase: Architecture and Design
Phase: Operation
Encrypt the code with a reliable encryption scheme before transmitting. This will only be a
partial solution, since it will not detect DNS spoofing and it will not prevent your code from being
modified on the hosting site.
Phase: Architecture and Design
Strategy = Libraries or Frameworks
Use a vetted library or framework that does not allow this weakness to occur or provides
constructs that make this weakness easier to avoid. Speficially, it may be helpful to use tools
or frameworks to perform integrity checking on the transmitted code. When providing the code
that is to be downloaded, such as for automatic updates of the software, then use cryptographic
signatures for the code and modify the download clients to verify the signatures. Ensure that
the implementation does not contain CWE-295, CWE-320, CWE-347, and related weaknesses.
Use code signing technologies such as Authenticode. See references [REF-454] [REF-455]
[REF-456].
Phase: Architecture and Design
Phase: Operation
CWE Version 4.14
CWE-494: Download of Code Without Integrity Check
CWE-494: Download of Code Without Integrity Check