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.

8313 vulnerabilities reference this CWE, most recent first.

GHSA-CC8M-98FM-RC9G

Vulnerability from github – Published: 2026-01-16 21:03 – Updated: 2026-01-16 21:57
VLAI
Summary
Skipper is vulnerable to arbitrary code execution through lua filters
Details

Impact

Arbitrary code execution through lua filters.

The default skipper configuration before v0.23 was -lua-sources=inline,file. The problem starts if untrusted users can create lua filters, because of -lua-sources=inline , for example through a Kubernetes Ingress resource. The configuration inline allows these user to create a script that is able to read the filesystem accessible to the skipper process and if the user has access to read the logs they an read skipper secrets.

Kubernetes example (vulnerability is not limited to Kubernetes)

function request(ctx, params)
  local file = io.open('/var/run/secrets/kubernetes.io/serviceaccount/token', 'r')
  if file then
    local token = file:read('*all')
    file:close()
    error('[EXFIL] ' .. token)  -- Exfiltrate via error logs
  end
end

Patches

https://github.com/zalando/skipper/releases/tag/v0.23.0 disables Lua by default.

Workarounds

You can reduce support of how you can pass lua filter script data by providing config for lua sources https://opensource.zalando.com/skipper/reference/scripts/#enable-and-disable-lua-sources. For example -lua-sources=file will only be exploitable if the attacker can create a lua script file on the target system.

References

https://opensource.zalando.com/skipper/reference/scripts/#enable-and-disable-lua-sources

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/zalando/skipper"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "0.23.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-23742"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-250",
      "CWE-522",
      "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-01-16T21:03:34Z",
    "nvd_published_at": "2026-01-16T20:15:51Z",
    "severity": "HIGH"
  },
  "details": "### Impact\n\nArbitrary code execution through [lua filters](https://opensource.zalando.com/skipper/reference/scripts/).\n\nThe default skipper configuration before v0.23 was `-lua-sources=inline,file`. \nThe problem starts if untrusted users can create lua filters, because of `-lua-sources=inline` , for example through a Kubernetes Ingress resource. The configuration `inline` allows these user to create a script that is able to read the filesystem accessible to the skipper process and if the user has access to read the logs they an read skipper secrets.\n\nKubernetes example (vulnerability is not limited to Kubernetes)\n```lua\nfunction request(ctx, params)\n  local file = io.open(\u0027/var/run/secrets/kubernetes.io/serviceaccount/token\u0027, \u0027r\u0027)\n  if file then\n    local token = file:read(\u0027*all\u0027)\n    file:close()\n    error(\u0027[EXFIL] \u0027 .. token)  -- Exfiltrate via error logs\n  end\nend\n```\n\n### Patches\n\nhttps://github.com/zalando/skipper/releases/tag/v0.23.0 disables Lua by default.\n\n### Workarounds\n\nYou can reduce support of how you can pass lua filter script data by providing config for lua sources https://opensource.zalando.com/skipper/reference/scripts/#enable-and-disable-lua-sources. For example `-lua-sources=file` will only be exploitable if the attacker can create a lua script file on the target system. \n\n### References\n\nhttps://opensource.zalando.com/skipper/reference/scripts/#enable-and-disable-lua-sources",
  "id": "GHSA-cc8m-98fm-rc9g",
  "modified": "2026-01-16T21:57:03Z",
  "published": "2026-01-16T21:03:34Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/zalando/skipper/security/advisories/GHSA-cc8m-98fm-rc9g"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-23742"
    },
    {
      "type": "WEB",
      "url": "https://github.com/zalando/skipper/commit/0b52894570773b29e2f3c571b94b4211ef8fa714"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/zalando/skipper"
    },
    {
      "type": "WEB",
      "url": "https://github.com/zalando/skipper/releases/tag/v0.23.0"
    }
  ],
  "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"
    }
  ],
  "summary": "Skipper is vulnerable to arbitrary code execution through lua filters"
}

GHSA-CCCJ-9J27-2C4W

Vulnerability from github – Published: 2022-05-05 00:28 – Updated: 2024-04-03 23:54
VLAI
Details

