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.

8306 vulnerabilities reference this CWE, most recent first.

GHSA-VM5P-J4C4-475P

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

The launch method in the Deployment Toolkit plugin in Java Runtime Environment (JRE) in Sun Java SE in JDK and JRE 6 before Update 17 allows remote attackers to execute arbitrary commands via a crafted web page, aka Bug Id 6869752.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2009-3865"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2009-11-05T16:30:00Z",
    "severity": "HIGH"
  },
  "details": "The launch method in the Deployment Toolkit plugin in Java Runtime Environment (JRE) in Sun Java SE in JDK and JRE 6 before Update 17 allows remote attackers to execute arbitrary commands via a crafted web page, aka Bug Id 6869752.",
  "id": "GHSA-vm5p-j4c4-475p",
  "modified": "2022-05-02T03:49:18Z",
  "published": "2022-05-02T03:49:18Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2009-3865"
    },
    {
      "type": "WEB",
      "url": "https://oval.cisecurity.org/repository/search/definition/oval%3Aorg.mitre.oval%3Adef%3A7562"
    },
    {
      "type": "WEB",
      "url": "http://java.sun.com/javase/6/webnotes/6u17.html"
    },
    {
      "type": "WEB",
      "url": "http://lists.apple.com/archives/security-announce/2009/Dec/msg00000.html"
    },
    {
      "type": "WEB",
      "url": "http://lists.apple.com/archives/security-announce/2009/Dec/msg00001.html"
    },
    {
      "type": "WEB",
      "url": "http://lists.opensuse.org/opensuse-security-announce/2009-11/msg00010.html"
    },
    {
      "type": "WEB",
      "url": "http://marc.info/?l=bugtraq\u0026m=134254866602253\u0026w=2"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/37231"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/37239"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/37386"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/37581"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/37841"
    },
    {
      "type": "WEB",
      "url": "http://security.gentoo.org/glsa/glsa-200911-02.xml"
    },
    {
      "type": "WEB",
      "url": "http://sunsolve.sun.com/search/document.do?assetkey=1-66-269869-1"
    },
    {
      "type": "WEB",
      "url": "http://support.apple.com/kb/HT3969"
    },
    {
      "type": "WEB",
      "url": "http://support.apple.com/kb/HT3970"
    },
    {
      "type": "WEB",
      "url": "http://www.redhat.com/support/errata/RHSA-2009-1694.html"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/36881"
    },
    {
      "type": "WEB",
      "url": "http://www.securitytracker.com/id?1023244"
    },
    {
      "type": "WEB",
      "url": "http://www.vupen.com/english/advisories/2009/3131"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-VM64-CFQX-3698

Vulnerability from github – Published: 2022-02-10 20:18 – Updated: 2023-09-11 23:08
VLAI
Summary
Code Injection in jsen
Details

This affects all versions of package jsen. If an attacker can control the schema file, it could run arbitrary JavaScript code on the victim machine. In the module description and README file there is no mention about the risks of untrusted schema files, so it is assumed that this is applicable. In particular the required field of the schema is not properly sanitized. The resulting string that is build based on the schema definition is then passed to a Function.apply();, leading to an Arbitrary Code Execution.

PoC

const jsen = require('jsen');
let schema = JSON.parse(
{ "type": "object", "properties": { "username": { "type": "string" } }, "required": ["\\"+process.mainModule.require(\'child_process\').execSync(\'touch malicious\')+\\""] }
);

const validate = jsen(schema); validate({});
Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "npm",
        "name": "jsen"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "last_affected": "0.6.6"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2020-7777"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2021-04-14T19:49:04Z",
    "nvd_published_at": "2020-11-23T16:15:00Z",
    "severity": "HIGH"
  },
  "details": "This affects all versions of package jsen. If an attacker can control the schema file, it could run arbitrary JavaScript code on the victim machine. In the module description and README file there is no mention about the risks of untrusted schema files, so it is assumed that this is applicable. In particular the required field of the schema is not properly sanitized. The resulting string that is build based on the schema definition is then passed to a `Function.apply();`, leading to an Arbitrary Code Execution.\n\n### PoC\n```js\nconst jsen = require(\u0027jsen\u0027);\nlet schema = JSON.parse(\n{ \u0026quot;type\u0026quot;: \u0026quot;object\u0026quot;, \u0026quot;properties\u0026quot;: { \u0026quot;username\u0026quot;: { \u0026quot;type\u0026quot;: \u0026quot;string\u0026quot; } }, \u0026quot;required\u0026quot;: [\u0026quot;\\\\\u0026quot;+process.mainModule.require(\\\u0026#39;child_process\\\u0026#39;).execSync(\\\u0026#39;touch malicious\\\u0026#39;)+\\\\\u0026quot;\u0026quot;] }\n);\n\nconst validate = jsen(schema); validate({});\n```",
  "id": "GHSA-vm64-cfqx-3698",
  "modified": "2023-09-11T23:08:53Z",
  "published": "2022-02-10T20:18:37Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2020-7777"
    },
    {
      "type": "WEB",
      "url": "https://github.com/bugventure/jsen/blob/master/lib/jsen.js#L875"
    },
    {
      "type": "WEB",
      "url": "https://security.snyk.io/vuln/SNYK-JS-JSEN-1014670"
    }
  ],
  "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"
    }
  ],
  "summary": "Code Injection in jsen"
}

