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.

8378 vulnerabilities reference this CWE, most recent first.

GHSA-5CMG-8M8P-WHMJ

Vulnerability from github – Published: 2022-05-17 00:36 – Updated: 2024-04-25 21:27
VLAI
Summary
GeniXCMS arbitrary PHP code execution
Details

In the Upload Modules page in GeniXCMS 1.1.4, remote authenticated users can execute arbitrary PHP code via a .php file in a ZIP archive of a module.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "genix/cms"
      },
      "versions": [
        "1.1.4"
      ]
    }
  ],
  "aliases": [
    "CVE-2017-14764"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2024-04-25T21:27:42Z",
    "nvd_published_at": "2017-09-27T08:29:00Z",
    "severity": "HIGH"
  },
  "details": "In the Upload Modules page in GeniXCMS 1.1.4, remote authenticated users can execute arbitrary PHP code via a .php file in a ZIP archive of a module.",
  "id": "GHSA-5cmg-8m8p-whmj",
  "modified": "2024-04-25T21:27:42Z",
  "published": "2022-05-17T00:36:05Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2017-14764"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/GeniXCMS/GeniXCMS"
    },
    {
      "type": "WEB",
      "url": "http://ph0rse.me/2017/09/21/GeniXCMS-1-1-4%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC-getshell"
    }
  ],
  "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"
    }
  ],
  "summary": "GeniXCMS arbitrary PHP code execution"
}

GHSA-5CPH-5V9Q-VH7G

Vulnerability from github – Published: 2026-02-16 18:31 – Updated: 2026-02-17 15:31
VLAI
Details

An issue in Visual Studio Code Extensions Markdown Preview Enhanced v0.8.18 allows attackers to execute arbitrary code via uploading a crafted .Md file.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-65716"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2026-02-16T16:19:17Z",
    "severity": "HIGH"
  },
  "details": "An issue in Visual Studio Code Extensions Markdown Preview Enhanced v0.8.18 allows attackers to execute arbitrary code via uploading a crafted .Md file.",
  "id": "GHSA-5cph-5v9q-vh7g",
  "modified": "2026-02-17T15:31:35Z",
  "published": "2026-02-16T18:31:28Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-65716"
    },
    {
      "type": "WEB",
      "url": "https://github.com/shd101wyy/markdown-preview-enhanced"
    },
    {
      "type": "WEB",
      "url": "https://www.ox.security/blog/cve-2025-65716-markdown-preview-enhanced-vscode-vulnerability"
    }
  ],
  "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"
    }
  ]
}

GHSA-5CVG-9PP5-MXCJ

Vulnerability from github – Published: 2023-04-07 15:30 – Updated: 2023-04-14 20:31
VLAI
Summary
Apache Airflow Hive Provider vulnerable to code injection
Details

Apache Software Foundation's Apache Airflow Hive Provider before 6.0.0 is vulnerable to improper control of generation of code.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "PyPI",
        "name": "apache-airflow-providers-apache-hive"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "6.0.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2023-28706"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2023-04-07T22:23:40Z",
    "nvd_published_at": "2023-04-07T15:15:00Z",
    "severity": "CRITICAL"
  },
  "details": "Apache Software Foundation\u0027s Apache Airflow Hive Provider before 6.0.0 is vulnerable to improper control of generation of code.",
  "id": "GHSA-5cvg-9pp5-mxcj",
  "modified": "2023-04-14T20:31:27Z",
  "published": "2023-04-07T15:30:38Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-28706"
    },
    {
      "type": "WEB",
      "url": "https://github.com/apache/airflow/pull/30212"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/apache/airflow"
    },
    {
      "type": "WEB",
      "url": "https://lists.apache.org/thread/dl20xxd51xvlx0zzc0wzgxfjwgtbbxo3"
    },
    {
      "type": "WEB",
      "url": "http://www.openwall.com/lists/oss-security/2023/04/07/2"
    }
  ],
  "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"
    }
  ],
  "summary": "Apache Airflow Hive Provider vulnerable to code injection"
}

GHSA-5CVX-CWPX-9RJH

Vulnerability from github – Published: 2023-11-09 21:30 – Updated: 2023-11-10 00:42
VLAI
Summary
Moodle Code Injection vulnerability
Details

