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.

8326 vulnerabilities reference this CWE, most recent first.

GHSA-RWMQ-JM93-PMPF

Vulnerability from github – Published: 2025-09-05 15:31 – Updated: 2026-04-01 18:36
VLAI
Details

Improper Control of Generation of Code ('Code Injection') vulnerability in PickPlugins Job Board Manager allows Code Injection. This issue affects Job Board Manager: from n/a through 2.1.61.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-58827"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-09-05T14:15:54Z",
    "severity": "LOW"
  },
  "details": "Improper Control of Generation of Code (\u0027Code Injection\u0027) vulnerability in PickPlugins Job Board Manager allows Code Injection. This issue affects Job Board Manager: from n/a through 2.1.61.",
  "id": "GHSA-rwmq-jm93-pmpf",
  "modified": "2026-04-01T18:36:05Z",
  "published": "2025-09-05T15:31:08Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-58827"
    },
    {
      "type": "WEB",
      "url": "https://patchstack.com/database/wordpress/plugin/job-board-manager/vulnerability/wordpress-job-board-manager-plugin-2-1-61-content-injection-vulnerability?_s_id=cve"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:N",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-RWQG-MW4Q-JJ4C

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

PHP remote file inclusion vulnerability in index.php in sCssBoard 1.0, 1.1, 1.11, and 1.12 allows remote attackers to execute arbitrary PHP code via a URL in the inc_function parameter.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2008-5577"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2008-12-15T18:00:00Z",
    "severity": "HIGH"
  },
  "details": "PHP remote file inclusion vulnerability in index.php in sCssBoard 1.0, 1.1, 1.11, and 1.12 allows remote attackers to execute arbitrary PHP code via a URL in the inc_function parameter.",
  "id": "GHSA-rwqg-mw4q-jj4c",
  "modified": "2022-05-17T00:43:55Z",
  "published": "2022-05-17T00:43:55Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2008-5577"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/47457"
    },
    {
      "type": "WEB",
      "url": "https://www.exploit-db.com/exploits/5149"
    },
    {
      "type": "WEB",
      "url": "http://securityreason.com/securityalert/4739"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-RWR9-36P6-24VW

Vulnerability from github – Published: 2022-05-24 19:02 – Updated: 2022-10-25 19:00
VLAI
Details

RabbitMQ installers on Windows prior to version 3.8.16 do not harden plugin directory permissions, potentially allowing attackers with sufficient local filesystem permissions to add arbitrary plugins.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2021-22117"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-732",
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2021-05-18T13:15:00Z",
    "severity": "HIGH"
  },
  "details": "RabbitMQ installers on Windows prior to version 3.8.16 do not harden plugin directory permissions, potentially allowing attackers with sufficient local filesystem permissions to add arbitrary plugins.",
  "id": "GHSA-rwr9-36p6-24vw",
  "modified": "2022-10-25T19:00:30Z",
  "published": "2022-05-24T19:02:43Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2021-22117"
    },
    {
      "type": "WEB",
      "url": "https://tanzu.vmware.com/security/cve-2021-22117"
    }
  ],
  "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-RWV5-X4XJ-5577

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

Incomplete blacklist vulnerability in Launch Services in Apple Mac OS X 10.5.8 allows user-assisted remote attackers to execute arbitrary code via a .fileloc file, which does not trigger a "potentially unsafe" warning message in the Quarantine feature.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2009-2811"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2009-09-14T16:30:00Z",
    "severity": "MODERATE"
  },
  "details": "Incomplete blacklist vulnerability in Launch Services in Apple Mac OS X 10.5.8 allows user-assisted remote attackers to execute arbitrary code via a .fileloc file, which does not trigger a \"potentially unsafe\" warning message in the Quarantine feature.",
  "id": "GHSA-rwv5-x4xj-5577",
  "modified": "2022-05-02T03:38:54Z",
  "published": "2022-05-02T03:38:53Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2009-2811"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/53171"
    },
    {
      "type": "WEB",
      "url": "http://lists.apple.com/archives/security-announce/2009/Sep/msg00004.html"
    },
    {
      "type": "WEB",
      "url": "http://osvdb.org/57953"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/36701"
    },
    {
      "type": "WEB",
      "url": "http://support.apple.com/kb/HT3865"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/36360"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-RWWX-GX55-3MQ6

Vulnerability from github – Published: 2025-09-08 15:37 – Updated: 2025-09-08 15:37
VLAI
Details

rsbi-os 4.7 is vulnerable to Remote Code Execution (RCE) in sqlite-jdbc.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-57141"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-09-08T15:15:36Z",
    "severity": "CRITICAL"
  },
  "details": "rsbi-os 4.7 is vulnerable to Remote Code Execution (RCE) in sqlite-jdbc.",
  "id": "GHSA-rwwx-gx55-3mq6",
  "modified": "2025-09-08T15:37:45Z",
  "published": "2025-09-08T15:37:45Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-57141"
    },
    {
      "type": "WEB",
      "url": "https://github.com/line2222/vuln/issues/2"
    },
    {
      "type": "WEB",
      "url": "https://github.com/ruisibi/rsbi-os"
    }
  ],
  "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-RWXP-HWWF-653V

