Common Weakness Enumeration

CWE-94

Allowed-with-Review

Improper Control of Generation of Code ('Code Injection')

Abstraction: Base · Status: Draft

The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.

8272 vulnerabilities reference this CWE, most recent first.

GHSA-G4C9-F287-64XG

Vulnerability from github – Published: 2025-09-08 18:31 – Updated: 2025-09-15 13:53
VLAI
Summary
SimStudioAI: A function in route.ts is vulnerable to Code Injection
Details

A vulnerability was identified in SimStudioAI sim. This impacts an unknown function of the file apps/sim/app/api/function/execute/route.ts. The manipulation of the argument code leads to code injection. The attack is possible to be carried out remotely.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "npm",
        "name": "simstudio"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "last_affected": "0.1.19"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2025-10097"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-74",
      "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2025-09-15T13:53:57Z",
    "nvd_published_at": "2025-09-08T17:15:32Z",
    "severity": "MODERATE"
  },
  "details": "A vulnerability was identified in SimStudioAI sim. This impacts an unknown function of the file apps/sim/app/api/function/execute/route.ts. The manipulation of the argument code leads to code injection. The attack is possible to be carried out remotely.",
  "id": "GHSA-g4c9-f287-64xg",
  "modified": "2025-09-15T13:53:57Z",
  "published": "2025-09-08T18:31:40Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-10097"
    },
    {
      "type": "WEB",
      "url": "https://github.com/simstudioai/sim/issues/961"
    },
    {
      "type": "WEB",
      "url": "https://github.com/simstudioai/sim/issues/961#issuecomment-3215578979"
    },
    {
      "type": "WEB",
      "url": "https://github.com/simstudioai/sim/pull/1149/commits/3f790867427275ebae3b3dc75cf1d93d912ac9ca"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/simstudioai/sim"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?ctiid.323058"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?id.323058"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?submit.644954"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L",
      "type": "CVSS_V3"
    },
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
      "type": "CVSS_V4"
    }
  ],
  "summary": "SimStudioAI: A function in route.ts is vulnerable to Code Injection"
}

GHSA-G4CV-96P3-5RQP

Vulnerability from github – Published: 2022-05-13 01:03 – Updated: 2022-05-13 01:03
VLAI
Details