GHSA-VM87-XQ8Q-F9XP

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

IOSurface in Apple iOS before 8.2, Apple OS X through 10.10.2, and Apple TV before 7.1 allows attackers to execute arbitrary code in a privileged context via a crafted app that leverages "type confusion" during serialized-object handling.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2015-1061"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2015-03-12T10:59:00Z",
    "severity": "HIGH"
  },
  "details": "IOSurface in Apple iOS before 8.2, Apple OS X through 10.10.2, and Apple TV before 7.1 allows attackers to execute arbitrary code in a privileged context via a crafted app that leverages \"type confusion\" during serialized-object handling.",
  "id": "GHSA-vm87-xq8q-f9xp",
  "modified": "2022-05-14T01:25:56Z",
  "published": "2022-05-14T01:25:56Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2015-1061"
    },
    {
      "type": "WEB",
      "url": "https://support.apple.com/HT204413"
    },
    {
      "type": "WEB",
      "url": "https://support.apple.com/HT204423"
    },
    {
      "type": "WEB",
      "url": "https://support.apple.com/HT204426"
    },
    {
      "type": "WEB",
      "url": "https://support.apple.com/kb/HT204563"
    },
    {
      "type": "WEB",
      "url": "http://lists.apple.com/archives/security-announce/2015/Mar/msg00000.html"
    },
    {
      "type": "WEB",
      "url": "http://lists.apple.com/archives/security-announce/2015/Mar/msg00001.html"
    },
    {
      "type": "WEB",
      "url": "http://lists.apple.com/archives/security-announce/2015/Mar/msg00002.html"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/73004"
    },
    {
      "type": "WEB",
      "url": "http://www.securitytracker.com/id/1031864"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-VM9R-3QXR-CXXP

Vulnerability from github – Published: 2023-09-18 12:30 – Updated: 2024-04-04 07:43
VLAI
Details

A command injection vulnerability exists in RTS VLink Virtual Matrix Software Versions v5 (< 5.7.6) and v6 (< 6.5.0) that allows an attacker to perform arbitrary code execution via the admin web interface.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2023-34999"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-77",
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2023-09-18T11:15:41Z",
    "severity": "HIGH"
  },
  "details": "A command injection vulnerability exists in RTS VLink Virtual Matrix Software Versions v5 (\u003c 5.7.6) and v6 (\u003c 6.5.0) that allows an attacker to perform arbitrary code execution via the admin web interface.",
  "id": "GHSA-vm9r-3qxr-cxxp",
  "modified": "2024-04-04T07:43:09Z",
  "published": "2023-09-18T12:30:16Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-34999"
    },
    {
      "type": "WEB",
      "url": "https://psirt.bosch.com/security-advisories/BOSCH-SA-893251-BT.html"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-VMF5-6G88-V3Q9

Vulnerability from github – Published: 2022-05-24 17:41 – Updated: 2024-04-04 03:04
VLAI
Details

An issue was discovered in SmartFoxServer 2.17.0. An attacker can execute arbitrary Python code, and bypass the javashell.py protection mechanism, by creating /config/ConsoleModuleUnlock.txt and editing /config/admin/admintool.xml to enable the Console module.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2021-26551"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2021-02-09T20:15:00Z",
    "severity": "HIGH"
  },
  "details": "An issue was discovered in SmartFoxServer 2.17.0. An attacker can execute arbitrary Python code, and bypass the javashell.py protection mechanism, by creating /config/ConsoleModuleUnlock.txt and editing /config/admin/admintool.xml to enable the Console module.",
  "id": "GHSA-vmf5-6g88-v3q9",
  "modified": "2024-04-04T03:04:30Z",
  "published": "2022-05-24T17:41:38Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2021-26551"
    },
    {
      "type": "WEB",
      "url": "https://www.smartfoxserver.com"
    },
    {
      "type": "WEB",
      "url": "https://www.zeroscience.mk/en/vulnerabilities"
    },
    {
      "type": "WEB",
      "url": "http://packetstormsecurity.com/files/161340/SmartFoxServer-2X-2.17.0-Remote-Code-Execution.html"
    }
  ],
  "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"
    }
  ]
}