Vulnerability from github – Published: 2021-05-17 20:58 – Updated: 2023-04-04 17:30
VLAI
Summary
Insecure template handling in express-hbs
Details

express-hbs is an Express handlebars template engine. express-hbs mixes pure template data with engine configuration options through the Express render API. More specifically, the layout parameter may trigger file disclosure vulnerabilities in downstream applications. This potential vulnerability is somewhat restricted in that only files with existing extentions (i.e. file.extension) can be included, files that lack an extension will have .hbs appended to them. For complete details refer to the referenced GHSL-2021-019 report. Notes in documentation have been added to help users of express-hbs avoid this potential information exposure vulnerability.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "npm",
        "name": "express-hbs"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "last_affected": "2.4.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2021-32817"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-200",
      "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2021-05-17T19:09:07Z",
    "nvd_published_at": "2021-05-14T19:15:00Z",
    "severity": "MODERATE"
  },
  "details": "express-hbs is an Express handlebars template engine. express-hbs mixes pure template data with engine configuration options through the Express render API. More specifically, the layout parameter may trigger file disclosure vulnerabilities in downstream applications. This potential vulnerability is somewhat restricted in that only files with existing extentions (i.e. file.extension) can be included, files that lack an extension will have .hbs appended to them. For complete details refer to the referenced GHSL-2021-019 report. Notes in documentation have been added to help users of express-hbs avoid this potential information exposure vulnerability.",
  "id": "GHSA-rwxp-hwwf-653v",
  "modified": "2023-04-04T17:30:41Z",
  "published": "2021-05-17T20:58:51Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2021-32817"
    },
    {
      "type": "WEB",
      "url": "https://github.com/TryGhost/express-hbs/commit/ff6fad6e357699412d4e916273314e5e7af1500e"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/TryGhost/express-hbs"
    },
    {
      "type": "WEB",
      "url": "https://github.com/TryGhost/express-hbs#%EF%B8%8F-this-creates-a-potential-security-vulnerability"
    },
    {
      "type": "ADVISORY",
      "url": "https://securitylab.github.com/advisories/GHSL-2021-019-express-hbs"
    },
    {
      "type": "WEB",
      "url": "https://www.npmjs.com/package/express-hbs"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N",
      "type": "CVSS_V3"
    }
  ],
  "summary": "Insecure template handling in express-hbs"
}

GHSA-RX39-82VR-XG3P

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

job/uploadfile_save.php in MetInfo through 5.3.17 blocks the .php extension but not related extensions, which might allow remote authenticated admins to execute arbitrary PHP code by uploading a .phtml file after certain actions involving admin/system/safe.php and job/cv.php.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2017-11715"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2017-07-28T05:29:00Z",
    "severity": "CRITICAL"
  },
  "details": "job/uploadfile_save.php in MetInfo through 5.3.17 blocks the .php extension but not related extensions, which might allow remote authenticated admins to execute arbitrary PHP code by uploading a .phtml file after certain actions involving admin/system/safe.php and job/cv.php.",
  "id": "GHSA-rx39-82vr-xg3p",
  "modified": "2022-05-17T02:15:35Z",
  "published": "2022-05-17T02:15:35Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2017-11715"
    },
    {
      "type": "WEB",
      "url": "https://lncken.cn/?p=316"
    }
  ],
  "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-RX4H-526Q-4458