Foswiki before 1.1.8 contains a code injection vulnerability in the MAKETEXT macro.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2013-1666"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2019-11-01T17:15:00Z",
    "severity": "CRITICAL"
  },
  "details": "Foswiki before 1.1.8 contains a code injection vulnerability in the MAKETEXT macro.",
  "id": "GHSA-cccj-9j27-2c4w",
  "modified": "2024-04-03T23:54:03Z",
  "published": "2022-05-05T00:28:57Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2013-1666"
    },
    {
      "type": "WEB",
      "url": "https://security-tracker.debian.org/tracker/CVE-2013-1666"
    },
    {
      "type": "WEB",
      "url": "https://www.securityfocus.com/archive/1/525733"
    },
    {
      "type": "WEB",
      "url": "http://foswiki.org/Support/SecurityAlert-CVE-2013-1666"
    },
    {
      "type": "WEB",
      "url": "http://www.openwall.com/lists/oss-security/2015/03/24/20"
    }
  ],
  "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-CCGC-CRP4-F2MF

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

utils/opcontrol in OProfile 0.9.6 and earlier might allow local users to conduct eval injection attacks and gain privileges via shell metacharacters in the -e argument.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2011-1760"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2011-06-09T19:55:00Z",
    "severity": "HIGH"
  },
  "details": "utils/opcontrol in OProfile 0.9.6 and earlier might allow local users to conduct eval injection attacks and gain privileges via shell metacharacters in the -e argument.",
  "id": "GHSA-ccgc-crp4-f2mf",
  "modified": "2022-05-17T05:39:44Z",
  "published": "2022-05-17T05:39:44Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2011-1760"
    },
    {
      "type": "WEB",
      "url": "https://bugzilla.redhat.com/show_bug.cgi?id=700883"
    },
    {
      "type": "WEB",
      "url": "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=624212"
    },
    {
      "type": "WEB",
      "url": "http://openwall.com/lists/oss-security/2011/04/29/3"
    },
    {
      "type": "WEB",
      "url": "http://openwall.com/lists/oss-security/2011/05/01/1"
    },
    {
      "type": "WEB",
      "url": "http://openwall.com/lists/oss-security/2011/05/01/2"
    },
    {
      "type": "WEB",
      "url": "http://openwall.com/lists/oss-security/2011/05/02/17"
    },
    {
      "type": "WEB",
      "url": "http://openwall.com/lists/oss-security/2011/05/03/2"
    },
    {
      "type": "WEB",
      "url": "http://openwall.com/lists/oss-security/2011/05/10/6"
    },
    {
      "type": "WEB",
      "url": "http://openwall.com/lists/oss-security/2011/05/10/7"
    },
    {
      "type": "WEB",
      "url": "http://openwall.com/lists/oss-security/2011/05/11/1"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/44790"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/45205"
    },
    {
      "type": "WEB",
      "url": "http://www.debian.org/security/2011/dsa-2254"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/47652"
    },
    {
      "type": "WEB",
      "url": "http://www.ubuntu.com/usn/USN-1166-1"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-CCH2-42P7-W83V

Vulnerability from github – Published: 2025-10-20 21:30 – Updated: 2025-10-20 21:30
VLAI
Details

An issue in Senayan Library Management System (SLiMS) 9 Bulian v.9.6.1 allows a remote attacker to execute arbitrary code via the scrap_image.php component and the imageURL parameter

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-61488"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-10-20T19:15:38Z",
    "severity": "HIGH"
  },
  "details": "An issue in Senayan Library Management System (SLiMS) 9 Bulian v.9.6.1 allows a remote attacker to execute arbitrary code via the scrap_image.php component and the imageURL parameter",
  "id": "GHSA-cch2-42p7-w83v",
  "modified": "2025-10-20T21:30:31Z",
  "published": "2025-10-20T21:30:31Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-61488"
    },
    {
      "type": "WEB",
      "url": "https://github.com/slims/slims9_bulian/issues/299"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:L/A:N",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-CCHJ-4X5R-9R76

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

An eval injection vulnerability in the Python web server routing on the Zyxel NAS 326 version 5.21 and below allows a remote authenticated attacker to execute arbitrary code via the tjp6jp6y4, simZysh, and ck6fup6 APIs.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2019-10633"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2019-04-09T05:29:00Z",
    "severity": "HIGH"
  },
  "details": "An eval injection vulnerability in the Python web server routing on the Zyxel NAS 326 version 5.21 and below allows a remote authenticated attacker to execute arbitrary code via the tjp6jp6y4, simZysh, and ck6fup6 APIs.",
  "id": "GHSA-cchj-4x5r-9r76",
  "modified": "2022-05-14T01:11:04Z",
  "published": "2022-05-14T01:11:04Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2019-10633"
    },
    {
      "type": "WEB",
      "url": "http://maxwelldulin.com/BlogPost?post=3236967424"
    }
  ],
  "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-CCHQ-FRGV-RJH5