GHSA-VMH9-7GFQ-4R2P

Vulnerability from github – Published: 2025-02-20 18:31 – Updated: 2025-11-04 21:31
VLAI
Details

PHPJabbers Restaurant Booking System v3.0 is vulnerable to Multiple HTML Injection in the "name, plugin_sms_api_key, plugin_sms_country_code, title, plugin_sms_api_key, title" parameters.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2023-51317"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-02-20T16:15:34Z",
    "severity": "MODERATE"
  },
  "details": "PHPJabbers Restaurant Booking System v3.0 is vulnerable to Multiple HTML Injection in the \"name, plugin_sms_api_key, plugin_sms_country_code, title, plugin_sms_api_key, title\" parameters.",
  "id": "GHSA-vmh9-7gfq-4r2p",
  "modified": "2025-11-04T21:31:30Z",
  "published": "2025-02-20T18:31:22Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-51317"
    },
    {
      "type": "WEB",
      "url": "https://packetstorm.news/files/id/176493"
    },
    {
      "type": "WEB",
      "url": "https://www.phpjabbers.com/restaurant-booking-system/#sectionDemo"
    },
    {
      "type": "WEB",
      "url": "http://packetstormsecurity.com/files/176493/PHPJabbers-Restaurant-Booking-System-3.0-Cross-Site-Scripting-HTML-Injection.html"
    }
  ],
  "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-VMMQ-P5R9-QM38

Vulnerability from github – Published: 2024-11-18 15:33 – Updated: 2026-04-01 18:32
VLAI
Details

