CVE-2023-40581 (GCVE-0-2023-40581)
Vulnerability from cvelistv5
Published
2023-09-25 18:54
Modified
2024-09-24 14:48
CWE
  • CWE-78 - Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Summary
yt-dlp is a youtube-dl fork with additional features and fixes. yt-dlp allows the user to provide shell command lines to be executed at various stages in its download steps through the `--exec` flag. This flag allows output template expansion in its argument, so that metadata values may be used in the shell commands. The metadata fields can be combined with the `%q` conversion, which is intended to quote/escape these values so they can be safely passed to the shell. However, the escaping used for `cmd` (the shell used by Python's `subprocess` on Windows) does not properly escape special characters, which can allow for remote code execution if `--exec` is used directly with maliciously crafted remote data. This vulnerability only impacts `yt-dlp` on Windows, and the vulnerability is present regardless of whether `yt-dlp` is run from `cmd` or from `PowerShell`. Support for output template expansion in `--exec`, along with this vulnerable behavior, was added to `yt-dlp` in version 2021.04.11. yt-dlp version 2023.09.24 fixes this issue by properly escaping each special character. `\n` will be replaced by `\r` as no way of escaping it has been found. It is recommended to upgrade yt-dlp to version 2023.09.24 as soon as possible. Also, always be careful when using --exec, because while this specific vulnerability has been patched, using unvalidated input in shell commands is inherently dangerous. For Windows users who are not able to upgrade: 1. Avoid using any output template expansion in --exec other than {} (filepath). 2. If expansion in --exec is needed, verify the fields you are using do not contain ", | or &. 3. Instead of using --exec, write the info json and load the fields from it instead.
Impacted products
Vendor Product Version
yt-dlp yt-dlp Version: >= 2021.04.11, < 2023.09.24
Version: < nightly 2023.09.24.003044
Create a notification for this product.
Show details on NVD website


{
  "containers": {
    "adp": [
      {
        "providerMetadata": {
          "dateUpdated": "2024-08-02T18:38:50.806Z",
          "orgId": "af854a3a-2127-422b-91ae-364da2661108",
          "shortName": "CVE"
        },
        "references": [
          {
            "name": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg",
            "tags": [
              "x_refsource_CONFIRM",
              "x_transferred"
            ],
            "url": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg"
          },
          {
            "name": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e",
            "tags": [
              "x_refsource_MISC",
              "x_transferred"
            ],
            "url": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e"
          },
          {
            "name": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044",
            "tags": [
              "x_refsource_MISC",
              "x_transferred"
            ],
            "url": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044"
          },
          {
            "name": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11",
            "tags": [
              "x_refsource_MISC",
              "x_transferred"
            ],
            "url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11"
          },
          {
            "name": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24",
            "tags": [
              "x_refsource_MISC",
              "x_transferred"
            ],
            "url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24"
          }
        ],
        "title": "CVE Program Container"
      },
      {
        "affected": [
          {
            "cpes": [
              "cpe:2.3:a:yt-dlp_project:yt-dlp:-:*:*:*:*:*:*:*"
            ],
            "defaultStatus": "unknown",
            "product": "yt-dlp",
            "vendor": "yt-dlp_project",
            "versions": [
              {
                "lessThan": "2023.09.24",
                "status": "affected",
                "version": "2021.04.11",
                "versionType": "custom"
              },
              {
                "lessThan": "nightly 2023.09.24.003044",
                "status": "affected",
                "version": "0",
                "versionType": "custom"
              }
            ]
          }
        ],
        "metrics": [
          {
            "other": {
              "content": {
                "id": "CVE-2023-40581",
                "options": [
                  {
                    "Exploitation": "none"
                  },
                  {
                    "Automatable": "no"
                  },
                  {
                    "Technical Impact": "total"
                  }
                ],
                "role": "CISA Coordinator",
                "timestamp": "2024-09-24T14:45:30.642943Z",
                "version": "2.0.3"
              },
              "type": "ssvc"
            }
          }
        ],
        "providerMetadata": {
          "dateUpdated": "2024-09-24T14:48:55.952Z",
          "orgId": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
          "shortName": "CISA-ADP"
        },
        "title": "CISA ADP Vulnrichment"
      }
    ],
    "cna": {
      "affected": [
        {
          "product": "yt-dlp",
          "vendor": "yt-dlp",
          "versions": [
            {
              "status": "affected",
              "version": "\u003e= 2021.04.11, \u003c 2023.09.24"
            },
            {
              "status": "affected",
              "version": "\u003c nightly 2023.09.24.003044"
            }
          ]
        }
      ],
      "descriptions": [
        {
          "lang": "en",
          "value": "yt-dlp is a youtube-dl fork with additional features and fixes. yt-dlp allows the user to provide shell command lines to be executed at various stages in its download steps through the `--exec` flag. This flag allows output template expansion in its argument, so that metadata values may be used in the shell commands. The metadata fields can be combined with the `%q` conversion, which is intended to quote/escape these values so they can be safely passed to the shell. However, the escaping used for `cmd` (the shell used by Python\u0027s `subprocess` on Windows) does not properly escape special characters, which can allow for remote code execution if `--exec` is used directly with maliciously crafted remote data. This vulnerability only impacts `yt-dlp` on Windows, and the vulnerability is present regardless of whether `yt-dlp` is run from `cmd` or from `PowerShell`. Support for output template expansion in `--exec`, along with this vulnerable behavior, was added to `yt-dlp` in version 2021.04.11. yt-dlp version 2023.09.24 fixes this issue by properly escaping each special character. `\\n` will be replaced by `\\r` as no way of escaping it has been found. It is recommended to upgrade yt-dlp to version 2023.09.24 as soon as possible. Also, always be careful when using --exec, because while this specific vulnerability has been patched, using unvalidated input in shell commands is inherently dangerous. For Windows users who are not able to upgrade: 1. Avoid using any output template expansion in --exec other than {} (filepath). 2. If expansion in --exec is needed, verify the fields you are using do not contain \", | or \u0026. 3. Instead of using --exec, write the info json and load the fields from it instead.\n"
        }
      ],
      "metrics": [
        {
          "cvssV3_1": {
            "attackComplexity": "HIGH",
            "attackVector": "NETWORK",
            "availabilityImpact": "HIGH",
            "baseScore": 8.4,
            "baseSeverity": "HIGH",
            "confidentialityImpact": "HIGH",
            "integrityImpact": "HIGH",
            "privilegesRequired": "NONE",
            "scope": "CHANGED",
            "userInteraction": "REQUIRED",
            "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H",
            "version": "3.1"
          }
        }
      ],
      "problemTypes": [
        {
          "descriptions": [
            {
              "cweId": "CWE-78",
              "description": "CWE-78: Improper Neutralization of Special Elements used in an OS Command (\u0027OS Command Injection\u0027)",
              "lang": "en",
              "type": "CWE"
            }
          ]
        }
      ],
      "providerMetadata": {
        "dateUpdated": "2023-09-25T18:54:00.204Z",
        "orgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
        "shortName": "GitHub_M"
      },
      "references": [
        {
          "name": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg",
          "tags": [
            "x_refsource_CONFIRM"
          ],
          "url": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg"
        },
        {
          "name": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e",
          "tags": [
            "x_refsource_MISC"
          ],
          "url": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e"
        },
        {
          "name": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044",
          "tags": [
            "x_refsource_MISC"
          ],
          "url": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044"
        },
        {
          "name": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11",
          "tags": [
            "x_refsource_MISC"
          ],
          "url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11"
        },
        {
          "name": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24",
          "tags": [
            "x_refsource_MISC"
          ],
          "url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24"
        }
      ],
      "source": {
        "advisory": "GHSA-42h4-v29r-42qg",
        "discovery": "UNKNOWN"
      },
      "title": "yt-dlp command injection when using `%q` in `--exec` on Windows"
    }
  },
  "cveMetadata": {
    "assignerOrgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
    "assignerShortName": "GitHub_M",
    "cveId": "CVE-2023-40581",
    "datePublished": "2023-09-25T18:54:00.204Z",
    "dateReserved": "2023-08-16T18:24:02.391Z",
    "dateUpdated": "2024-09-24T14:48:55.952Z",
    "state": "PUBLISHED"
  },
  "dataType": "CVE_RECORD",
  "dataVersion": "5.1",
  "vulnerability-lookup:meta": {
    "nvd": "{\"cve\":{\"id\":\"CVE-2023-40581\",\"sourceIdentifier\":\"security-advisories@github.com\",\"published\":\"2023-09-25T19:15:09.960\",\"lastModified\":\"2024-11-21T08:19:45.480\",\"vulnStatus\":\"Modified\",\"cveTags\":[],\"descriptions\":[{\"lang\":\"en\",\"value\":\"yt-dlp is a youtube-dl fork with additional features and fixes. yt-dlp allows the user to provide shell command lines to be executed at various stages in its download steps through the `--exec` flag. This flag allows output template expansion in its argument, so that metadata values may be used in the shell commands. The metadata fields can be combined with the `%q` conversion, which is intended to quote/escape these values so they can be safely passed to the shell. However, the escaping used for `cmd` (the shell used by Python\u0027s `subprocess` on Windows) does not properly escape special characters, which can allow for remote code execution if `--exec` is used directly with maliciously crafted remote data. This vulnerability only impacts `yt-dlp` on Windows, and the vulnerability is present regardless of whether `yt-dlp` is run from `cmd` or from `PowerShell`. Support for output template expansion in `--exec`, along with this vulnerable behavior, was added to `yt-dlp` in version 2021.04.11. yt-dlp version 2023.09.24 fixes this issue by properly escaping each special character. `\\\\n` will be replaced by `\\\\r` as no way of escaping it has been found. It is recommended to upgrade yt-dlp to version 2023.09.24 as soon as possible. Also, always be careful when using --exec, because while this specific vulnerability has been patched, using unvalidated input in shell commands is inherently dangerous. For Windows users who are not able to upgrade: 1. Avoid using any output template expansion in --exec other than {} (filepath). 2. If expansion in --exec is needed, verify the fields you are using do not contain \\\", | or \u0026. 3. Instead of using --exec, write the info json and load the fields from it instead.\\n\"},{\"lang\":\"es\",\"value\":\"yt-dlp es un fork de youtube-dl con funciones y correcciones adicionales. yt-dlp permite al usuario proporcionar l\u00edneas de comando de shell para ejecutar en varias etapas de sus pasos de descarga a trav\u00e9s del indicador `--exec`. Este indicador permite la expansi\u00f3n de la plantilla de salida en su argumento, de modo que los valores de metadatos se puedan usar en los comandos del shell. Los campos de metadatos se pueden combinar con la conversi\u00f3n `%q`, cuyo objetivo es citar/escapar estos valores para que puedan pasarse de forma segura al shell. Sin embargo, el escape usado para `cmd` (el shell usado por el `subproceso` de Python en Windows) no escapa adecuadamente a los caracteres especiales, lo que puede permitir la ejecuci\u00f3n remota de c\u00f3digo si `--exec` se usa directamente con datos remotos creados con fines maliciosos. Esta vulnerabilidad solo afecta a \\\"yt-dlp\\\" en Windows y est\u00e1 presente independientemente de si \\\"yt-dlp\\\" se ejecuta desde \\\"cmd\\\" o desde \\\"PowerShell\\\". La compatibilidad con la expansi\u00f3n de la plantilla de salida en `--exec`, junto con este comportamiento vulnerable, se agreg\u00f3 a `yt-dlp` en la versi\u00f3n 2021.04.11. La versi\u00f3n 2023.09.24 de yt-dlp soluciona este problema escapando correctamente cada car\u00e1cter especial. `\\\\n` ser\u00e1 reemplazado por `\\\\r` ya que no se ha encontrado ninguna forma de escapar. Se recomienda actualizar yt-dlp a la versi\u00f3n 2023.09.24 lo antes posible. Adem\u00e1s, siempre tenga cuidado al usar --exec, porque si bien esta vulnerabilidad espec\u00edfica ha sido parcheada, usar entradas no validadas en los comandos del shell es inherentemente peligroso. Para usuarios de Windows que no pueden actualizar: 1. Evite utilizar cualquier expansi\u00f3n de plantilla de salida en --exec que no sea {} (ruta de archivo). 2. Si se necesita expansi\u00f3n en --exec, verifique que los campos que est\u00e1 usando no contengan \\\", | o \u0026amp;. 3. En lugar de usar --exec, escriba la informaci\u00f3n json y cargue los campos desde all\u00ed.\"}],\"metrics\":{\"cvssMetricV31\":[{\"source\":\"security-advisories@github.com\",\"type\":\"Secondary\",\"cvssData\":{\"version\":\"3.1\",\"vectorString\":\"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H\",\"baseScore\":8.3,\"baseSeverity\":\"HIGH\",\"attackVector\":\"NETWORK\",\"attackComplexity\":\"HIGH\",\"privilegesRequired\":\"NONE\",\"userInteraction\":\"REQUIRED\",\"scope\":\"CHANGED\",\"confidentialityImpact\":\"HIGH\",\"integrityImpact\":\"HIGH\",\"availabilityImpact\":\"HIGH\"},\"exploitabilityScore\":1.6,\"impactScore\":6.0},{\"source\":\"nvd@nist.gov\",\"type\":\"Primary\",\"cvssData\":{\"version\":\"3.1\",\"vectorString\":\"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H\",\"baseScore\":7.8,\"baseSeverity\":\"HIGH\",\"attackVector\":\"LOCAL\",\"attackComplexity\":\"LOW\",\"privilegesRequired\":\"NONE\",\"userInteraction\":\"REQUIRED\",\"scope\":\"UNCHANGED\",\"confidentialityImpact\":\"HIGH\",\"integrityImpact\":\"HIGH\",\"availabilityImpact\":\"HIGH\"},\"exploitabilityScore\":1.8,\"impactScore\":5.9}]},\"weaknesses\":[{\"source\":\"security-advisories@github.com\",\"type\":\"Primary\",\"description\":[{\"lang\":\"en\",\"value\":\"CWE-78\"}]}],\"configurations\":[{\"operator\":\"AND\",\"nodes\":[{\"operator\":\"OR\",\"negate\":false,\"cpeMatch\":[{\"vulnerable\":true,\"criteria\":\"cpe:2.3:a:yt-dlp_project:yt-dlp:*:*:*:*:*:*:*:*\",\"versionStartIncluding\":\"2021.04.11\",\"versionEndExcluding\":\"2023.09.24\",\"matchCriteriaId\":\"AAE6AF84-62B8-469A-9F5D-FC638DCFE350\"}]},{\"operator\":\"OR\",\"negate\":false,\"cpeMatch\":[{\"vulnerable\":false,\"criteria\":\"cpe:2.3:o:microsoft:windows:-:*:*:*:*:*:*:*\",\"matchCriteriaId\":\"A2572D17-1DE6-457B-99CC-64AFD54487EA\"}]}]}],\"references\":[{\"url\":\"https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044\",\"source\":\"security-advisories@github.com\",\"tags\":[\"Product\",\"Release Notes\"]},{\"url\":\"https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e\",\"source\":\"security-advisories@github.com\",\"tags\":[\"Patch\"]},{\"url\":\"https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11\",\"source\":\"security-advisories@github.com\",\"tags\":[\"Product\",\"Release Notes\"]},{\"url\":\"https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24\",\"source\":\"security-advisories@github.com\",\"tags\":[\"Product\",\"Release Notes\"]},{\"url\":\"https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg\",\"source\":\"security-advisories@github.com\",\"tags\":[\"Exploit\",\"Mitigation\",\"Patch\",\"Third Party Advisory\"]},{\"url\":\"https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044\",\"source\":\"af854a3a-2127-422b-91ae-364da2661108\",\"tags\":[\"Product\",\"Release Notes\"]},{\"url\":\"https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e\",\"source\":\"af854a3a-2127-422b-91ae-364da2661108\",\"tags\":[\"Patch\"]},{\"url\":\"https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11\",\"source\":\"af854a3a-2127-422b-91ae-364da2661108\",\"tags\":[\"Product\",\"Release Notes\"]},{\"url\":\"https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24\",\"source\":\"af854a3a-2127-422b-91ae-364da2661108\",\"tags\":[\"Product\",\"Release Notes\"]},{\"url\":\"https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg\",\"source\":\"af854a3a-2127-422b-91ae-364da2661108\",\"tags\":[\"Exploit\",\"Mitigation\",\"Patch\",\"Third Party Advisory\"]}]}}"
  }
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
  • Confirmed: The vulnerability is confirmed from an analyst perspective.
  • Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
  • Patched: This vulnerability was successfully patched by the user reporting the sighting.
  • Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
  • Not confirmed: The user expresses doubt about the veracity of the vulnerability.
  • Not patched: This vulnerability was not successfully patched by the user reporting the sighting.


Loading…

Loading…