CWE-94
Allowed-with-ReviewImproper 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.
8286 vulnerabilities reference this CWE, most recent first.
GHSA-W6W5-X32X-CG2W
Vulnerability from github – Published: 2022-05-17 04:31 – Updated: 2022-05-17 04:31The XMonad.Hooks.DynamicLog module in xmonad-contrib before 0.11.2 allows remote attackers to execute arbitrary commands via a web page title, which activates the commands when the user clicks on the xmobar window title, as demonstrated using an action tag.
{
"affected": [],
"aliases": [
"CVE-2013-1436"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2014-10-06T23:55:00Z",
"severity": "HIGH"
},
"details": "The XMonad.Hooks.DynamicLog module in xmonad-contrib before 0.11.2 allows remote attackers to execute arbitrary commands via a web page title, which activates the commands when the user clicks on the xmobar window title, as demonstrated using an action tag.",
"id": "GHSA-w6w5-x32x-cg2w",
"modified": "2022-05-17T04:31:37Z",
"published": "2022-05-17T04:31:37Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2013-1436"
},
{
"type": "WEB",
"url": "http://handra.rampa.sk/dawb/patch?repoPURL=http%3A%2F%2Fcode.haskell.org%2FXMonadContrib\u0026repoPHash=20130708144813-1499c-0c3e284d3523c0694b9423714081761813bc1e89"
},
{
"type": "WEB",
"url": "http://security.gentoo.org/glsa/glsa-201405-28.xml"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2013/07/26/5"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/61491"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-W739-R6V2-X43X
Vulnerability from github – Published: 2022-05-01 07:05 – Updated: 2022-05-01 07:05Multiple PHP remote file inclusion vulnerabilities in phpCMS 1.2.1pl2 allow remote attackers to execute arbitrary PHP code via a URL in the PHPCMS_INCLUDEPATH parameter to files in parser/include/ including (1) class.parser_phpcms.php, (2) class.session_phpcms.php, (3) class.edit_phpcms.php, (4) class.http_indexer_phpcms.php, (5) class.cache_phpcms.php, (6) class.search_phpcms.php, (7) class.lib_indexer_universal_phpcms.php, and (8) class.layout_phpcms.php, (9) parser/plugs/counter.php, and (10) parser/parser.php. NOTE: the class.cache_phpcms.php vector was also reported to affect 1.1.7.
{
"affected": [],
"aliases": [
"CVE-2006-3019"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2006-06-15T10:02:00Z",
"severity": "HIGH"
},
"details": "Multiple PHP remote file inclusion vulnerabilities in phpCMS 1.2.1pl2 allow remote attackers to execute arbitrary PHP code via a URL in the PHPCMS_INCLUDEPATH parameter to files in parser/include/ including (1) class.parser_phpcms.php, (2) class.session_phpcms.php, (3) class.edit_phpcms.php, (4) class.http_indexer_phpcms.php, (5) class.cache_phpcms.php, (6) class.search_phpcms.php, (7) class.lib_indexer_universal_phpcms.php, and (8) class.layout_phpcms.php, (9) parser/plugs/counter.php, and (10) parser/parser.php. NOTE: the class.cache_phpcms.php vector was also reported to affect 1.1.7.",
"id": "GHSA-w739-r6v2-x43x",
"modified": "2022-05-01T07:05:00Z",
"published": "2022-05-01T07:05:00Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2006-3019"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/27067"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/20573"
},
{
"type": "WEB",
"url": "http://securityreason.com/securityalert/1106"
},
{
"type": "WEB",
"url": "http://www.osvdb.org/26388"
},
{
"type": "WEB",
"url": "http://www.osvdb.org/26389"
},
{
"type": "WEB",
"url": "http://www.osvdb.org/26390"
},
{
"type": "WEB",
"url": "http://www.osvdb.org/26391"
},
{
"type": "WEB",
"url": "http://www.osvdb.org/26392"
},
{
"type": "WEB",
"url": "http://www.osvdb.org/26393"
},
{
"type": "WEB",
"url": "http://www.osvdb.org/26394"
},
{
"type": "WEB",
"url": "http://www.osvdb.org/26395"
},
{
"type": "WEB",
"url": "http://www.osvdb.org/26396"
},
{
"type": "WEB",
"url": "http://www.osvdb.org/26397"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/archive/1/436893/100/0/threaded"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/archive/1/455302/100/0/threaded"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/21768"
},
{
"type": "WEB",
"url": "http://www.vupen.com/english/advisories/2006/2302"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-W749-P3V6-HCCQ
Vulnerability from github – Published: 2022-03-08 21:25 – Updated: 2022-06-21 15:59The Active Storage module of Rails starting with version 5.2.0 is possibly vulnerable to code injection. This issue was patched in versions 5.2.6.3, 6.0.4.7, 6.1.4.7, and 7.0.2.3. To work around this issue, applications should implement a strict allow-list on accepted transformation methods or arguments. Additionally, a strict ImageMagick security policy will help mitigate this issue.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 5.2.6.2"
},
"package": {
"ecosystem": "RubyGems",
"name": "activestorage"
},
"ranges": [
{
"events": [
{
"introduced": "5.2.0"
},
{
"fixed": "5.2.6.3"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 6.0.4.6"
},
"package": {
"ecosystem": "RubyGems",
"name": "activestorage"
},
"ranges": [
{
"events": [
{
"introduced": "6.0.0"
},
{
"fixed": "6.0.4.7"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 6.1.4.6"
},
"package": {
"ecosystem": "RubyGems",
"name": "activestorage"
},
"ranges": [
{
"events": [
{
"introduced": "6.1.0"
},
{
"fixed": "6.1.4.7"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 7.0.2.2"
},
"package": {
"ecosystem": "RubyGems",
"name": "activestorage"
},
"ranges": [
{
"events": [
{
"introduced": "7.0.0"
},
{
"fixed": "7.0.2.3"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2022-21831"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": true,
"github_reviewed_at": "2022-03-08T21:25:54Z",
"nvd_published_at": "2022-05-26T17:15:00Z",
"severity": "CRITICAL"
},
"details": "The Active Storage module of Rails starting with version 5.2.0 is possibly vulnerable to code injection. This issue was patched in versions 5.2.6.3, 6.0.4.7, 6.1.4.7, and 7.0.2.3. To work around this issue, applications should implement a strict allow-list on accepted transformation methods or arguments. Additionally, a strict ImageMagick security policy will help mitigate this issue.",
"id": "GHSA-w749-p3v6-hccq",
"modified": "2022-06-21T15:59:23Z",
"published": "2022-03-08T21:25:54Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-21831"
},
{
"type": "WEB",
"url": "https://github.com/rails/rails/commit/0a72f7d670e9aa77a0bb8584cb1411ddabb7546e"
},
{
"type": "ADVISORY",
"url": "https://github.com/advisories/GHSA-w749-p3v6-hccq"
},
{
"type": "PACKAGE",
"url": "https://github.com/rails/rails"
},
{
"type": "WEB",
"url": "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/activestorage/CVE-2022-21831.yml"
},
{
"type": "WEB",
"url": "https://groups.google.com/g/rubyonrails-security/c/n-p-W1yxatI"
},
{
"type": "WEB",
"url": "https://lists.debian.org/debian-lts-announce/2022/09/msg00002.html"
},
{
"type": "WEB",
"url": "https://rubysec.com/advisories/CVE-2022-21831"
},
{
"type": "WEB",
"url": "https://security.netapp.com/advisory/ntap-20221118-0001"
},
{
"type": "WEB",
"url": "https://www.debian.org/security/2023/dsa-5372"
}
],
"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": "Possible code injection vulnerability in Rails / Active Storage"
}
GHSA-W74V-6CVM-J42Q
Vulnerability from github – Published: 2023-02-01 09:30 – Updated: 2023-02-10 18:30Potential vulnerabilities have been identified in the system BIOS of certain HP PC products, which might allow arbitrary code execution, escalation of privilege, denial of service, and information disclosure. HP is releasing BIOS updates to mitigate these potential vulnerabilities.
{
"affected": [],
"aliases": [
"CVE-2022-27537"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-02-01T07:15:00Z",
"severity": "HIGH"
},
"details": "Potential vulnerabilities have been identified in the system BIOS of certain HP PC products, which might allow arbitrary code execution, escalation of privilege, denial of service, and information disclosure. HP is releasing BIOS updates to mitigate these potential vulnerabilities.",
"id": "GHSA-w74v-6cvm-j42q",
"modified": "2023-02-10T18:30:32Z",
"published": "2023-02-01T09:30:26Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-27537"
},
{
"type": "WEB",
"url": "https://support.hp.com/us-en/document/ish_6664419-6664458-16/hpsbhf03806"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-W754-GQ8R-PF5F
Vulnerability from github – Published: 2017-10-24 18:33 – Updated: 2023-08-29 14:01lib/mini_magick.rb in the MiniMagick Gem 1.3.1 for Ruby allows remote attackers to execute arbitrary commands via shell metacharacters in a URL.
{
"affected": [
{
"package": {
"ecosystem": "RubyGems",
"name": "mini_magick"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "3.6.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2013-2616"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": true,
"github_reviewed_at": "2020-06-16T21:59:55Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "`lib/mini_magick.rb` in the MiniMagick Gem 1.3.1 for Ruby allows remote attackers to execute arbitrary commands via shell metacharacters in a URL.",
"id": "GHSA-w754-gq8r-pf5f",
"modified": "2023-08-29T14:01:28Z",
"published": "2017-10-24T18:33:37Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2013-2616"
},
{
"type": "PACKAGE",
"url": "https://github.com/minimagick/minimagick"
},
{
"type": "WEB",
"url": "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/mini_magick/CVE-2013-2616.yml"
},
{
"type": "WEB",
"url": "https://web.archive.org/web/20130315095512/http://www.securityfocus.com/bid/58448"
},
{
"type": "WEB",
"url": "http://packetstormsecurity.com/files/120777/Ruby-Gem-Minimagic-Command-Execution.html"
},
{
"type": "WEB",
"url": "http://seclists.org/fulldisclosure/2013/Mar/123"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2013/03/19/9"
}
],
"schema_version": "1.4.0",
"severity": [],
"summary": "MiniMagick Gem for Ruby URI Handling Arbitrary Command Injection"
}
GHSA-W772-RR97-RMMM
Vulnerability from github – Published: 2022-05-01 18:32 – Updated: 2022-05-01 18:32Microsoft Internet Explorer 5.01 through 7 allows remote attackers to execute arbitrary code via a crafted website using Javascript that creates, modifies, deletes, and accesses document objects using the tags property, which triggers heap corruption, related to uninitialized or deleted objects, a different issue than CVE-2007-3902 and CVE-2007-3903, and a variant of "Uninitialized Memory Corruption Vulnerability."
{
"affected": [],
"aliases": [
"CVE-2007-5344"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2007-12-12T00:46:00Z",
"severity": "MODERATE"
},
"details": "Microsoft Internet Explorer 5.01 through 7 allows remote attackers to execute arbitrary code via a crafted website using Javascript that creates, modifies, deletes, and accesses document objects using the tags property, which triggers heap corruption, related to uninitialized or deleted objects, a different issue than CVE-2007-3902 and CVE-2007-3903, and a variant of \"Uninitialized Memory Corruption Vulnerability.\"",
"id": "GHSA-w772-rr97-rmmm",
"modified": "2022-05-01T18:32:21Z",
"published": "2022-05-01T18:32:21Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2007-5344"
},
{
"type": "WEB",
"url": "https://docs.microsoft.com/en-us/security-updates/securitybulletins/2007/ms07-069"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/38715"
},
{
"type": "WEB",
"url": "https://oval.cisecurity.org/repository/search/definition/oval%3Aorg.mitre.oval%3Adef%3A4480"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/28036"
},
{
"type": "WEB",
"url": "http://securitytracker.com/id?1019078"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/archive/1/484890/100/100/threaded"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/archive/1/485268/100/0/threaded"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/26817"
},
{
"type": "WEB",
"url": "http://www.us-cert.gov/cas/techalerts/TA07-345A.html"
},
{
"type": "WEB",
"url": "http://www.vupen.com/english/advisories/2007/4184"
},
{
"type": "WEB",
"url": "http://www.zerodayinitiative.com/advisories/ZDI-07-075.html"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-W784-6HH8-995V
Vulnerability from github – Published: 2024-09-16 15:32 – Updated: 2026-06-03 15:30Improper Control of Generation of Code ('Code Injection') vulnerability in SFS Consulting ww.Winsure allows Code Injection.This issue affects ww.Winsure: before 4.6.2.
{
"affected": [],
"aliases": [
"CVE-2024-7104"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2024-09-16T15:15:17Z",
"severity": "CRITICAL"
},
"details": "Improper Control of Generation of Code (\u0027Code Injection\u0027) vulnerability in SFS Consulting ww.Winsure allows Code Injection.This issue affects ww.Winsure: before 4.6.2.",
"id": "GHSA-w784-6hh8-995v",
"modified": "2026-06-03T15:30:34Z",
"published": "2024-09-16T15:32:47Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-7104"
},
{
"type": "WEB",
"url": "https://siberguvenlik.gov.tr/guvenlik-bildirimleri/detay/tr-24-1475"
},
{
"type": "WEB",
"url": "https://www.usom.gov.tr/bildirim/tr-24-1475"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:L/VA:N/SC:H/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
"type": "CVSS_V4"
}
]
}
GHSA-W78Q-4W34-JRJX
Vulnerability from github – Published: 2022-05-17 00:01 – Updated: 2023-08-25 21:43Code Injection in GitHub repository publify/publify prior to 9.2.8.
{
"affected": [
{
"package": {
"ecosystem": "RubyGems",
"name": "publify_core"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "9.2.8"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2022-0578"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": true,
"github_reviewed_at": "2022-06-03T15:48:03Z",
"nvd_published_at": "2022-05-16T15:15:00Z",
"severity": "MODERATE"
},
"details": "Code Injection in GitHub repository publify/publify prior to 9.2.8.",
"id": "GHSA-w78q-4w34-jrjx",
"modified": "2023-08-25T21:43:03Z",
"published": "2022-05-17T00:01:25Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-0578"
},
{
"type": "WEB",
"url": "https://github.com/publify/publify/commit/b50df050c593cc532b2c516792989bcfce2d73f7"
},
{
"type": "PACKAGE",
"url": "https://github.com/publify/publify"
},
{
"type": "WEB",
"url": "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/publify_core/CVE-2022-0578.yml"
},
{
"type": "WEB",
"url": "https://huntr.dev/bounties/02c81928-eb47-476f-8000-e93dc796dbcc"
}
],
"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": "Publify vulnerable to code injection"
}
GHSA-W79C-GWH4-8R76
Vulnerability from github – Published: 2022-01-12 00:01 – Updated: 2024-11-14 21:31Microsoft Word Remote Code Execution Vulnerability.
{
"affected": [],
"aliases": [
"CVE-2022-21842"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2022-01-11T21:15:00Z",
"severity": "HIGH"
},
"details": "Microsoft Word Remote Code Execution Vulnerability.",
"id": "GHSA-w79c-gwh4-8r76",
"modified": "2024-11-14T21:31:43Z",
"published": "2022-01-12T00:01:09Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-21842"
},
{
"type": "WEB",
"url": "https://msrc.microsoft.com/update-guide/vulnerability/CVE-2022-21842"
},
{
"type": "WEB",
"url": "https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2022-21842"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-W79G-RG56-5HXW
Vulnerability from github – Published: 2022-05-17 05:00 – Updated: 2022-05-17 05:00LOCKON EC-CUBE 2.11.2 through 2.12.4 allows remote attackers to conduct unspecified PHP code-injection attacks via a crafted string, related to data/class/SC_CheckError.php and data/class/SC_FormParam.php.
{
"affected": [],
"aliases": [
"CVE-2013-3651"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2013-06-30T19:28:00Z",
"severity": "HIGH"
},
"details": "LOCKON EC-CUBE 2.11.2 through 2.12.4 allows remote attackers to conduct unspecified PHP code-injection attacks via a crafted string, related to data/class/SC_CheckError.php and data/class/SC_FormParam.php.",
"id": "GHSA-w79g-rg56-5hxw",
"modified": "2022-05-17T05:00:57Z",
"published": "2022-05-17T05:00:57Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2013-3651"
},
{
"type": "WEB",
"url": "http://jvn.jp/en/jp/JVN34900750/index.html"
},
{
"type": "WEB",
"url": "http://jvndb.jvn.jp/jvndb/JVNDB-2013-000062"
},
{
"type": "WEB",
"url": "http://svn.ec-cube.net/open_trac/changeset/22891"
},
{
"type": "WEB",
"url": "http://www.ec-cube.net/info/weakness/20130626/index.php"
},
{
"type": "WEB",
"url": "http://www.ec-cube.net/info/weakness/weakness.php?id=49"
}
],
"schema_version": "1.4.0",
"severity": []
}
Mitigation
Strategy: Refactoring
Refactor your program so that you do not have to dynamically generate code.
Mitigation
- 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
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
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
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
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
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.