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.

8269 vulnerabilities reference this CWE, most recent first.

GHSA-GQMG-CFHG-MW2Q

Vulnerability from github – Published: 2026-06-15 21:30 – Updated: 2026-06-16 15:33
VLAI
Details

An issue in the loopback request handling component of fossar selfoss v2.20-SNAPSHOT allows attackers to execute arbitrary commands and obtain sensitive information via supplying a crafted HTTP request.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2026-50872"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2026-06-15T20:16:29Z",
    "severity": "CRITICAL"
  },
  "details": "An issue in the loopback request handling component of fossar selfoss v2.20-SNAPSHOT allows attackers to execute arbitrary commands and obtain sensitive information via supplying a crafted HTTP request.",
  "id": "GHSA-gqmg-cfhg-mw2q",
  "modified": "2026-06-16T15:33:47Z",
  "published": "2026-06-15T21:30:40Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-50872"
    },
    {
      "type": "WEB",
      "url": "https://gist.github.com/pyuysig/272bf96c028ed45ad010b7c75937c914"
    }
  ],
  "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-GQMV-WGQ3-W6P3

Vulnerability from github – Published: 2025-06-16 18:32 – Updated: 2025-08-21 21:32
VLAI
Details

The chat feature within Remote Support (RS) and Privileged Remote Access (PRA) is vulnerable to a Server-Side Template Injection vulnerability which can lead to remote code execution.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-5309"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-06-16T17:15:29Z",
    "severity": "HIGH"
  },
  "details": "The chat feature within Remote Support (RS) and Privileged Remote Access (PRA) is vulnerable to a Server-Side Template Injection vulnerability which can lead to remote code execution.",
  "id": "GHSA-gqmv-wgq3-w6p3",
  "modified": "2025-08-21T21:32:01Z",
  "published": "2025-06-16T18:32:20Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-5309"
    },
    {
      "type": "WEB",
      "url": "https://www.beyondtrust.com/trust-center/security-advisories/bt25-04"
    }
  ],
  "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"
    },
    {
      "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/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"
    }
  ]
}

GHSA-GQQM-564F-VVXQ

Vulnerability from github – Published: 2022-05-14 01:57 – Updated: 2023-08-16 09:30
VLAI
Summary
Arbitrary code execution in Apache Struts 2
Details

Apache Struts 2 before 2.3.14.3 allows remote attackers to execute arbitrary OGNL code via a request with a crafted action name that is not properly handled during wildcard matching, a different vulnerability than CVE-2013-2135.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Maven",
        "name": "org.apache.struts:struts2-core"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "2.0.0"
            },
            {
              "fixed": "2.3.14.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Maven",
        "name": "org.apache.struts.xwork:xwork-core"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "2.0.0"
            },
            {
              "fixed": "2.3.14.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2013-2134"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2022-11-03T21:07:40Z",
    "nvd_published_at": "2013-07-16T18:55:00Z",
    "severity": "HIGH"
  },
  "details": "Apache Struts 2 before 2.3.14.3 allows remote attackers to execute arbitrary OGNL code via a request with a crafted action name that is not properly handled during wildcard matching, a different vulnerability than CVE-2013-2135.",
  "id": "GHSA-gqqm-564f-vvxq",
  "modified": "2023-08-16T09:30:57Z",
  "published": "2022-05-14T01:57:02Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2013-2134"
    },
    {
      "type": "WEB",
      "url": "https://github.com/apache/struts/commit/01e6b251b4db78bfb7971033652e81d1af4cb3e0"
    },
    {
      "type": "WEB",
      "url": "https://github.com/apache/struts/commit/041206d2a693d02c0cb2e72765275e55ba14049f"
    },
    {
      "type": "WEB",
      "url": "https://github.com/apache/struts/commit/113c47082c09818bcef65acc436a2d0c7c47aa6c"
    },
    {
      "type": "WEB",
      "url": "https://github.com/apache/struts/commit/54e5c912ebd9a1599bfcf7a719da17c28127bbe3"
    },
    {
      "type": "WEB",
      "url": "https://github.com/apache/struts/commit/711cf0201cdd319a38cf29238913312355db29ba"
    },
    {
      "type": "WEB",
      "url": "https://github.com/apache/struts/commit/8b4fc81daeea3834bcbf73de5f48d0021917aa37"
    },
    {
      "type": "WEB",
      "url": "https://github.com/apache/struts/commit/cfb6e9afbae320a4dd5bdd655154ab9fe5a92c16"
    },
    {
      "type": "WEB",
      "url": "https://cwiki.apache.org/confluence/display/WW/S2-015"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/apache/struts"
    },
    {
      "type": "WEB",
      "url": "https://issues.apache.org/jira/browse/WW-4090"
    },
    {
      "type": "WEB",
      "url": "https://issues.apache.org/jira/browse/WW-4094"
    },
    {
      "type": "WEB",
      "url": "https://issues.apache.org/jira/browse/WW-4095"
    },
    {
      "type": "WEB",
      "url": "https://web.archive.org/web/20140226173351/http://www.securityfocus.com/bid/60346"
    },
    {
      "type": "WEB",
      "url": "https://web.archive.org/web/20140410223942/http://www.securityfocus.com/bid/64758"
    },
    {
      "type": "WEB",
      "url": "http://security.gentoo.org/glsa/glsa-201409-04.xml"
    },
    {
      "type": "WEB",
      "url": "http://struts.apache.org/development/2.x/docs/s2-015.html"
    },
    {
      "type": "WEB",
      "url": "http://www.oracle.com/technetwork/topics/security/cpujan2014-1972949.html"
    },
    {
      "type": "WEB",
      "url": "http://www.oracle.com/technetwork/topics/security/cpuoct2013-1899837.html"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [],
  "summary": "Arbitrary code execution in Apache Struts 2"
}