Vulnerability from github – Published: 2023-07-13 17:02 – Updated: 2026-01-05 21:25
VLAI
Summary
vm2 Sandbox Escape vulnerability
Details

In vm2 for versions up to 3.9.19, Promise handler sanitization can be bypassed, allowing attackers to escape the sandbox and run arbitrary code.

Impact

Remote Code Execution, assuming the attacker has arbitrary code execution primitive inside the context of vm2 sandbox.

Patches

None.

Workarounds

None.

References

PoC - https://gist.github.com/leesh3288/f693061e6523c97274ad5298eb2c74e9

For more information

If you have any questions or comments about this advisory:

  • Open an issue in VM2

Thanks to Xion (SeungHyun Lee) of KAIST Hacking Lab for disclosing this vulnerability.

Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 3.9.19"
      },
      "package": {
        "ecosystem": "npm",
        "name": "vm2"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "3.10.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2023-37466"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2023-07-13T17:02:02Z",
    "nvd_published_at": "2023-07-14T00:15:09Z",
    "severity": "CRITICAL"
  },
  "details": "In vm2 for versions up to 3.9.19, `Promise` handler sanitization can be bypassed, allowing attackers to escape the sandbox and run arbitrary code.\n\n### Impact\nRemote Code Execution, assuming the attacker has arbitrary code execution primitive inside the context of vm2 sandbox.\n\n### Patches\nNone.\n\n### Workarounds\nNone.\n\n### References\nPoC - https://gist.github.com/leesh3288/f693061e6523c97274ad5298eb2c74e9\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n- Open an issue in [VM2](https://github.com/patriksimek/vm2)\n\nThanks to [Xion](https://twitter.com/0x10n) (SeungHyun Lee) of [KAIST Hacking Lab](https://kaist-hacking.github.io/) for disclosing this vulnerability.",
  "id": "GHSA-cchq-frgv-rjh5",
  "modified": "2026-01-05T21:25:38Z",
  "published": "2023-07-13T17:02:02Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/patriksimek/vm2/security/advisories/GHSA-cchq-frgv-rjh5"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-37466"
    },
    {
      "type": "WEB",
      "url": "https://github.com/patriksimek/vm2/commit/d9a1fde8ec5a5a9c9e5a69bf91d703950859d744"
    },
    {
      "type": "WEB",
      "url": "https://gist.github.com/leesh3288/f693061e6523c97274ad5298eb2c74e9"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/patriksimek/vm2"
    },
    {
      "type": "WEB",
      "url": "https://github.com/patriksimek/vm2/releases/tag/v3.10.0"
    },
    {
      "type": "WEB",
      "url": "https://security.netapp.com/advisory/ntap-20230831-0007"
    },
    {
      "type": "WEB",
      "url": "https://security.netapp.com/advisory/ntap-20241108-0002"
    }
  ],
  "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": "vm2 Sandbox Escape vulnerability"
}

GHSA-CCQ2-JRJ3-PW8X

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

