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.

8344 vulnerabilities reference this CWE, most recent first.

GHSA-3JFQ-4F5C-MP6V

Vulnerability from github – Published: 2025-01-16 03:30 – Updated: 2025-01-16 15:32
VLAI
Details

RE11S v1.11 was discovered to contain a command injection vulnerability via the component /goform/formAccept.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-22912"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-77",
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-01-16T03:15:06Z",
    "severity": "CRITICAL"
  },
  "details": "RE11S v1.11 was discovered to contain a command injection vulnerability via the component /goform/formAccept.",
  "id": "GHSA-3jfq-4f5c-mp6v",
  "modified": "2025-01-16T15:32:10Z",
  "published": "2025-01-16T03:30:31Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-22912"
    },
    {
      "type": "WEB",
      "url": "https://github.com/xyqer1/RE11S_1.11-formAccept-CommandInjection"
    },
    {
      "type": "WEB",
      "url": "https://www.edimax.com/edimax/global"
    },
    {
      "type": "WEB",
      "url": "http://re11s.com"
    }
  ],
  "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-3JG7-5HV4-35JM

Vulnerability from github – Published: 2022-05-14 01:51 – Updated: 2022-05-14 01:51
VLAI
Details

Code injection in the /ui/login form Language parameter in Epicentro E_7.3.2+ allows attackers to execute JavaScript code by making a user issue a manipulated POST request.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2018-7633"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2018-10-09T22:29:00Z",
    "severity": "CRITICAL"
  },
  "details": "Code injection in the /ui/login form Language parameter in Epicentro E_7.3.2+ allows attackers to execute JavaScript code by making a user issue a manipulated POST request.",
  "id": "GHSA-3jg7-5hv4-35jm",
  "modified": "2022-05-14T01:51:33Z",
  "published": "2022-05-14T01:51:33Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2018-7633"
    },
    {
      "type": "WEB",
      "url": "https://fschallock.wordpress.com/2018/10/08/cve-2018-7633-script-injection-in-the-login-form-language-parameter-of-adb-firmware-epicentro-7-3-2"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-3JGV-PFQJ-V626

Vulnerability from github – Published: 2024-04-26 06:30 – Updated: 2024-07-03 18:36
VLAI
Details

Server-Side Template Injection (SSTI) vulnerability in inducer relate before v.2024.1 allows a remote attacker to execute arbitrary code via a crafted payload to the Batch-Issue Exam Tickets function.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2024-32406"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-1336",
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2024-04-26T04:15:09Z",
    "severity": "HIGH"
  },
  "details": "Server-Side Template Injection (SSTI) vulnerability in inducer relate before v.2024.1 allows a remote attacker to execute arbitrary code via a crafted payload to the Batch-Issue Exam Tickets function.",
  "id": "GHSA-3jgv-pfqj-v626",
  "modified": "2024-07-03T18:36:57Z",
  "published": "2024-04-26T06:30:34Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-32406"
    },
    {
      "type": "WEB",
      "url": "https://packetstormsecurity.com/files/178251/Relate-Learning-And-Teaching-System-SSTI-Remote-Code-Execution.html"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-3JM4-C6QF-JRH3

Vulnerability from github – Published: 2024-10-24 17:58 – Updated: 2024-12-04 22:18
VLAI
Summary
OpenRefine's PreviewExpressionCommand, which is eval, lacks protection against cross-site request forgery (CSRF)
Details

Summary

Lack of CSRF protection on the preview-expression command means that visiting a malicious website could cause an attacker-controlled expression to be executed. The expression can contain arbitrary Clojure or Python code.

The attacker must know a valid project ID of a project that contains at least one row.

Details

The com.google.refine.commands.expr.PreviewExpressionCommand class contains the following comment:

/**
 * The command uses POST but does not actually modify any state so it does not require CSRF.
 */

However, this appears to be false (or no longer true). The expression being previewed (executed) can be written in GREL, Python, or Clojure. Since there are no restrictions on what code can be executed, the expression can do anything the user running OpenRefine can do. For instance, the following expressions start a calculator:

clojure:(.exec (Runtime/getRuntime) "gnome-calculator")
jython:import os;os.system("gnome-calculator")

The lack of restrictions on expressions is arguably not a problem if the user is typing their own expressions into OpenRefine: they could have just as well typed them into Clojure or Python directly. However, since the preview-expression command does not check for a CSRF token, the expression can actually come from a HTML form submitted by a different origin, including arbitrary websites.

Issue #2164 suggested adding CSRF protection to all endpoints, but this endpoint was skipped (and the above comment added) in the associated PR #2182.

PoC

An example "malicious" page is at https://wandernauta.nl/or/ (of course, actual malicious pages would not wait for the victim to press the submit button).

The following curl command (substituting the project ID) also demonstrates the issue:

curl -d project=123456789 -d cellIndex=1 -d rowIndices='[0]' -d 'expression=clojure:(.exec (Runtime/getRuntime) "gnome-calculator")' http://localhost:3333/command/core/preview-expression/

Impact

CSRF into remote code execution, provided the attacker knows at least one project ID in the victim's workspace and can convince the victim to open a malicious webpage.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Maven",
        "name": "org.openrefine:main"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "3.8.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2024-47879"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-352",
      "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2024-10-24T17:58:53Z",
    "nvd_published_at": "2024-10-24T21:15:12Z",
    "severity": "HIGH"
  },
  "details": "### Summary\n\nLack of CSRF protection on the `preview-expression` command means that visiting a malicious website could cause an attacker-controlled expression to be executed. The expression can contain arbitrary Clojure or Python code.\n\nThe attacker must know a valid project ID of a project that contains at least one row.\n\n### Details\n\nThe `com.google.refine.commands.expr.PreviewExpressionCommand` class contains the following comment:\n```\n/**\n * The command uses POST but does not actually modify any state so it does not require CSRF.\n */\n```\n\nHowever, this appears to be false (or no longer true). The expression being previewed (executed) can be written in GREL, Python, or Clojure. Since there are no restrictions on what code can be executed, the expression can do anything the user running OpenRefine can do. For instance, the following expressions start a calculator:\n\n```\nclojure:(.exec (Runtime/getRuntime) \"gnome-calculator\")\n```\n\n```\njython:import os;os.system(\"gnome-calculator\")\n```\n\nThe lack of restrictions on expressions is arguably not a problem if the user is typing their own expressions into OpenRefine: they could have just as well typed them into Clojure or Python directly. However, since the `preview-expression` command does not check for a CSRF token, the expression can actually come from a HTML form submitted by a different origin, including arbitrary websites.\n\nIssue #2164 suggested adding CSRF protection to all endpoints, but this endpoint was skipped (and the above comment added) in the associated PR #2182.\n\n### PoC\n\nAn example \"malicious\" page is at https://wandernauta.nl/or/ (of course, actual malicious pages would not wait for the victim to press the submit button).\n\nThe following curl command (substituting the project ID) also demonstrates the issue:\n\n```sh\ncurl -d project=123456789 -d cellIndex=1 -d rowIndices=\u0027[0]\u0027 -d \u0027expression=clojure:(.exec (Runtime/getRuntime) \"gnome-calculator\")\u0027 http://localhost:3333/command/core/preview-expression/\n```\n\n### Impact\n\nCSRF into remote code execution, provided the attacker knows at least one project ID in the victim\u0027s workspace and can convince the victim to open a malicious webpage.",
  "id": "GHSA-3jm4-c6qf-jrh3",
  "modified": "2024-12-04T22:18:02Z",
  "published": "2024-10-24T17:58:53Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/OpenRefine/OpenRefine/security/advisories/GHSA-3jm4-c6qf-jrh3"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-47879"
    },
    {
      "type": "WEB",
      "url": "https://github.com/OpenRefine/OpenRefine/commit/090924ca923489b6c94397cf1f5df7f7f78f0126"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/OpenRefine/OpenRefine"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:L",
      "type": "CVSS_V3"
    }
  ],
  "summary": "OpenRefine\u0027s PreviewExpressionCommand, which is eval, lacks protection against cross-site request forgery (CSRF)"
}