In a shared hosting environment that has been misconfigured to allow access to other users' content, a Moodle user who also has direct access to the web server outside of the Moodle webroot could utilise a local file include to achieve remote code execution.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "moodle/moodle"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "4.3.0-beta"
            },
            {
              "fixed": "4.3.0-rc2"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "moodle/moodle"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "4.2.0"
            },
            {
              "fixed": "4.2.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "moodle/moodle"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "4.1.0"
            },
            {
              "fixed": "4.1.6"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "moodle/moodle"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "4.0.0"
            },
            {
              "fixed": "4.0.11"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "moodle/moodle"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "3.10.0"
            },
            {
              "fixed": "3.11.17"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "moodle/moodle"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "3.9.24"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2023-5550"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2023-11-10T00:42:36Z",
    "nvd_published_at": "2023-11-09T20:15:10Z",
    "severity": "MODERATE"
  },
  "details": "In a shared hosting environment that has been misconfigured to allow access to other users\u0027 content, a Moodle user who also has direct access to the web server outside of the Moodle webroot could utilise a local file include to achieve remote code execution.",
  "id": "GHSA-5cvx-cwpx-9rjh",
  "modified": "2023-11-10T00:42:36Z",
  "published": "2023-11-09T21:30:39Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-5550"
    },
    {
      "type": "WEB",
      "url": "https://github.com/moodle/moodle/commit/77766f9c8af8fc8d861d7ac09ce4e1f6e72faca7"
    },
    {
      "type": "WEB",
      "url": "https://bugzilla.redhat.com/show_bug.cgi?id=2243452"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/moodle/moodle"
    },
    {
      "type": "WEB",
      "url": "https://moodle.org/mod/forum/discuss.php?d=451591"
    },
    {
      "type": "WEB",
      "url": "http://git.moodle.org/gw?p=moodle.git\u0026a=search\u0026h=HEAD\u0026st=commit\u0026s=MDL-72249"
    }
  ],
  "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"
    }
  ],
  "summary": "Moodle Code Injection vulnerability"
}

GHSA-5CW4-VRV3-8QX9

Vulnerability from github – Published: 2023-10-30 03:30 – Updated: 2023-11-08 03:30
VLAI
Details

/api/v1/company/upload-logo in CompanyController.php in crater through 6.0.6 allows a superadmin to execute arbitrary PHP code by placing this code into an image/png IDAT chunk of a Company Logo image.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2023-46865"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2023-10-30T01:15:21Z",
    "severity": "HIGH"
  },
  "details": "/api/v1/company/upload-logo in CompanyController.php in crater through 6.0.6 allows a superadmin to execute arbitrary PHP code by placing this code into an image/png IDAT chunk of a Company Logo image.",
  "id": "GHSA-5cw4-vrv3-8qx9",
  "modified": "2023-11-08T03:30:32Z",
  "published": "2023-10-30T03:30:15Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-46865"
    },
    {
      "type": "WEB",
      "url": "https://github.com/crater-invoice/crater/issues/1267"
    },
    {
      "type": "WEB",
      "url": "https://github.com/crater-invoice/crater/pull/1271"
    },
    {
      "type": "WEB",
      "url": "https://github.com/asylumdx/Crater-CVE-2023-46865-RCE"
    },
    {
      "type": "WEB",
      "url": "https://notes.netbytesec.com/2023/11/post-auth-rce-in-crater-invoice.html"
    }
  ],
  "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-5CXG-299X-C7PC

Vulnerability from github – Published: 2025-05-12 18:31 – Updated: 2025-05-13 00:31
VLAI
Details

An issue in vvveb CMS v.1.0.6 allows a remote attacker to execute arbitrary code via the Plugin mechanism.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-44022"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-05-12T16:15:25Z",
    "severity": "CRITICAL"
  },
  "details": "An issue in vvveb CMS v.1.0.6 allows a remote attacker to execute arbitrary code via the Plugin mechanism.",
  "id": "GHSA-5cxg-299x-c7pc",
  "modified": "2025-05-13T00:31:12Z",
  "published": "2025-05-12T18:31:45Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-44022"
    },
    {
      "type": "WEB",
      "url": "https://github.com/givanz/Vvveb/issues/289"
    },
    {
      "type": "WEB",
      "url": "https://github.com/givanz/Vvveb/commit/dd74abcae88f658779f61338b9f4c123884eef0d"
    },
    {
      "type": "WEB",
      "url": "https://github.com/chimmeee/vulnerability-research/blob/main/CVE-2025-44022"
    }
  ],
  "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-5F2P-6VJV-2Q2M

Vulnerability from github – Published: 2022-05-17 04:56 – Updated: 2023-01-27 00:02
VLAI
Summary
Sup Code Injection vulnerability
Details

Sup before 0.13.2.1 and 0.14.x before 0.14.1.1 allows remote attackers to execute arbitrary commands via shell metacharacters in the filename of an email attachment.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "RubyGems",
        "name": "sup"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "0.13.2.1"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "RubyGems",
        "name": "sup"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0.14.0"
            },
            {
              "fixed": "0.14.1.1"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2013-4478"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2023-01-27T00:02:42Z",
    "nvd_published_at": "2013-12-07T20:55:00Z",
    "severity": "MODERATE"
  },
  "details": "Sup before 0.13.2.1 and 0.14.x before 0.14.1.1 allows remote attackers to execute arbitrary commands via shell metacharacters in the filename of an email attachment.",
  "id": "GHSA-5f2p-6vjv-2q2m",
  "modified": "2023-01-27T00:02:42Z",
  "published": "2022-05-17T04:56:46Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2013-4478"
    },
    {
      "type": "WEB",
      "url": "https://github.com/sup-heliotrope/sup/commit/8b46cdbfc14e07ca07d403aa28b0e7bc1c544785"
    },
    {
      "type": "WEB",
      "url": "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/sup/CVE-2013-4478.yml"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/sup-heliotrope/sup"
    },
    {
      "type": "WEB",
      "url": "https://web.archive.org/web/20140524005344/http://rubyforge.org/pipermail/sup-talk/2013-October/004996.html"
    },
    {
      "type": "WEB",
      "url": "https://web.archive.org/web/20140524012714/http://rubyforge.org/pipermail/sup-talk/2013-August/004993.html"
    },
    {
      "type": "WEB",
      "url": "http://rubyforge.org/pipermail/sup-talk/2013-August/004993.html"
    },
    {
      "type": "WEB",
      "url": "http://rubyforge.org/pipermail/sup-talk/2013-October/004996.html"
    },
    {
      "type": "WEB",
      "url": "http://www.debian.org/security/2012/dsa-2805"
    },
    {
      "type": "WEB",
      "url": "http://www.openwall.com/lists/oss-security/2013/10/30/2"
    },
    {
      "type": "WEB",
      "url": "http://www.phenoelit.org/stuff/whatsup.txt"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [],
  "summary": "Sup Code Injection vulnerability"
}