Java on Apple Mac OS X 10.5.4 and 10.5.5 does not prevent applets from accessing file:// URLs, which allows remote attackers to execute arbitrary programs.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2008-3638"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2008-09-26T16:21:00Z",
    "severity": "HIGH"
  },
  "details": "Java on Apple Mac OS X 10.5.4 and 10.5.5 does not prevent applets from accessing file:// URLs, which allows remote attackers to execute arbitrary programs.",
  "id": "GHSA-ccq2-jrj3-pw8x",
  "modified": "2022-05-02T00:02:09Z",
  "published": "2022-05-02T00:02:09Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2008-3638"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/45397"
    },
    {
      "type": "WEB",
      "url": "http://lists.apple.com/archives/security-announce//2008/Sep/msg00007.html"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/32018"
    },
    {
      "type": "WEB",
      "url": "http://support.apple.com/kb/HT3179"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/31380"
    },
    {
      "type": "WEB",
      "url": "http://www.securitytracker.com/id?1020944"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-CCQR-WHPM-2JV2

Vulnerability from github – Published: 2022-04-30 18:21 – Updated: 2022-04-30 18:21
VLAI
Details

csNewsPro.cgi in CGIScript.net csNews Professional (csNewsPro) allows remote attackers to execute arbitrary Perl code via the setup parameter, which is processed by the Perl eval function.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2002-1753"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2002-12-31T05:00:00Z",
    "severity": "MODERATE"
  },
  "details": "csNewsPro.cgi in CGIScript.net csNews Professional (csNewsPro) allows remote attackers to execute arbitrary Perl code via the setup parameter, which is processed by the Perl eval function.",
  "id": "GHSA-ccqr-whpm-2jv2",
  "modified": "2022-04-30T18:21:47Z",
  "published": "2022-04-30T18:21:47Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2002-1753"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/8636"
    },
    {
      "type": "WEB",
      "url": "http://cert.uni-stuttgart.de/archive/bugtraq/2002/04/msg00106.html"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/4451"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-CCR7-M2XP-492W

Vulnerability from github – Published: 2023-02-13 18:30 – Updated: 2023-02-22 21:30
VLAI
Details

Control By Web X-600M devices run Lua scripts and are vulnerable to code injection, which could allow an attacker to remotely execute arbitrary code.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2023-23551"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2023-02-13T18:15:00Z",
    "severity": "CRITICAL"
  },
  "details": "Control By Web X-600M devices run Lua scripts and are vulnerable to code injection, which could allow an attacker to remotely execute arbitrary code.",
  "id": "GHSA-ccr7-m2xp-492w",
  "modified": "2023-02-22T21:30:37Z",
  "published": "2023-02-13T18:30:25Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-23551"
    },
    {
      "type": "WEB",
      "url": "https://www.cisa.gov/uscert/ics/advisories/icsa-23-040-01"
    }
  ],
  "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-CCW3-9MR4-PX9J

Vulnerability from github – Published: 2022-05-02 03:13 – Updated: 2025-04-09 04:10
VLAI
Details

Array index error in FL21WIN.DLL in the PowerPoint Freelance Windows 2.1 Translator in Microsoft PowerPoint 2000 and 2002 allows remote attackers to execute arbitrary code via a Freelance file with unspecified "layout information" that triggers a heap-based buffer overflow.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2009-0202"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2009-06-11T21:30:00Z",
    "severity": "HIGH"
  },
  "details": "Array index error in FL21WIN.DLL in the PowerPoint Freelance Windows 2.1 Translator in Microsoft PowerPoint 2000 and 2002 allows remote attackers to execute arbitrary code via a Freelance file with unspecified \"layout information\" that triggers a heap-based buffer overflow.",
  "id": "GHSA-ccw3-9mr4-px9j",
  "modified": "2025-04-09T04:10:51Z",
  "published": "2022-05-02T03:13:28Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2009-0202"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/51034"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/35184"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/secunia_research/2009-29"
    },
    {
      "type": "WEB",
      "url": "http://securitytracker.com/id?1022369"
    },
    {
      "type": "WEB",
      "url": "http://www.osvdb.org/54961"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/archive/1/504215/100/0/threaded"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/35275"
    }
  ],
  "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.