GHSA-3JPP-JWVR-524V

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

Eval injection vulnerability in the ReplaceListVars function in the template parser in e/class/connect.php in EmpireCMS 6.6 allows user-assisted remote attackers to execute arbitrary PHP code via a crafted template.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2012-5777"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2012-11-16T00:55:00Z",
    "severity": "MODERATE"
  },
  "details": "Eval injection vulnerability in the ReplaceListVars function in the template parser in e/class/connect.php in EmpireCMS 6.6 allows user-assisted remote attackers to execute arbitrary PHP code via a crafted template.",
  "id": "GHSA-3jpp-jwvr-524v",
  "modified": "2022-05-17T01:38:56Z",
  "published": "2022-05-17T01:38:56Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2012-5777"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/79779"
    },
    {
      "type": "WEB",
      "url": "http://archives.neohapsis.com/archives/bugtraq/2012-11/0027.html"
    },
    {
      "type": "WEB",
      "url": "http://packetstormsecurity.com/files/117902/EmpireCMS-6.6-PHP-Code-Execution.html"
    },
    {
      "type": "WEB",
      "url": "http://packetstormsecurity.org/files/117902/EmpireCMS-6.6-PHP-Code-Execution.html"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/56406"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-3JQ6-FX9W-PJQJ

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

CRLF injection vulnerability in Microsoft Internet Explorer 5 and 6 allows remote attackers to execute arbitrary FTP commands via an ftp:// URL that contains a URL-encoded CRLF (%0D%0A) before the FTP command, which causes the commands to be inserted into an authenticated FTP connection established earlier in the same browser session, as demonstrated using a DELE command, a variant or possibly a regression of CVE-2004-1166. NOTE: a trailing "//" can force Internet Explorer to try to reuse an existing authenticated connection.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2008-1368"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2008-03-18T00:44:00Z",
    "severity": "MODERATE"
  },
  "details": "CRLF injection vulnerability in Microsoft Internet Explorer 5 and 6 allows remote attackers to execute arbitrary FTP commands via an ftp:// URL that contains a URL-encoded CRLF (%0D%0A) before the FTP command, which causes the commands to be inserted into an authenticated FTP connection established earlier in the same browser session, as demonstrated using a DELE command, a variant or possibly a regression of CVE-2004-1166.  NOTE: a trailing \"//\" can force Internet Explorer to try to reuse an existing authenticated connection.",
  "id": "GHSA-3jq6-fx9w-pjqj",
  "modified": "2022-05-01T23:39:31Z",
  "published": "2022-05-01T23:39:31Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2008-1368"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/29346"
    },
    {
      "type": "WEB",
      "url": "http://securityreason.com/securityalert/3750"
    },
    {
      "type": "WEB",
      "url": "http://www.rapid7.com/advisories/R7-0032.jsp"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/archive/1/489500/100/0/threaded"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/28208"
    },
    {
      "type": "WEB",
      "url": "http://www.vupen.com/english/advisories/2008/0870"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-3JQV-HHHV-7WP5

Vulnerability from github – Published: 2022-05-01 07:14 – Updated: 2022-05-01 07:14
VLAI
Details

PHP remote file inclusion vulnerability in administrator/components/com_mgm/help.mgm.php in Mambo Gallery Manager (MGM) 0.95r2 and earlier for Mambo 4.5 allows remote attackers to execute arbitrary PHP code via a URL in the mosConfig_absolute_path parameter.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2006-3980"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2006-08-05T00:04:00Z",
    "severity": "MODERATE"
  },
  "details": "PHP remote file inclusion vulnerability in administrator/components/com_mgm/help.mgm.php in Mambo Gallery Manager (MGM) 0.95r2 and earlier for Mambo 4.5 allows remote attackers to execute arbitrary PHP code via a URL in the mosConfig_absolute_path parameter.",
  "id": "GHSA-3jqv-hhhv-7wp5",
  "modified": "2022-05-01T07:14:12Z",
  "published": "2022-05-01T07:14:12Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2006-3980"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/28072"
    },
    {
      "type": "WEB",
      "url": "https://www.exploit-db.com/exploits/2084"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/21268"
    },
    {
      "type": "WEB",
      "url": "http://securityreason.com/securityalert/1322"
    },
    {
      "type": "WEB",
      "url": "http://www.osvdb.org/27650"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/archive/1/441533/100/0/threaded"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/19224"
    },
    {
      "type": "WEB",
      "url": "http://www.vupen.com/english/advisories/2006/3054"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-3JXQ-4Q7M-7PFC

Vulnerability from github – Published: 2026-05-12 18:30 – Updated: 2026-05-13 18:30
VLAI
Details

The _load_model() function in the neural_magic_training.py script of the optimate project in commit a6d302f912b481c94370811af6b11402f51d377f (2024-07-21) allows arbitrary code execution. When a user supplies a directory path via the --model command-line argument, the function reads a module.py file from that directory and executes its contents directly using Python's exec() function. This design does not validate or sanitize the file's content, allowing an attacker who controls the input directory to execute arbitrary Python code in the context of the process running the script.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2026-31217"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2026-05-12T16:16:13Z",
    "severity": "CRITICAL"
  },
  "details": "The _load_model() function in the neural_magic_training.py script of the optimate project in commit a6d302f912b481c94370811af6b11402f51d377f (2024-07-21) allows arbitrary code execution. When a user supplies a directory path via the --model command-line argument, the function reads a module.py file from that directory and executes its contents directly using Python\u0027s exec() function. This design does not validate or sanitize the file\u0027s content, allowing an attacker who controls the input directory to execute arbitrary Python code in the context of the process running the script.",
  "id": "GHSA-3jxq-4q7m-7pfc",
  "modified": "2026-05-13T18:30:41Z",
  "published": "2026-05-12T18:30:37Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-31217"
    },
    {
      "type": "WEB",
      "url": "https://github.com/nebuly-ai/optimate"
    },
    {
      "type": "WEB",
      "url": "https://www.notion.so/CVE-2026-31217-35d1e13931888179ae40dea5258d2db9"
    }
  ],
  "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-3M2X-QQJ5-5R42

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