GHSA-GQRG-CV49-5PC6

Vulnerability from github – Published: 2022-05-14 02:35 – Updated: 2022-05-14 02:35
VLAI
Details

Microsoft Publisher 2003 SP3 allows remote attackers to execute arbitrary code via a crafted Publisher file that leverages incorrect handling of values in memory, aka "Publisher Invalid Pointer Vulnerability."

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2011-3411"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2011-12-14T00:55:00Z",
    "severity": "HIGH"
  },
  "details": "Microsoft Publisher 2003 SP3 allows remote attackers to execute arbitrary code via a crafted Publisher file that leverages incorrect handling of values in memory, aka \"Publisher Invalid Pointer Vulnerability.\"",
  "id": "GHSA-gqrg-cv49-5pc6",
  "modified": "2022-05-14T02:35:30Z",
  "published": "2022-05-14T02:35:30Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2011-3411"
    },
    {
      "type": "WEB",
      "url": "https://docs.microsoft.com/en-us/security-updates/securitybulletins/2011/ms11-091"
    },
    {
      "type": "WEB",
      "url": "https://oval.cisecurity.org/repository/search/definition/oval%3Aorg.mitre.oval%3Adef%3A14346"
    },
    {
      "type": "WEB",
      "url": "http://www.kb.cert.org/vuls/id/361441"
    },
    {
      "type": "WEB",
      "url": "http://www.securitytracker.com/id?1026414"
    },
    {
      "type": "WEB",
      "url": "http://www.us-cert.gov/cas/techalerts/TA11-347A.html"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-GQV4-JGMQ-RFXP

Vulnerability from github – Published: 2022-05-17 01:49 – Updated: 2022-05-17 01:49
VLAI
Details

Eval injection vulnerability in zp-core/zp-extensions/viewer_size_image.php in ZENphoto 1.4.2, when the viewer_size_image plugin is enabled, allows remote attackers to execute arbitrary PHP code via the viewer_size_image_saved cookie.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2012-0993"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2012-02-21T13:31:00Z",
    "severity": "MODERATE"
  },
  "details": "Eval injection vulnerability in zp-core/zp-extensions/viewer_size_image.php in ZENphoto 1.4.2, when the viewer_size_image plugin is enabled, allows remote attackers to execute arbitrary PHP code via the viewer_size_image_saved cookie.",
  "id": "GHSA-gqv4-jgmq-rfxp",
  "modified": "2022-05-17T01:49:12Z",
  "published": "2022-05-17T01:49:12Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2012-0993"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/73081"
    },
    {
      "type": "WEB",
      "url": "https://www.htbridge.ch/advisory/HTB23070"
    },
    {
      "type": "WEB",
      "url": "http://archives.neohapsis.com/archives/bugtraq/2012-02/0037.html"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/47875"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/51916"
    },
    {
      "type": "WEB",
      "url": "http://www.zenphoto.org/news/zenphoto-1.4.2.1"
    },
    {
      "type": "WEB",
      "url": "http://www.zenphoto.org/trac/changeset/8994"
    },
    {
      "type": "WEB",
      "url": "http://www.zenphoto.org/trac/changeset/8995"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-GR4H-894Q-P7JP

Vulnerability from github – Published: 2022-05-04 00:28 – Updated: 2025-04-11 04:03
VLAI
Details

Horde 3.3.12, Horde Groupware 1.2.10, and Horde Groupware Webmail Edition 1.2.10, as distributed by FTP between November 2011 and February 2012, contains an externally introduced modification (Trojan Horse) in templates/javascript/open_calendar.js, which allows remote attackers to execute arbitrary PHP code.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2012-0209"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2012-09-25T22:55:00Z",
    "severity": "HIGH"
  },
  "details": "Horde 3.3.12, Horde Groupware 1.2.10, and Horde Groupware Webmail Edition 1.2.10, as distributed by FTP between November 2011 and February 2012, contains an externally introduced modification (Trojan Horse) in templates/javascript/open_calendar.js, which allows remote attackers to execute arbitrary PHP code.",
  "id": "GHSA-gr4h-894q-p7jp",
  "modified": "2025-04-11T04:03:01Z",
  "published": "2022-05-04T00:28:49Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2012-0209"
    },
    {
      "type": "WEB",
      "url": "https://bugzilla.redhat.com/show_bug.cgi?id=790877"
    },
    {
      "type": "WEB",
      "url": "http://dev.horde.org/h/jonah/stories/view.php?channel_id=1\u0026id=155"
    },
    {
      "type": "WEB",
      "url": "http://eromang.zataz.com/2012/02/15/cve-2012-0209-horde-backdoor-analysis"
    },
    {
      "type": "WEB",
      "url": "http://lists.horde.org/archives/announce/2012/000751.html"
    },
    {
      "type": "WEB",
      "url": "http://packetstormsecurity.org/files/109874/Horde-3.3.12-Backdoor-Arbitrary-PHP-Code-Execution.html"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-GR67-7V65-6XCW

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

Cacti before 1.0.0 allows remote authenticated users to conduct PHP object injection attacks and execute arbitrary PHP code via a crafted serialized object, related to calling unserialize(stripslashes()).

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2014-4000"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2017-11-15T16:29:00Z",
    "severity": "HIGH"
  },
  "details": "Cacti before 1.0.0 allows remote authenticated users to conduct PHP object injection attacks and execute arbitrary PHP code via a crafted serialized object, related to calling unserialize(stripslashes()).",
  "id": "GHSA-gr67-7v65-6xcw",
  "modified": "2022-05-17T00:20:02Z",
  "published": "2022-05-17T00:20:02Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2014-4000"
    },
    {
      "type": "WEB",
      "url": "https://forums.cacti.net/viewtopic.php?f=4\u0026t=56794"
    },
    {
      "type": "WEB",
      "url": "https://security-tracker.debian.org/tracker/CVE-2014-4000"
    },
    {
      "type": "WEB",
      "url": "https://security.gentoo.org/glsa/201711-10"
    },
    {
      "type": "WEB",
      "url": "https://www.cacti.net/release_notes_1_0_0.php"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-GR6F-XX69-HRGQ

Vulnerability from github – Published: 2026-03-30 21:31 – Updated: 2026-04-01 21:30
VLAI
Details

In its design for automatic terminal command execution, HAI Build Code Generator offers two options: Execute safe commands and Execute all commands. The description for the former states that commands determined by the model to be safe will be automatically executed, whereas if the model judges a command to be potentially destructive, it still requires user approval. However, this design is highly susceptible to prompt injection attacks. An attacker can employ a generic template to wrap any malicious command and mislead the model into misclassifying it as a 'safe' command, thereby bypassing the user approval requirement and resulting in arbitrary command execution.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2026-30308"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2026-03-30T21:17:09Z",
    "severity": "CRITICAL"
  },
  "details": "In its design for automatic terminal command execution, HAI Build Code Generator offers two options: Execute safe commands and Execute all commands. The description for the former states that commands determined by the model to be safe will be automatically executed, whereas if the model judges a command to be potentially destructive, it still requires user approval. However, this design is highly susceptible to prompt injection attacks. An attacker can employ a generic template to wrap any malicious command and mislead the model into misclassifying it as a \u0027safe\u0027 command, thereby bypassing the user approval requirement and resulting in arbitrary command execution.",
  "id": "GHSA-gr6f-xx69-hrgq",
  "modified": "2026-04-01T21:30:26Z",
  "published": "2026-03-30T21:31:04Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-30308"
    },
    {
      "type": "WEB",
      "url": "https://github.com/Secsys-FDU/LLM-Tool-Calling-CVEs/issues/10"
    },
    {
      "type": "WEB",
      "url": "https://github.com/presidio-oss/hai-build"
    }
  ],
  "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-GR9C-H5PV-HGRP