Vulnerability from github – Published: 2026-03-31 23:28 – Updated: 2026-04-06 16:40
VLAI
Summary
SiYuan: Stored XSS in Attribute View Gallery/Kanban Cover Rendering Allows Arbitrary Command Execution in Desktop Client
Details

Summary

An attacker who can place a malicious URL in an Attribute View mAsse field can trigger stored XSS when a victim opens the Gallery or Kanban view with “Cover From -> Asset Field” enabled. The vulnerable code accepts arbitrary http(s) URLs without extensions as images, stores the attacker-controlled string in coverURL, and injects it directly into an <img src="..."> attribute without escaping. In the Electron desktop client, the injected JavaScript executes with nodeIntegration enabled and contextIsolation disabled, so the XSS reaches arbitrary OS command execution under the victim’s account.

Details

The vulnerable flow is:

  1. IsPossiblyImage(assetPath) accepts arbitrary http(s) URLs without validating that they are safe image URLs.
  2. When an Attribute View card uses Cover From -> Asset Field, the application copies asset.Content directly into galleryCard.CoverURL / kanbanCard.CoverURL.
  3. The front-end renderer inserts coverURL directly into <img src="${getCompressURL(item.coverURL)}"> without escaping quotes or other attribute-breaking characters.
  4. A payload such as https://example.com/" onerror="require('child_process').exec('calc') breaks out of the src attribute and adds an attacker-controlled onerror handler. When the image fails to load, the injected JavaScript runs in the Electron renderer. Because the desktop app enables nodeIntegration: true and disables contextIsolation and webSecurity, that JavaScript can access Node.js APIs and execute system commands.

PoC

  1. Install Electron Desktop app.
  2. Create a database / Attribute View with an mAsset column and add at least one row.
  3. Add any legitimate image to that mAsset field so the entry is stored as type image.
  4. Switch the view to Gallery or Kanban. 5.Set Cover From to Asset Field and choose the mAsset column.
  5. Edit the existing image asset entry and replace its link with the following payload:
https://example.com/" onerror="require('child_process').exec('calc')
  1. Save the change and reopen or refresh the Gallery / Kanban view.
  2. Observe that the rendered HTML contains an injected onerror handler and the Calculator application starts on Windows.

Example rendered output:

<img loading="lazy" class="av__gallery-img" src="https://example.com/" onerror="require('child_process').exec('calc')">

Impact