An issue was discovered in UCMS 1.4.6 and 1.6. It allows PHP code injection during installation via the systemdomain parameter to install/index.php, as demonstrated by injecting a phpinfo() call into /inc/config.php.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2018-17036"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2018-09-14T07:29:00Z",
    "severity": "CRITICAL"
  },
  "details": "An issue was discovered in UCMS 1.4.6 and 1.6. It allows PHP code injection during installation via the systemdomain parameter to install/index.php, as demonstrated by injecting a phpinfo() call into /inc/config.php.",
  "id": "GHSA-g4cv-96p3-5rqp",
  "modified": "2022-05-13T01:03:32Z",
  "published": "2022-05-13T01:03:32Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2018-17036"
    },
    {
      "type": "WEB",
      "url": "https://github.com/blackstar24/UCMS/blob/master/phpinfo.md"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-G4FM-73WH-J3M8

Vulnerability from github – Published: 2025-04-22 12:31 – Updated: 2025-04-22 12:31
VLAI
Details

The Ocean Extra plugin for WordPress is vulnerable to arbitrary shortcode execution in all versions up to, and including, 2.4.6. This is due to the software allowing users to execute an action that does not properly validate a value before running do_shortcode. This makes it possible for unauthenticated attackers to execute arbitrary shortcodes when WooCommerce is also installed and activated.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-3472"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-04-22T12:15:16Z",
    "severity": "MODERATE"
  },
  "details": "The Ocean Extra plugin for WordPress is vulnerable to arbitrary shortcode execution in all versions up to, and including, 2.4.6. This is due to the software allowing users to execute an action that does not properly validate a value before running do_shortcode. This makes it possible for unauthenticated attackers to execute arbitrary shortcodes when WooCommerce is also installed and activated.",
  "id": "GHSA-g4fm-73wh-j3m8",
  "modified": "2025-04-22T12:31:24Z",
  "published": "2025-04-22T12:31:24Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-3472"
    },
    {
      "type": "WEB",
      "url": "https://plugins.trac.wordpress.org/browser/ocean-extra/trunk/includes/shortcodes/shortcodes.php#L618"
    },
    {
      "type": "WEB",
      "url": "https://plugins.trac.wordpress.org/changeset/3277977"
    },
    {
      "type": "WEB",
      "url": "https://www.wordfence.com/threat-intel/vulnerabilities/id/74428e76-1946-408f-8adc-24ab4b7e46c5?source=cve"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-G4G2-W92H-7FJC

Vulnerability from github – Published: 2022-05-17 03:23 – Updated: 2025-04-11 04:06
VLAI
Details

The _compile function in Maketext.pm in the Locale::Maketext implementation in Perl before 5.17.7 does not properly handle backslashes and fully qualified method names during compilation of bracket notation, which allows context-dependent attackers to execute arbitrary commands via crafted input to an application that accepts translation strings from users, as demonstrated by the TWiki application before 5.1.3, and the Foswiki application 1.0.x through 1.0.10 and 1.1.x through 1.1.6.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2012-6329"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2013-01-04T21:55:00Z",
    "severity": "HIGH"
  },
  "details": "The _compile function in Maketext.pm in the Locale::Maketext implementation in Perl before 5.17.7 does not properly handle backslashes and fully qualified method names during compilation of bracket notation, which allows context-dependent attackers to execute arbitrary commands via crafted input to an application that accepts translation strings from users, as demonstrated by the TWiki application before 5.1.3, and the Foswiki application 1.0.x through 1.0.10 and 1.1.x through 1.1.6.",
  "id": "GHSA-g4g2-w92h-7fjc",
  "modified": "2025-04-11T04:06:04Z",
  "published": "2022-05-17T03:23:31Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2012-6329"
    },
    {
      "type": "WEB",
      "url": "https://bugzilla.redhat.com/show_bug.cgi?id=884354"
    },
    {
      "type": "WEB",
      "url": "https://wiki.mageia.org/en/Support/Advisories/MGASA-2013-0032"
    },
    {
      "type": "WEB",
      "url": "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=695224"
    },
    {
      "type": "WEB",
      "url": "http://code.activestate.com/lists/perl5-porters/187746"
    },
    {
      "type": "WEB",
      "url": "http://code.activestate.com/lists/perl5-porters/187763"
    },
    {
      "type": "WEB",
      "url": "http://kb.juniper.net/InfoCenter/index?page=content\u0026id=JSA10705"
    },
    {
      "type": "WEB",
      "url": "http://kb.juniper.net/InfoCenter/index?page=content\u0026id=JSA10735"
    },
    {
      "type": "WEB",
      "url": "http://openwall.com/lists/oss-security/2012/12/11/4"
    },
    {
      "type": "WEB",
      "url": "http://perl5.git.perl.org/perl.git/blob/HEAD:/pod/perl5177delta.pod"
    },
    {
      "type": "WEB",
      "url": "http://perl5.git.perl.org/perl.git/commit/1735f6f53ca19f99c6e9e39496c486af323ba6a8"
    },
    {
      "type": "WEB",
      "url": "http://rhn.redhat.com/errata/RHSA-2013-0685.html"
    },
    {
      "type": "WEB",
      "url": "http://sourceforge.net/mailarchive/message.php?msg_id=30219695"
    },
    {
      "type": "WEB",
      "url": "http://twiki.org/cgi-bin/view/Codev/SecurityAlert-CVE-2012-6329"
    },
    {
      "type": "WEB",
      "url": "http://www.mandriva.com/security/advisories?name=MDVSA-2013:113"
    },
    {
      "type": "WEB",
      "url": "http://www.oracle.com/technetwork/topics/security/ovmbulletinjul2016-3090546.html"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/56950"
    },
    {
      "type": "WEB",
      "url": "http://www.ubuntu.com/usn/USN-2099-1"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-G4J5-MVHR-VGWR

Vulnerability from github – Published: 2022-05-01 23:47 – Updated: 2022-05-01 23:47
VLAI
Details

Multiple unspecified vulnerabilities in the JPEG (GDI+) and GIF image processing in Microsoft Windows CE 5.0 allow remote attackers to execute arbitrary code via crafted (1) JPEG and (2) GIF images.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2008-2160"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2008-05-12T22:20:00Z",
    "severity": "HIGH"
  },
  "details": "Multiple unspecified vulnerabilities in the JPEG (GDI+) and GIF image processing in Microsoft Windows CE 5.0 allow remote attackers to execute arbitrary code via crafted (1) JPEG and (2) GIF images.",
  "id": "GHSA-g4j5-mvhr-vgwr",
  "modified": "2022-05-01T23:47:07Z",
  "published": "2022-05-01T23:47:07Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2008-2160"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/42334"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/30197"
    },
    {
      "type": "WEB",
      "url": "http://support.microsoft.com/kb/948812"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/29147"
    },
    {
      "type": "WEB",
      "url": "http://www.securitytracker.com/id?1020007"
    },
    {
      "type": "WEB",
      "url": "http://www.vupen.com/english/advisories/2008/1469/references"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-G4M9-9H4J-22XX

Vulnerability from github – Published: 2025-05-13 18:30 – Updated: 2025-10-22 00:33
VLAI
Details

Remote Code Execution in API component in Ivanti Endpoint Manager Mobile 12.5.0.0 and prior on unspecified platforms allows authenticated attackers to execute arbitrary code via crafted API requests.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-4428"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-05-13T16:15:32Z",
    "severity": "HIGH"
  },
  "details": "Remote Code Execution in API component in Ivanti Endpoint Manager Mobile 12.5.0.0 and prior on unspecified platforms allows authenticated attackers to execute arbitrary code via crafted API requests.",
  "id": "GHSA-g4m9-9h4j-22xx",
  "modified": "2025-10-22T00:33:18Z",
  "published": "2025-05-13T18:30:53Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-4428"
    },
    {
      "type": "WEB",
      "url": "https://forums.ivanti.com/s/article/Security-Advisory-Ivanti-Endpoint-Manager-Mobile-EPMM"
    },
    {
      "type": "WEB",
      "url": "https://www.cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2025-4428"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-G4P4-G8HM-9PRR

Vulnerability from github – Published: 2022-05-01 18:36 – Updated: 2022-05-01 18:36
VLAI
Details

Direct static code injection vulnerability in the download module in Flatnuke 3 allows remote authenticated administrators to inject arbitrary PHP code into a description.it.php file in a subdirectory of Download/ by saving a description and setting fneditmode to 1. NOTE: unauthenticated remote attackers can exploit this by leveraging a cookie manipulation issue.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2007-5772"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2007-11-01T16:46:00Z",
    "severity": "MODERATE"
  },
  "details": "Direct static code injection vulnerability in the download module in Flatnuke 3 allows remote authenticated administrators to inject arbitrary PHP code into a description.it.php file in a subdirectory of Download/ by saving a description and setting fneditmode to 1.  NOTE: unauthenticated remote attackers can exploit this by leveraging a cookie manipulation issue.",
  "id": "GHSA-g4p4-g8hm-9prr",
  "modified": "2022-05-01T18:36:38Z",
  "published": "2022-05-01T18:36:38Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2007-5772"
    },
    {
      "type": "WEB",
      "url": "https://www.exploit-db.com/exploits/4562"
    },
    {
      "type": "WEB",
      "url": "http://osvdb.org/43636"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/archive/1/482774/100/0/threaded"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-G4PF-3JVQ-2GCW

Vulnerability from github – Published: 2024-06-05 15:08 – Updated: 2024-06-05 15:08
VLAI
Summary
TYPO3 Remote Code Execution in third party library swiftmailer
Details

TYPO3 uses the package swiftmailer/swiftmailer for mail actions. This package is known to be vulnerable to Remote Code Execution.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "typo3/cms"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "6.2.0"
            },
            {
              "fixed": "6.2.30"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "typo3/cms"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "7.6.0"
            },
            {
              "fixed": "7.6.15"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "typo3/cms"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "8.0.0"
            },
            {
              "fixed": "8.5.1"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2024-06-05T15:08:03Z",
    "nvd_published_at": null,
    "severity": "HIGH"
  },
  "details": "TYPO3 uses the package swiftmailer/swiftmailer for mail actions. This package is known to be vulnerable to Remote Code Execution.",
  "id": "GHSA-g4pf-3jvq-2gcw",
  "modified": "2024-06-05T15:08:03Z",
  "published": "2024-06-05T15:08:03Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/FriendsOfPHP/security-advisories/blob/master/typo3/cms/2017-01-03-1.yaml"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/TYPO3/typo3"
    },
    {
      "type": "WEB",
      "url": "https://typo3.org/security/advisory/typo3-core-sa-2017-001"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [],
  "summary": "TYPO3 Remote Code Execution in third party library swiftmailer"
}