Multiple PHP remote file inclusion vulnerabilities in KCWiki 1.0 allow remote attackers to execute arbitrary PHP code via a URL in the page parameter to (1) minimal/wiki.php and (2) simplest/wiki.php.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2008-1170"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2008-03-05T23:44:00Z",
    "severity": "MODERATE"
  },
  "details": "Multiple PHP remote file inclusion vulnerabilities in KCWiki 1.0 allow remote attackers to execute arbitrary PHP code via a URL in the page parameter to (1) minimal/wiki.php and (2) simplest/wiki.php.",
  "id": "GHSA-3m2x-qqj5-5r42",
  "modified": "2022-05-01T23:37:21Z",
  "published": "2022-05-01T23:37:21Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2008-1170"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/40976"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/29218"
    },
    {
      "type": "WEB",
      "url": "http://securityreason.com/securityalert/3714"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/archive/1/489024/100/0/threaded"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/28074"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-3M3M-Q3HW-6QQ6

Vulnerability from github – Published: 2024-05-14 15:32 – Updated: 2026-04-02 21:31
VLAI
Details

The issue was addressed with improved checks. This issue is fixed in iTunes 12.13.2 for Windows. Parsing a file may lead to an unexpected app termination or arbitrary code execution.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2024-27793"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2024-05-14T15:13:02Z",
    "severity": "MODERATE"
  },
  "details": "The issue was addressed with improved checks. This issue is fixed in iTunes 12.13.2 for Windows. Parsing a file may lead to an unexpected app termination or arbitrary code execution.",
  "id": "GHSA-3m3m-q3hw-6qq6",
  "modified": "2026-04-02T21:31:39Z",
  "published": "2024-05-14T15:32:53Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-27793"
    },
    {
      "type": "WEB",
      "url": "https://support.apple.com/en-us/120897"
    },
    {
      "type": "WEB",
      "url": "https://support.apple.com/en-us/HT214099"
    },
    {
      "type": "WEB",
      "url": "https://support.apple.com/kb/HT214099"
    },
    {
      "type": "WEB",
      "url": "http://seclists.org/fulldisclosure/2024/May/8"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:L",
      "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.