An attacker can store malicious content in a database asset field and execute arbitrary JavaScript when another user opens the affected Gallery or Kanban view. In the desktop client, that JavaScript has access to Node.js APIs, so the impact is not limited to browser-context XSS. The payload executes OS commands with the victim’s local user privileges, which turns this into remote code execution on the desktop application once the malicious content is delivered and rendered.

Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 3.6.1"
      },
      "package": {
        "ecosystem": "Go",
        "name": "github.com/siyuan-note/siyuan/kernel"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "3.6.2"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-34448"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-79",
      "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-03-31T23:28:23Z",
    "nvd_published_at": "2026-03-31T22:16:19Z",
    "severity": "CRITICAL"
  },
  "details": "### Summary\nAn attacker who can place a malicious URL in an Attribute View `mAsse` field can trigger stored XSS when a victim opens the Gallery or Kanban view with \u201cCover From -\u003e Asset Field\u201d enabled. The vulnerable code accepts arbitrary `http(s)` URLs without extensions as images, stores the attacker-controlled string in `coverURL`, and injects it directly into an `\u003cimg src=\"...\"\u003e` attribute without escaping. In the Electron desktop client, the injected JavaScript executes with `nodeIntegration` enabled and `contextIsolation` disabled, so the XSS reaches arbitrary OS command execution under the victim\u2019s account.\n\n### Details\nThe vulnerable flow is:\n\n1. `IsPossiblyImage(assetPath)` accepts arbitrary `http(s)` URLs without validating that they are safe image URLs.\n2. When an Attribute View card uses `Cover From -\u003e Asset Field`, the application copies `asset.Content` directly into `galleryCard.CoverURL / kanbanCard.CoverURL`.\n3. The front-end renderer inserts `coverURL` directly into `\u003cimg src=\"${getCompressURL(item.coverURL)}\"\u003e` without escaping quotes or other attribute-breaking characters.\n4. A payload such as `https://example.com/\" onerror=\"require(\u0027child_process\u0027).exec(\u0027calc\u0027)` breaks out of the `src` attribute and adds an attacker-controlled `onerror` handler.\nWhen the image fails to load, the injected JavaScript runs in the Electron renderer. Because the desktop app enables `nodeIntegration: true` and disables `contextIsolation` and `webSecurity`, that JavaScript can access Node.js APIs and execute system commands.\n\n### PoC\n1. Install Electron Desktop app.\n2. Create a database / Attribute View with an mAsset column and add at least one row.\n3. Add any legitimate image to that mAsset field so the entry is stored as type image.\n4. Switch the view to Gallery or Kanban.\n5.Set Cover From to Asset Field and choose the mAsset column.\n6. Edit the existing image asset entry and replace its link with the following payload:\n```\nhttps://example.com/\" onerror=\"require(\u0027child_process\u0027).exec(\u0027calc\u0027)\n```\n7. Save the change and reopen or refresh the Gallery / Kanban view.\n8. Observe that the rendered HTML contains an injected onerror handler and the Calculator application starts on Windows.\n\nExample rendered output:\n```html\n\u003cimg loading=\"lazy\" class=\"av__gallery-img\" src=\"https://example.com/\" onerror=\"require(\u0027child_process\u0027).exec(\u0027calc\u0027)\"\u003e\n```\n### Impact\nAn attacker can store malicious content in a database asset field and execute arbitrary JavaScript when another user opens the affected Gallery or Kanban view. In the desktop client, that JavaScript has access to Node.js APIs, so the impact is not limited to browser-context XSS. The payload executes OS commands with the victim\u2019s local user privileges, which turns this into remote code execution on the desktop application once the malicious content is delivered and rendered.",
  "id": "GHSA-rx4h-526q-4458",
  "modified": "2026-04-06T16:40:00Z",
  "published": "2026-03-31T23:28:23Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/siyuan-note/siyuan/security/advisories/GHSA-rx4h-526q-4458"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-34448"
    },
    {
      "type": "WEB",
      "url": "https://github.com/siyuan-note/siyuan/issues/17246"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/siyuan-note/siyuan"
    },
    {
      "type": "WEB",
      "url": "https://github.com/siyuan-note/siyuan/releases/tag/v3.6.2"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "SiYuan: Stored XSS in Attribute View Gallery/Kanban Cover Rendering Allows Arbitrary Command Execution in Desktop Client"
}

GHSA-RX4W-347Q-2M87

Vulnerability from github – Published: 2022-07-13 00:00 – Updated: 2022-07-13 00:00
VLAI
Details

Windows Network File System Remote Code Execution Vulnerability. This CVE ID is unique from CVE-2022-22029.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2022-22039"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2022-07-12T23:15:00Z",
    "severity": "HIGH"
  },
  "details": "Windows Network File System Remote Code Execution Vulnerability. This CVE ID is unique from CVE-2022-22029.",
  "id": "GHSA-rx4w-347q-2m87",
  "modified": "2022-07-13T00:00:39Z",
  "published": "2022-07-13T00:00:39Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2022-22039"
    },
    {
      "type": "WEB",
      "url": "https://msrc.microsoft.com/update-guide/vulnerability/CVE-2022-22039"
    },
    {
      "type": "WEB",
      "url": "https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2022-22039"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-RXG9-73C5-FC9F

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

SAP MaxDB ODBC driver (all versions before 7.9.09.07) allows an attacker to inject code that can be executed by the application. An attacker could thereby control the behavior of the application.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2018-2418"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-94"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2018-05-09T20:29:00Z",
    "severity": "CRITICAL"
  },
  "details": "SAP MaxDB ODBC driver (all versions before 7.9.09.07) allows an attacker to inject code that can be executed by the application. An attacker could thereby control the behavior of the application.",
  "id": "GHSA-rxg9-73c5-fc9f",
  "modified": "2022-05-13T01:32:22Z",
  "published": "2022-05-13T01:32:22Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2018-2418"
    },
    {
      "type": "WEB",
      "url": "https://blogs.sap.com/2018/05/08/sap-security-patch-day-may-2018"
    },
    {
      "type": "WEB",
      "url": "https://launchpad.support.sap.com/#/notes/2610231"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/104115"
    }
  ],
  "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"
    }
  ]
}

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.