GHSA-G4PW-3X2F-HXMX

Vulnerability from github – Published: 2022-05-17 00:45 – Updated: 2022-05-17 00:45
VLAI
Details

Multiple eval injection vulnerabilities in itpm_estimate.php in Yoxel 1.23beta and earlier allow remote authenticated users to execute arbitrary PHP code via the proj_id parameter.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2008-5071"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2008-11-14T18:07:00Z",
    "severity": "HIGH"
  },
  "details": "Multiple eval injection vulnerabilities in itpm_estimate.php in Yoxel 1.23beta and earlier allow remote authenticated users to execute arbitrary PHP code via the proj_id parameter.",
  "id": "GHSA-g4pw-3x2f-hxmx",
  "modified": "2022-05-17T00:45:28Z",
  "published": "2022-05-17T00:45:28Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2008-5071"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/45488"
    },
    {
      "type": "WEB",
      "url": "https://www.exploit-db.com/exploits/6606"
    },
    {
      "type": "WEB",
      "url": "http://securityreason.com/securityalert/4591"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/31448"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-G4R7-86GM-PGQC

Vulnerability from github – Published: 2024-09-18 15:30 – Updated: 2024-09-18 17:39
VLAI
Summary
sqlitedict insecure deserialization vulnerability
Details

Insecure deserialization in sqlitedict up to v2.1.0 allows attackers to execute arbitrary code.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "PyPI",
        "name": "sqlitedict"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "last_affected": "2.1.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2024-35515"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-502",
      "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2024-09-18T17:39:11Z",
    "nvd_published_at": "2024-09-18T15:15:14Z",
    "severity": "HIGH"
  },
  "details": "Insecure deserialization in sqlitedict up to v2.1.0 allows attackers to execute arbitrary code.",
  "id": "GHSA-g4r7-86gm-pgqc",
  "modified": "2024-09-18T17:39:11Z",
  "published": "2024-09-18T15:30:52Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-35515"
    },
    {
      "type": "WEB",
      "url": "https://github.com/piskvorky/sqlitedict/issues/174"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/piskvorky/sqlitedict"
    },
    {
      "type": "WEB",
      "url": "https://github.com/piskvorky/sqlitedict?tab=readme-ov-file#serialization"
    },
    {
      "type": "WEB",
      "url": "https://wha13.github.io/2024/06/13/mfcve"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    },
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N",
      "type": "CVSS_V4"
    }
  ],
  "summary": "sqlitedict insecure deserialization vulnerability"
}

