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.
8289 vulnerabilities reference this CWE, most recent first.
GHSA-CV3F-W5GJ-CCPF
Vulnerability from github – Published: 2025-02-20 00:32 – Updated: 2025-02-20 15:31Buffer Overflow vulnerability in Bento4 v.1.6.0-641 allows a local attacker to execute arbitrary code via the AP4_Stz2Atom::AP4_Stz2Atom component located in Ap4Stz2Atom.cpp.
{
"affected": [],
"aliases": [
"CVE-2025-25943"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-02-19T23:15:15Z",
"severity": "HIGH"
},
"details": "Buffer Overflow vulnerability in Bento4 v.1.6.0-641 allows a local attacker to execute arbitrary code via the AP4_Stz2Atom::AP4_Stz2Atom component located in Ap4Stz2Atom.cpp.",
"id": "GHSA-cv3f-w5gj-ccpf",
"modified": "2025-02-20T15:31:08Z",
"published": "2025-02-20T00:32:04Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-25943"
},
{
"type": "WEB",
"url": "https://github.com/axiomatic-systems/Bento4/issues/993"
}
],
"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-CV79-FF7V-6VX6
Vulnerability from github – Published: 2022-05-17 05:20 – Updated: 2022-05-17 05:20The (1) Traceroute and (2) Ping implementations in tools.php in SpamTitan WebTitan before 3.60 allow remote authenticated users to execute arbitrary commands via shell metacharacters in an argument, as demonstrated by an && (ampersand ampersand) sequence.
{
"affected": [],
"aliases": [
"CVE-2011-4639"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2012-10-08T10:47:00Z",
"severity": "MODERATE"
},
"details": "The (1) Traceroute and (2) Ping implementations in tools.php in SpamTitan WebTitan before 3.60 allow remote authenticated users to execute arbitrary commands via shell metacharacters in an argument, as demonstrated by an \u0026\u0026 (ampersand ampersand) sequence.",
"id": "GHSA-cv79-ff7v-6vx6",
"modified": "2022-05-17T05:20:41Z",
"published": "2022-05-17T05:20:41Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2011-4639"
},
{
"type": "WEB",
"url": "http://www.sec-1.com/blog/?p=211"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-CV8P-R9GW-9X34
Vulnerability from github – Published: 2022-05-14 03:23 – Updated: 2022-05-14 03:23In Gxlcms QY v1.0.0713, the update function in Lib\Lib\Action\Admin\TplAction.class.php allows remote attackers to execute arbitrary PHP code by placing this code into a template.
{
"affected": [],
"aliases": [
"CVE-2018-9847"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2018-04-07T21:29:00Z",
"severity": "CRITICAL"
},
"details": "In Gxlcms QY v1.0.0713, the update function in Lib\\Lib\\Action\\Admin\\TplAction.class.php allows remote attackers to execute arbitrary PHP code by placing this code into a template.",
"id": "GHSA-cv8p-r9gw-9x34",
"modified": "2022-05-14T03:23:51Z",
"published": "2022-05-14T03:23:51Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2018-9847"
},
{
"type": "WEB",
"url": "http://www.atksec.com/cve/GxlcmsQY-v1.0.0713-update-template-getshell/index.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-CVGP-9GF8-257Q
Vulnerability from github – Published: 2022-05-02 00:04 – Updated: 2022-05-02 00:04Unspecified "Command Injection" vulnerability in ZoneMinder 1.23.3 and earlier allows remote attackers to execute arbitrary commands via (1) the executeFilter function in zm_html_view_events.php and (2) the run_state parameter to zm_html_view_state.php.
{
"affected": [],
"aliases": [
"CVE-2008-3882"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2008-09-02T15:41:00Z",
"severity": "HIGH"
},
"details": "Unspecified \"Command Injection\" vulnerability in ZoneMinder 1.23.3 and earlier allows remote attackers to execute arbitrary commands via (1) the executeFilter function in zm_html_view_events.php and (2) the run_state parameter to zm_html_view_state.php.",
"id": "GHSA-cvgp-9gf8-257q",
"modified": "2022-05-02T00:04:40Z",
"published": "2022-05-02T00:04:40Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2008-3882"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/44728"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/31636"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/archive/1/495745/100/0/threaded"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/30843"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-CVJQ-RW47-X86V
Vulnerability from github – Published: 2025-06-06 12:30 – Updated: 2025-06-06 12:30Code injection vulnerability in IDF v0.10.0-0C03-03 and ZLF v0.10.0-0C03-04. This vulnerability allows an attacker to store malicious payload in software that will run in the victim's browser. Exploiting this vulnerability requires authenticating to the device and executing certain commands that can be executed only with permissions higher than the view permission.
{
"affected": [],
"aliases": [
"CVE-2025-41365"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-06-06T12:15:22Z",
"severity": "MODERATE"
},
"details": "Code injection vulnerability in IDF v0.10.0-0C03-03 and ZLF v0.10.0-0C03-04. This vulnerability allows an attacker to store malicious payload in software that will run in the victim\u0027s browser. Exploiting this vulnerability requires authenticating to the device and executing certain commands that can be executed only with permissions higher than the view permission.",
"id": "GHSA-cvjq-rw47-x86v",
"modified": "2025-06-06T12:30:33Z",
"published": "2025-06-06T12:30:33Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-41365"
},
{
"type": "WEB",
"url": "https://www.incibe.es/en/incibe-cert/notices/aviso-sci/multiple-vulnerabilities-zivs-idf-and-zlf-products"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/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-CVP7-C586-CMF4
Vulnerability from github – Published: 2022-01-28 22:01 – Updated: 2022-02-01 15:17Withdrawn
This advisory has been withdrawn after the maintainers of loguru noted this issue is not a security vulnerability and the CVE has been revoked. We have stopped Dependabot alerts regarding this issue.
Original Description
In versions of loguru up to and including 0.5.3 a lack of sanitization on log serialization can lead to arbitrary code execution. The maintainer disputes the issue, but has altered behavior of the library in commit 4b0070a4f30cbf6d5e12e6274b242b62ea11c81b. See https://github.com/Delgan/loguru/issues/563 for further discussion of the issue. The function in question is intended for internal use only, but is not restricted. This has been patched in version 0.6.0.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 0.5.3"
},
"package": {
"ecosystem": "PyPI",
"name": "loguru"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.6.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2022-0329"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": true,
"github_reviewed_at": "2022-01-25T23:33:20Z",
"nvd_published_at": "2022-01-21T11:15:00Z",
"severity": "LOW"
},
"details": "# Withdrawn\n\nThis advisory has been withdrawn after the maintainers of loguru noted this issue is not a security vulnerability and the CVE has been revoked. We have [stopped](https://github.com/Delgan/loguru/issues/563#issuecomment-1025223732) Dependabot alerts regarding this issue.\n\n## Original Description\n\nIn versions of loguru up to and including 0.5.3 a lack of sanitization on log serialization can lead to arbitrary code execution. The maintainer disputes the issue, but has altered behavior of the library in commit 4b0070a4f30cbf6d5e12e6274b242b62ea11c81b. See https://github.com/Delgan/loguru/issues/563 for further discussion of the issue. The function in question is intended for internal use only, but is not restricted. This has been patched in version 0.6.0.",
"id": "GHSA-cvp7-c586-cmf4",
"modified": "2022-02-01T15:17:33Z",
"published": "2022-01-28T22:01:45Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-0329"
},
{
"type": "WEB",
"url": "https://github.com/Delgan/loguru/issues/563"
},
{
"type": "WEB",
"url": "https://github.com/delgan/loguru/commit/4b0070a4f30cbf6d5e12e6274b242b62ea11c81b"
},
{
"type": "PACKAGE",
"url": "https://github.com/delgan/loguru"
},
{
"type": "WEB",
"url": "https://huntr.dev/bounties/1-pypi-loguru"
},
{
"type": "WEB",
"url": "https://tomforb.es/cve-2022-0329-and-the-problems-with-automated-vulnerability-management"
}
],
"schema_version": "1.4.0",
"severity": [],
"summary": "Withdrawn: Code Injection in loguru",
"withdrawn": "2022-02-01T15:17:33Z"
}
GHSA-CVP9-HWC6-X9XF
Vulnerability from github – Published: 2022-05-01 18:28 – Updated: 2025-04-09 03:46Multiple PHP remote file inclusion vulnerabilities in Webmedia Explorer (webmex) 3.2.2 allow remote attackers to execute arbitrary PHP code via (1) a URL in the path_include parameter to includes/rss.class.php, (2) a URL in the path_template parameter to (a) templates/main.tpl.php or (b) templates/folder_messages_link_message_name.tpl.php, or (4) a URL in the path_templates parameter to templates/sidebar.tpl.php. NOTE: the vulnerability is present only when the administrator does not follow installation instructions about the requirement for .htaccess support. NOTE: the includes/core.lib.php vector is already covered by CVE-2006-5252.
{
"affected": [],
"aliases": [
"CVE-2007-4948"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2007-09-18T20:17:00Z",
"severity": "MODERATE"
},
"details": "Multiple PHP remote file inclusion vulnerabilities in Webmedia Explorer (webmex) 3.2.2 allow remote attackers to execute arbitrary PHP code via (1) a URL in the path_include parameter to includes/rss.class.php, (2) a URL in the path_template parameter to (a) templates/main.tpl.php or (b) templates/folder_messages_link_message_name.tpl.php, or (4) a URL in the path_templates parameter to templates/sidebar.tpl.php. NOTE: the vulnerability is present only when the administrator does not follow installation instructions about the requirement for .htaccess support. NOTE: the includes/core.lib.php vector is already covered by CVE-2006-5252.",
"id": "GHSA-cvp9-hwc6-x9xf",
"modified": "2025-04-09T03:46:20Z",
"published": "2022-05-01T18:28:34Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2007-4948"
},
{
"type": "WEB",
"url": "http://arfis.wordpress.com/2007/09/14/rfi-03-webmedia-explorer"
},
{
"type": "WEB",
"url": "http://osvdb.org/43140"
},
{
"type": "WEB",
"url": "http://osvdb.org/43141"
},
{
"type": "WEB",
"url": "http://osvdb.org/43142"
},
{
"type": "WEB",
"url": "http://osvdb.org/43143"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-CVV5-9H9W-QP2M
Vulnerability from github – Published: 2024-12-20 19:13 – Updated: 2024-12-20 21:37Summary
The SSID is not sanitized when before it is passed as a parameter to cmd.exe in the getWindowsIEEE8021x function. This means that malicious content in the SSID can be executed as OS commands.
Details
I have exploited this vulnerability in a Windows service using version 5.22.11 of the module, to escalate privileges (in an environment where I am authorized to do so). However, as far as I can see from the code, it is still present in master branch at time of writing, on line 403/404 of network.js.
The SSID is obtained from netsh wlan show interface ... in getWindowsWirelessIfaceSSID, and then passed to cmd.exe /d /s /c "netsh wlan show profiles ... in getWindowsIEEE8021x, without sanitization.
PoC
First, the command injection payload should be included in the connected Wi-Fi SSID. For example create hotspot on mobile phone or other laptop, set SSID to payload, connect to it with victim Windows system. Two example SSID's to demonstrate exploitation are below.
Demonstration to run ping command indefinitely:
a" | ping /t 127.0.0.1 &
Run executable with privileges of the user in which vulnerable function is executed. Chosen executable should should be placed in (assuming system drive is C): C:\a\a.exe.
a" | %SystemDrive%\a\a.exe &
Then, the vulnerable function can be executed on the victim system, for example, using:
const si = require('systeminformation');
si.networkInterfaces((net) => { console.log(net) });
Now the chosen command, PING.exe or a.exe will be run through the cmd.exe command line.
Impact
This vulnerability may enable an attacker, depending on how the package is used, to perform remote code execution or local privilege escalation.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 5.23.6"
},
"package": {
"ecosystem": "npm",
"name": "systeminformation"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "5.23.7"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2024-56334"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": true,
"github_reviewed_at": "2024-12-20T19:13:23Z",
"nvd_published_at": "2024-12-20T21:15:10Z",
"severity": "HIGH"
},
"details": "### Summary\nThe SSID is not sanitized when before it is passed as a parameter to cmd.exe in the `getWindowsIEEE8021x` function. This means that malicious content in the SSID can be executed as OS commands. \n\n### Details\nI have exploited this vulnerability in a Windows service using version 5.22.11 of the module, to escalate privileges (in an environment where I am authorized to do so). However, as far as I can see from the code, it is still present in master branch at time of writing, on line [403/404 of network.js](https://github.com/sebhildebrandt/systeminformation/blob/3a92931c7d46605ffddc1aacb97a9727273b2888/lib/network.js#L403).\n\nThe SSID is obtained from `netsh wlan show interface ...` in `getWindowsWirelessIfaceSSID`, and then passed to `cmd.exe /d /s /c \"netsh wlan show profiles ...` in `getWindowsIEEE8021x`, without sanitization.\n\n### PoC\nFirst, the command injection payload should be included in the connected Wi-Fi SSID. For example create hotspot on mobile phone or other laptop, set SSID to payload, connect to it with victim Windows system. Two example SSID\u0027s to demonstrate exploitation are below.\n\nDemonstration to run ping command indefinitely:\n```\na\" | ping /t 127.0.0.1 \u0026\n```\n\nRun executable with privileges of the user in which vulnerable function is executed. Chosen executable should should be placed in (assuming system drive is C): `C:\\a\\a.exe`.\n```\na\" | %SystemDrive%\\a\\a.exe \u0026\n```\n\nThen, the vulnerable function can be executed on the victim system, for example, using:\n```\nconst si = require(\u0027systeminformation\u0027);\nsi.networkInterfaces((net) =\u003e { console.log(net) });\n```\n\nNow the chosen command, `PING.exe` or `a.exe` will be run through the cmd.exe command line.\n\n### Impact\nThis vulnerability may enable an attacker, depending on how the package is used, to perform remote code execution or local privilege escalation.\n\n",
"id": "GHSA-cvv5-9h9w-qp2m",
"modified": "2024-12-20T21:37:00Z",
"published": "2024-12-20T19:13:23Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/sebhildebrandt/systeminformation/security/advisories/GHSA-cvv5-9h9w-qp2m"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-56334"
},
{
"type": "WEB",
"url": "https://github.com/sebhildebrandt/systeminformation/commit/f7af0a67b78e7894335a6cad510566a25e06ae41"
},
{
"type": "PACKAGE",
"url": "https://github.com/sebhildebrandt/systeminformation"
}
],
"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"
}
],
"summary": "Systeminformation has command injection vulnerability in getWindowsIEEE8021x (SSID)"
}
GHSA-CVV9-F32P-CP3V
Vulnerability from github – Published: 2022-05-17 02:00 – Updated: 2022-05-17 02:00The Blueberry FlashBack ActiveX control in BB FlashBack Recorder.dll in Blueberry BB FlashBack, as used in IBM Rational Rhapsody before 7.6.1 and other products, does not properly implement the TestCompatibilityRecordMode method, which allows remote attackers to execute arbitrary code via unspecified vectors.
{
"affected": [],
"aliases": [
"CVE-2011-1388"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2011-12-23T22:55:00Z",
"severity": "HIGH"
},
"details": "The Blueberry FlashBack ActiveX control in BB FlashBack Recorder.dll in Blueberry BB FlashBack, as used in IBM Rational Rhapsody before 7.6.1 and other products, does not properly implement the TestCompatibilityRecordMode method, which allows remote attackers to execute arbitrary code via unspecified vectors.",
"id": "GHSA-cvv9-f32p-cp3v",
"modified": "2022-05-17T02:00:43Z",
"published": "2022-05-17T02:00:43Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2011-1388"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/71694"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/47286"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/47310"
},
{
"type": "WEB",
"url": "http://www-01.ibm.com/support/docview.wss?uid=swg21576352"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-CVW4-VC58-FHX4
Vulnerability from github – Published: 2025-05-25 18:30 – Updated: 2025-05-25 18:30A vulnerability classified as critical has been found in defog-ai introspect up to 0.1.4. This affects the function execute_analysis_code_safely of the file introspect/backend/tools/analysis_tools.py. The manipulation of the argument code leads to code injection. It is possible to launch the attack on the local host. The exploit has been disclosed to the public and may be used. The patch is named 502. It is recommended to apply a patch to fix this issue. The code maintainer explains, that "[they] have added some workarounds to address this in #502, but will not be implementing a full fix. This is because this repo is meant to be run in a docker environment, which will significantly mitigate potential security risks. Having said that, we have added a SECURITY section in our README to make this clearer to users."
{
"affected": [],
"aliases": [
"CVE-2025-5151"
],
"database_specific": {
"cwe_ids": [
"CWE-74",
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-05-25T17:15:20Z",
"severity": "MODERATE"
},
"details": "A vulnerability classified as critical has been found in defog-ai introspect up to 0.1.4. This affects the function execute_analysis_code_safely of the file introspect/backend/tools/analysis_tools.py. The manipulation of the argument code leads to code injection. It is possible to launch the attack on the local host. The exploit has been disclosed to the public and may be used. The patch is named 502. It is recommended to apply a patch to fix this issue. The code maintainer explains, that \"[they] have added some workarounds to address this in #502, but will not be implementing a full fix. This is because this repo is meant to be run in a docker environment, which will significantly mitigate potential security risks. Having said that, we have added a SECURITY section in our README to make this clearer to users.\"",
"id": "GHSA-cvw4-vc58-fhx4",
"modified": "2025-05-25T18:30:29Z",
"published": "2025-05-25T18:30:29Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-5151"
},
{
"type": "WEB",
"url": "https://github.com/defog-ai/introspect/issues/495"
},
{
"type": "WEB",
"url": "https://github.com/defog-ai/introspect/issues/495#issue-3036141048"
},
{
"type": "WEB",
"url": "https://github.com/defog-ai/introspect/issues/495#issuecomment-2894640278"
},
{
"type": "WEB",
"url": "https://github.com/defog-ai/introspect/pull/502"
},
{
"type": "WEB",
"url": "https://vuldb.com/?ctiid.310239"
},
{
"type": "WEB",
"url": "https://vuldb.com/?id.310239"
},
{
"type": "WEB",
"url": "https://vuldb.com/?submit.574809"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:L/SC:N/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"
}
]
}
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.