GHSA-5F2R-J5H2-8P7F

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

mapFiler.php in Mapbender 2.4 to 2.4.4 allows remote attackers to execute arbitrary PHP code via PHP code sequences in the factor parameter, which are not properly handled when accessing a filename that contains those sequences.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2008-0300"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2008-03-11T23:44:00Z",
    "severity": "MODERATE"
  },
  "details": "mapFiler.php in Mapbender 2.4 to 2.4.4 allows remote attackers to execute arbitrary PHP code via PHP code sequences in the factor parameter, which are not properly handled when accessing a filename that contains those sequences.",
  "id": "GHSA-5f2r-j5h2-8p7f",
  "modified": "2022-05-01T23:28:57Z",
  "published": "2022-05-01T23:28:57Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2008-0300"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/41131"
    },
    {
      "type": "WEB",
      "url": "https://www.exploit-db.com/exploits/5232"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/29329"
    },
    {
      "type": "WEB",
      "url": "http://www.redteam-pentesting.de/advisories/rt-sa-2008-001.php"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/28195"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-5F3P-WQH5-33M5

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

The favicon functionality in Firefox before 1.0.3 and Mozilla Suite before 1.7.7 allows remote attackers to execute arbitrary code via a tag with a javascript: URL in the href attribute, aka "Firelinking."

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2005-1155"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2005-05-02T04:00:00Z",
    "severity": "HIGH"
  },
  "details": "The favicon functionality in Firefox before 1.0.3 and Mozilla Suite before 1.7.7 allows remote attackers to execute arbitrary code via a \u003cLINK rel=\"icon\"\u003e tag with a javascript: URL in the href attribute, aka \"Firelinking.\"",
  "id": "GHSA-5f3p-wqh5-33m5",
  "modified": "2022-05-03T03:14:07Z",
  "published": "2022-05-03T03:14:07Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2005-1155"
    },
    {
      "type": "WEB",
      "url": "https://bugzilla.mozilla.org/show_bug.cgi?id=290036"
    },
    {
      "type": "WEB",
      "url": "https://oval.cisecurity.org/repository/search/definition/oval%3Aorg.mitre.oval%3Adef%3A100021"
    },
    {
      "type": "WEB",
      "url": "https://oval.cisecurity.org/repository/search/definition/oval%3Aorg.mitre.oval%3Adef%3A10655"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/14938"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/14992"
    },
    {
      "type": "WEB",
      "url": "http://www.gentoo.org/security/en/glsa/glsa-200504-18.xml"
    },
    {
      "type": "WEB",
      "url": "http://www.kb.cert.org/vuls/id/973309"
    },
    {
      "type": "WEB",
      "url": "http://www.mikx.de/firelinking"
    },
    {
      "type": "WEB",
      "url": "http://www.mozilla.org/security/announce/mfsa2005-37.html"
    },
    {
      "type": "WEB",
      "url": "http://www.redhat.com/support/errata/RHSA-2005-383.html"
    },
    {
      "type": "WEB",
      "url": "http://www.redhat.com/support/errata/RHSA-2005-384.html"
    },
    {
      "type": "WEB",
      "url": "http://www.redhat.com/support/errata/RHSA-2005-386.html"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/13216"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/15495"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-5F3X-VHW5-3RCG

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

Session::Cookie in the HTML::EP module 0.2011 for Perl does not properly use the Storable::thaw function, which allows remote attackers to execute arbitrary code via a crafted request, which is not properly handled when it is deserialized.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2012-6142"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2014-06-04T23:55:00Z",
    "severity": "HIGH"
  },
  "details": "Session::Cookie in the HTML::EP module 0.2011 for Perl does not properly use the Storable::thaw function, which allows remote attackers to execute arbitrary code via a crafted request, which is not properly handled when it is deserialized.",
  "id": "GHSA-5f3x-vhw5-3rcg",
  "modified": "2022-05-17T01:37:41Z",
  "published": "2022-05-17T01:37:41Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2012-6142"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/84199"
    },
    {
      "type": "WEB",
      "url": "http://seclists.org/oss-sec/2013/q2/318"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/59833"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

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.