Mitigation
Architecture and Design

Strategy: Refactoring

Refactor your program so that you do not have to dynamically generate code.

Mitigation
Architecture and Design
  • Run your code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which code can be executed by your product.
  • Examples include the Unix chroot jail and AppArmor. In general, managed code may provide some protection.
  • This may not be a feasible solution, and it only limits the impact to the operating system; the rest of your application may still be subject to compromise.
  • Be careful to avoid CWE-243 and other weaknesses related to jails.
Mitigation MIT-5
Implementation

Strategy: Input Validation

  • Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does.
  • When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue."
  • Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
  • To reduce the likelihood of code injection, use stringent allowlists that limit which constructs are allowed. If you are dynamically constructing code that invokes a function, then verifying that the input is alphanumeric might be insufficient. An attacker might still be able to reference a dangerous function that you did not intend to allow, such as system(), exec(), or exit().
Mitigation
Testing

Use dynamic tools and techniques that interact with the product using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The product's operation may slow down, but it should not become unstable, crash, or generate incorrect results.

Mitigation MIT-32
Operation

Strategy: Compilation or Build Hardening

Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's "-T" switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).

Mitigation MIT-32
Operation

Strategy: Environment Hardening

Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's "-T" switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).

Mitigation
Implementation

For Python programs, it is frequently encouraged to use the ast.literal_eval() function instead of eval, since it is intentionally designed to avoid executing code. However, an adversary could still cause excessive memory or stack consumption via deeply nested structures [REF-1372], so the python documentation discourages use of ast.literal_eval() on untrusted data [REF-1373].

CAPEC-242: Code Injection

An adversary exploits a weakness in input validation on the target to inject new code into that which is currently executing. This differs from code inclusion in that code inclusion involves the addition or replacement of a reference to a code file, which is subsequently loaded by the target and used as part of the code of some application.

CAPEC-35: Leverage Executable Code in Non-Executable Files

An attack of this type exploits a system's trust in configuration and resource files. When the executable loads the resource (such as an image file or configuration file) the attacker has modified the file to either execute malicious code directly or manipulate the target process (e.g. application server) to execute based on the malicious configuration parameters. Since systems are increasingly interrelated mashing up resources from local and remote sources the possibility of this attack occurring is high.

CAPEC-77: Manipulating User-Controlled Variables

This attack targets user controlled variables (DEBUG=1, PHP Globals, and So Forth). An adversary can override variables leveraging user-supplied, untrusted query variables directly used on the application server without any data sanitization. In extreme cases, the adversary can change variables controlling the business logic of the application. For instance, in languages like PHP, a number of poorly set default configurations may allow the user to override variables.