Vulnerability from github – Published: 2022-05-14 02:26 – Updated: 2022-05-14 02:26
VLAI
Details

Microsoft .NET Framework 2.0 SP2, 3.5, 3.5.1, 4.5.2, 4.6, and 4.6.1 does not prevent recursive compilation of XSLT transforms, which allows remote attackers to cause a denial of service (performance degradation) via crafted XSLT data, aka ".NET Framework Stack Overflow Denial of Service Vulnerability."

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2016-0033"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2016-02-10T11:59:00Z",
    "severity": "HIGH"
  },
  "details": "Microsoft .NET Framework 2.0 SP2, 3.5, 3.5.1, 4.5.2, 4.6, and 4.6.1 does not prevent recursive compilation of XSLT transforms, which allows remote attackers to cause a denial of service (performance degradation) via crafted XSLT data, aka \".NET Framework Stack Overflow Denial of Service Vulnerability.\"",
  "id": "GHSA-gr9c-h5pv-hgrp",
  "modified": "2022-05-14T02:26:19Z",
  "published": "2022-05-14T02:26:19Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2016-0033"
    },
    {
      "type": "WEB",
      "url": "https://docs.microsoft.com/en-us/security-updates/securitybulletins/2016/ms16-019"
    },
    {
      "type": "WEB",
      "url": "http://www.securitytracker.com/id/1034983"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-GR9W-68PR-98WP

Vulnerability from github – Published: 2024-08-24 12:30 – Updated: 2024-08-24 12:30
VLAI
Details

The Image Hotspot by DevVN plugin for WordPress is vulnerable to PHP Object Injection in all versions up to, and including, 1.2.5 via deserialization of untrusted input in the 'devvn_ihotspot_shortcode_func' function. This makes it possible for authenticated attackers, with Author-level access and above, to inject a PHP Object. No known POP chain is present in the vulnerable software. If a POP chain is present via an additional plugin or theme installed on the target system, it could allow the attacker to delete arbitrary files, retrieve sensitive data, or execute code.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2024-7656"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2024-08-24T12:15:04Z",
    "severity": "HIGH"
  },
  "details": "The Image Hotspot by DevVN plugin for WordPress is vulnerable to PHP Object Injection in all versions up to, and including, 1.2.5 via deserialization of untrusted input in the \u0027devvn_ihotspot_shortcode_func\u0027 function. This makes it possible for authenticated attackers, with Author-level access and above, to inject a PHP Object. No known POP chain is present in the vulnerable software. If a POP chain is present via an additional plugin or theme installed on the target system, it could allow the attacker to delete arbitrary files, retrieve sensitive data, or execute code.",
  "id": "GHSA-gr9w-68pr-98wp",
  "modified": "2024-08-24T12:30:46Z",
  "published": "2024-08-24T12:30:46Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-7656"
    },
    {
      "type": "WEB",
      "url": "https://plugins.trac.wordpress.org/browser/devvn-image-hotspot/trunk/admin/inc/add_shortcode_devvn_ihotspot.php#L16"
    },
    {
      "type": "WEB",
      "url": "https://plugins.trac.wordpress.org/changeset/3139899"
    },
    {
      "type": "WEB",
      "url": "https://www.wordfence.com/threat-intel/vulnerabilities/id/624bdb9e-6c50-4a00-9a04-1a32c938d48b?source=cve"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

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.