CVE-2022-36113
Vulnerability from cvelistv5
Published
2022-09-14 00:00
Modified
2024-08-03 09:52
Summary
Extracting malicious crates can corrupt arbitrary files
Impacted products
rust-langcargo
Show details on NVD website


{
  "containers": {
    "adp": [
      {
        "providerMetadata": {
          "dateUpdated": "2024-08-03T09:52:00.553Z",
          "orgId": "af854a3a-2127-422b-91ae-364da2661108",
          "shortName": "CVE"
        },
        "references": [
          {
            "name": "https://github.com/rust-lang/cargo/security/advisories/GHSA-rfj2-q3h3-hm5j",
            "tags": [
              "x_refsource_CONFIRM",
              "x_transferred"
            ],
            "url": "https://github.com/rust-lang/cargo/security/advisories/GHSA-rfj2-q3h3-hm5j"
          },
          {
            "name": "https://github.com/rust-lang/cargo/commit/97b80919e404b0768ea31ae329c3b4da54bed05a",
            "tags": [
              "x_refsource_MISC",
              "x_transferred"
            ],
            "url": "https://github.com/rust-lang/cargo/commit/97b80919e404b0768ea31ae329c3b4da54bed05a"
          }
        ],
        "title": "CVE Program Container"
      }
    ],
    "cna": {
      "affected": [
        {
          "product": "cargo",
          "vendor": "rust-lang",
          "versions": [
            {
              "status": "affected",
              "version": "\u003c 0.65.0"
            },
            {
              "status": "affected",
              "version": "= 0.66.0"
            }
          ]
        }
      ],
      "descriptions": [
        {
          "lang": "en",
          "value": "Cargo is a package manager for the rust programming language. After a package is downloaded, Cargo extracts its source code in the ~/.cargo folder on disk, making it available to the Rust projects it builds. To record when an extraction is successful, Cargo writes \"ok\" to the .cargo-ok file at the root of the extracted source code once it extracted all the files. It was discovered that Cargo allowed packages to contain a .cargo-ok symbolic link, which Cargo would extract. Then, when Cargo attempted to write \"ok\" into .cargo-ok, it would actually replace the first two bytes of the file the symlink pointed to with ok. This would allow an attacker to corrupt one file on the machine using Cargo to extract the package. Note that by design Cargo allows code execution at build time, due to build scripts and procedural macros. The vulnerabilities in this advisory allow performing a subset of the possible damage in a harder to track down way. Your dependencies must still be trusted if you want to be protected from attacks, as it\u0027s possible to perform the same attacks with build scripts and procedural macros. The vulnerability is present in all versions of Cargo. Rust 1.64, to be released on September 22nd, will include a fix for it. Since the vulnerability is just a more limited way to accomplish what a malicious build scripts or procedural macros can do, we decided not to publish Rust point releases backporting the security fix. Patch files are available for Rust 1.63.0 are available in the wg-security-response repository for people building their own toolchain.\nMitigations We recommend users of alternate registries to exercise care in which package they download, by only including trusted dependencies in their projects. Please note that even with these vulnerabilities fixed, by design Cargo allows arbitrary code execution at build time thanks to build scripts and procedural macros: a malicious dependency will be able to cause damage regardless of these vulnerabilities. crates.io implemented server-side checks to reject these kinds of packages years ago, and there are no packages on crates.io exploiting these vulnerabilities. crates.io users still need to exercise care in choosing their dependencies though, as remote code execution is allowed by design there as well."
        }
      ],
      "metrics": [
        {
          "cvssV3_1": {
            "attackComplexity": "HIGH",
            "attackVector": "NETWORK",
            "availabilityImpact": "LOW",
            "baseScore": 4.6,
            "baseSeverity": "MEDIUM",
            "confidentialityImpact": "LOW",
            "integrityImpact": "LOW",
            "privilegesRequired": "LOW",
            "scope": "UNCHANGED",
            "userInteraction": "REQUIRED",
            "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:L",
            "version": "3.1"
          }
        }
      ],
      "problemTypes": [
        {
          "descriptions": [
            {
              "cweId": "CWE-22",
              "description": "CWE-22: Improper Limitation of a Pathname to a Restricted Directory (\u0027Path Traversal\u0027)",
              "lang": "en",
              "type": "CWE"
            }
          ]
        }
      ],
      "providerMetadata": {
        "dateUpdated": "2023-08-14T16:16:10.762Z",
        "orgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
        "shortName": "GitHub_M"
      },
      "references": [
        {
          "name": "https://github.com/rust-lang/cargo/security/advisories/GHSA-rfj2-q3h3-hm5j",
          "tags": [
            "x_refsource_CONFIRM"
          ],
          "url": "https://github.com/rust-lang/cargo/security/advisories/GHSA-rfj2-q3h3-hm5j"
        },
        {
          "name": "https://github.com/rust-lang/cargo/commit/97b80919e404b0768ea31ae329c3b4da54bed05a",
          "tags": [
            "x_refsource_MISC"
          ],
          "url": "https://github.com/rust-lang/cargo/commit/97b80919e404b0768ea31ae329c3b4da54bed05a"
        }
      ],
      "source": {
        "advisory": "GHSA-rfj2-q3h3-hm5j",
        "discovery": "UNKNOWN"
      },
      "title": "Extracting malicious crates can corrupt arbitrary files"
    }
  },
  "cveMetadata": {
    "assignerOrgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
    "assignerShortName": "GitHub_M",
    "cveId": "CVE-2022-36113",
    "datePublished": "2022-09-14T00:00:00",
    "dateReserved": "2022-07-15T00:00:00",
    "dateUpdated": "2024-08-03T09:52:00.553Z",
    "state": "PUBLISHED"
  },
  "dataType": "CVE_RECORD",
  "dataVersion": "5.1",
  "meta": {
    "nvd": "{\"cve\":{\"id\":\"CVE-2022-36113\",\"sourceIdentifier\":\"security-advisories@github.com\",\"published\":\"2022-09-14T18:15:10.763\",\"lastModified\":\"2023-08-14T17:15:09.743\",\"vulnStatus\":\"Modified\",\"descriptions\":[{\"lang\":\"en\",\"value\":\"Cargo is a package manager for the rust programming language. After a package is downloaded, Cargo extracts its source code in the ~/.cargo folder on disk, making it available to the Rust projects it builds. To record when an extraction is successful, Cargo writes \\\"ok\\\" to the .cargo-ok file at the root of the extracted source code once it extracted all the files. It was discovered that Cargo allowed packages to contain a .cargo-ok symbolic link, which Cargo would extract. Then, when Cargo attempted to write \\\"ok\\\" into .cargo-ok, it would actually replace the first two bytes of the file the symlink pointed to with ok. This would allow an attacker to corrupt one file on the machine using Cargo to extract the package. Note that by design Cargo allows code execution at build time, due to build scripts and procedural macros. The vulnerabilities in this advisory allow performing a subset of the possible damage in a harder to track down way. Your dependencies must still be trusted if you want to be protected from attacks, as it\u0027s possible to perform the same attacks with build scripts and procedural macros. The vulnerability is present in all versions of Cargo. Rust 1.64, to be released on September 22nd, will include a fix for it. Since the vulnerability is just a more limited way to accomplish what a malicious build scripts or procedural macros can do, we decided not to publish Rust point releases backporting the security fix. Patch files are available for Rust 1.63.0 are available in the wg-security-response repository for people building their own toolchain.\\nMitigations We recommend users of alternate registries to exercise care in which package they download, by only including trusted dependencies in their projects. Please note that even with these vulnerabilities fixed, by design Cargo allows arbitrary code execution at build time thanks to build scripts and procedural macros: a malicious dependency will be able to cause damage regardless of these vulnerabilities. crates.io implemented server-side checks to reject these kinds of packages years ago, and there are no packages on crates.io exploiting these vulnerabilities. crates.io users still need to exercise care in choosing their dependencies though, as remote code execution is allowed by design there as well.\"},{\"lang\":\"es\",\"value\":\"Cargo es un administrador de paquetes para el lenguaje de programaci\u00f3n rust. Despu\u00e9s de descargar un paquete, Cargo extrae su c\u00f3digo fuente en la carpeta ~/.cargo del disco, poni\u00e9ndolo a disposici\u00f3n de los proyectos Rust que construye. Para registrar cuando una extracci\u00f3n es exitosa, Cargo escribe \\\"ok\\\" en el archivo .cargo-ok en el root del c\u00f3digo fuente extra\u00eddo una vez que extrajo todos los archivos. Se ha detectado que Cargo permit\u00eda que los paquetes contuvieran un enlace simb\u00f3lico .cargo-ok, que Cargo extra\u00eda. Entonces, cuando Cargo intentaba escribir \\\"ok\\\" en .cargo-ok, en realidad sustitu\u00eda los dos primeros bytes del archivo al que apuntaba el enlace simb\u00f3lico por ok. Esto permitir\u00eda a un atacante corromper un archivo en la m\u00e1quina que usa Cargo para extraer el paquete. Tenga en cuenta que, por dise\u00f1o, Cargo permite una ejecuci\u00f3n de c\u00f3digo en tiempo de compilaci\u00f3n, debido a los scripts de compilaci\u00f3n y las macros de procedimiento. Las vulnerabilidades de este aviso permiten llevar a cabo un subconjunto de los posibles da\u00f1os de una forma m\u00e1s dif\u00edcil de rastrear. Tus dependencias deben seguir siendo confiables si quieres estar protegido de los ataques, ya que es posible llevar a cabo los mismos ataques con scripts de construcci\u00f3n y macros de procedimiento. La vulnerabilidad est\u00e1 presente en todas las versiones de Cargo. Rust versi\u00f3n 1.64, ser\u00e1 publicada el 22 de septiembre, incluir\u00e1 una correcci\u00f3n para la misma. Dado que la vulnerabilidad es s\u00f3lo una forma m\u00e1s limitada de lograr lo que pueden hacer los scripts de construcci\u00f3n o las macros de procedimiento maliciosos, hemos decidido no publicar versiones puntuales de Rust que incluyan la correcci\u00f3n de seguridad. Los archivos de parche est\u00e1n disponibles para Rust versi\u00f3n 1.63.0 en el repositorio wg-security-response para las personas que construyen su propia cadena de herramientas. Mitigaci\u00f3n Recomendamos a usuarios de registros alternativos que tengan cuidado con el paquete que descargan, incluyendo s\u00f3lo dependencias confiables en sus proyectos. Tenga en cuenta que incluso con estas vulnerabilidades corregidas, Cargo permite por dise\u00f1o la ejecuci\u00f3n de c\u00f3digo arbitrario en tiempo de compilaci\u00f3n gracias a los scripts de compilaci\u00f3n y a las macros de procedimiento: una dependencia maliciosa podr\u00e1 causar da\u00f1os independientemente de estas vulnerabilidades. crates.io implement\u00f3 comprobaciones del lado del servidor para rechazar este tipo de paquetes hace a\u00f1os, y no se presentan paquetes en crates.io que exploten estas vulnerabilidades\"}],\"metrics\":{\"cvssMetricV31\":[{\"source\":\"nvd@nist.gov\",\"type\":\"Primary\",\"cvssData\":{\"version\":\"3.1\",\"vectorString\":\"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H\",\"attackVector\":\"NETWORK\",\"attackComplexity\":\"LOW\",\"privilegesRequired\":\"NONE\",\"userInteraction\":\"REQUIRED\",\"scope\":\"UNCHANGED\",\"confidentialityImpact\":\"NONE\",\"integrityImpact\":\"HIGH\",\"availabilityImpact\":\"HIGH\",\"baseScore\":8.1,\"baseSeverity\":\"HIGH\"},\"exploitabilityScore\":2.8,\"impactScore\":5.2},{\"source\":\"security-advisories@github.com\",\"type\":\"Secondary\",\"cvssData\":{\"version\":\"3.1\",\"vectorString\":\"CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:L\",\"attackVector\":\"NETWORK\",\"attackComplexity\":\"HIGH\",\"privilegesRequired\":\"LOW\",\"userInteraction\":\"REQUIRED\",\"scope\":\"UNCHANGED\",\"confidentialityImpact\":\"LOW\",\"integrityImpact\":\"LOW\",\"availabilityImpact\":\"LOW\",\"baseScore\":4.6,\"baseSeverity\":\"MEDIUM\"},\"exploitabilityScore\":1.2,\"impactScore\":3.4}]},\"weaknesses\":[{\"source\":\"security-advisories@github.com\",\"type\":\"Primary\",\"description\":[{\"lang\":\"en\",\"value\":\"CWE-22\"}]},{\"source\":\"nvd@nist.gov\",\"type\":\"Secondary\",\"description\":[{\"lang\":\"en\",\"value\":\"CWE-59\"}]}],\"configurations\":[{\"nodes\":[{\"operator\":\"OR\",\"negate\":false,\"cpeMatch\":[{\"vulnerable\":true,\"criteria\":\"cpe:2.3:a:rust-lang:cargo:*:*:*:*:*:rust:*:*\",\"versionEndExcluding\":\"0.65.0\",\"matchCriteriaId\":\"28D07B7F-9076-4BCD-8CBE-4CD7E1E996AB\"}]}]}],\"references\":[{\"url\":\"https://github.com/rust-lang/cargo/commit/97b80919e404b0768ea31ae329c3b4da54bed05a\",\"source\":\"security-advisories@github.com\",\"tags\":[\"Patch\",\"Third Party Advisory\"]},{\"url\":\"https://github.com/rust-lang/cargo/security/advisories/GHSA-rfj2-q3h3-hm5j\",\"source\":\"security-advisories@github.com\",\"tags\":[\"Mitigation\",\"Third Party Advisory\"]}]}}"
  }
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading...

Loading...

Loading...
  • 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.