Improper Neutralization of Special Elements Used in a Template Engine vulnerability in Supsystic Popup by Supsystic allows Command Injection.This issue affects Popup by Supsystic: from n/a through 1.10.29.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2024-52434"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-1336",
      "CWE-82",
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2024-11-18T15:15:08Z",
    "severity": "CRITICAL"
  },
  "details": "Improper Neutralization of Special Elements Used in a Template Engine vulnerability in Supsystic Popup by Supsystic allows Command Injection.This issue affects Popup by Supsystic: from n/a through 1.10.29.",
  "id": "GHSA-vmmq-p5r9-qm38",
  "modified": "2026-04-01T18:32:25Z",
  "published": "2024-11-18T15:33:21Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-52434"
    },
    {
      "type": "WEB",
      "url": "https://patchstack.com/database/Wordpress/Plugin/popup-by-supsystic/vulnerability/wordpress-popup-by-supsystic-plugin-1-10-29-remote-code-execution-rce-vulnerability?_s_id=cve"
    },
    {
      "type": "WEB",
      "url": "https://patchstack.com/database/vulnerability/popup-by-supsystic/wordpress-popup-by-supsystic-plugin-1-10-29-remote-code-execution-rce-vulnerability?_s_id=cve"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-VMPF-F73J-FG6V

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

The callme_startcall function in recordings/misc/callme_page.php in FreePBX 2.9, 2.10, and earlier allows remote attackers to execute arbitrary commands via the callmenum parameter in a c action.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2012-4869"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2012-09-06T17:55:00Z",
    "severity": "HIGH"
  },
  "details": "The callme_startcall function in recordings/misc/callme_page.php in FreePBX 2.9, 2.10, and earlier allows remote attackers to execute arbitrary commands via the callmenum parameter in a c action.",
  "id": "GHSA-vmpf-f73j-fg6v",
  "modified": "2022-05-13T01:30:22Z",
  "published": "2022-05-13T01:30:22Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2012-4869"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/74174"
    },
    {
      "type": "WEB",
      "url": "http://packetstormsecurity.org/files/111028/FreePBX-2.10.0-Remote-Command-Execution-XSS.html"
    },
    {
      "type": "WEB",
      "url": "http://seclists.org/fulldisclosure/2012/Mar/234"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/48463"
    },
    {
      "type": "WEB",
      "url": "http://www.exploit-db.com/exploits/18649"
    },
    {
      "type": "WEB",
      "url": "http://www.exploit-db.com/exploits/18659"
    },
    {
      "type": "WEB",
      "url": "http://www.freepbx.org/trac/ticket/5711"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/52630"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-VMQ4-67RJ-G3JW

Vulnerability from github – Published: 2024-06-15 09:30 – Updated: 2026-04-08 18:33
VLAI
Details

The Woody code snippets – Insert Header Footer Code, AdSense Ads plugin for WordPress is vulnerable to Remote Code Execution in all versions up to, and including, 2.5.0 via the 'insert_php' shortcode. This is due to the plugin not restricting the usage of the functionality to high level authorized users. This makes it possible for authenticated attackers, with contributor-level access and above, to execute code on the server.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2024-3105"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2024-06-15T09:15:11Z",
    "severity": "CRITICAL"
  },
  "details": "The Woody code snippets \u2013 Insert Header Footer Code, AdSense Ads plugin for WordPress is vulnerable to Remote Code Execution in all versions up to, and including, 2.5.0 via the \u0027insert_php\u0027 shortcode. This is due to the plugin not restricting the usage of the functionality to high level authorized users. This makes it possible for authenticated attackers, with contributor-level access and above, to execute code on the server.",
  "id": "GHSA-vmq4-67rj-g3jw",
  "modified": "2026-04-08T18:33:25Z",
  "published": "2024-06-15T09:30:35Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-3105"
    },
    {
      "type": "WEB",
      "url": "https://plugins.trac.wordpress.org/browser/insert-php/trunk/includes/class.plugin.php#L166"
    },
    {
      "type": "WEB",
      "url": "https://plugins.trac.wordpress.org/browser/insert-php/trunk/includes/shortcodes/shortcode-insert-php.php"
    },
    {
      "type": "WEB",
      "url": "https://plugins.trac.wordpress.org/changeset?sfp_email=\u0026sfph_mail=\u0026reponame=\u0026old=3102522%40insert-php\u0026new=3102522%40insert-php\u0026sfp_email=\u0026sfph_mail="
    },
    {
      "type": "WEB",
      "url": "https://www.wordfence.com/threat-intel/vulnerabilities/id/134ad095-b0a0-4f0f-832d-3e558d4a250a?source=cve"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-VMQJ-WP2G-3JP7

Vulnerability from github – Published: 2023-01-22 09:30 – Updated: 2025-04-02 18:30
VLAI
Details

Grand Theft Auto V for PC allows attackers to achieve partial remote code execution or modify files on a PC, as exploited in the wild in January 2023.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2023-24059"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2023-01-22T07:15:00Z",
    "severity": "HIGH"
  },
  "details": "Grand Theft Auto V for PC allows attackers to achieve partial remote code execution or modify files on a PC, as exploited in the wild in January 2023.",
  "id": "GHSA-vmqj-wp2g-3jp7",
  "modified": "2025-04-02T18:30:38Z",
  "published": "2023-01-22T09:30:25Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-24059"
    },
    {
      "type": "WEB",
      "url": "https://support.rockstargames.com/community/200063373/13249062368147"
    },
    {
      "type": "WEB",
      "url": "https://support.rockstargames.com/community/200063373/13252523900819"
    },
    {
      "type": "WEB",
      "url": "https://twitter.com/TezFunz2/status/1616575783215964166"
    },
    {
      "type": "WEB",
      "url": "https://www.reddit.com/r/gtaonline/comments/10hsosu/mass_reporting_the_dangerous_pc_exploit"
    }
  ],
  "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: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.