{"id":"CVE-2022-23530","aliases":["CVE-2022-23530","GHSA-78m5-jpmf-ch7v","PYSEC-2022-42993"],"related":[],"kind":"vulnerability","state":"published","title":"GuardDog vulnerable to arbitrary file write when scanning a specially-crafted remote PyPI package","summary":"GuardDog is a CLI tool to identify malicious PyPI packages. Versions prior to v0.1.8 are vulnerable to arbitrary file write when scanning a specially-crafted remote PyPI package. Extracting files using shutil.unpack_archive() from a potentially malicious tarball without validating that the destination file path is within the intended destination directory can cause files outside the destination directory to be overwritten.  This issue is patched in version 0.1.8. Potential workarounds include using a safer module, like zipfile, and validating the location of the extracted files and discarding those with malicious paths.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"GuardDog is a CLI tool to identify malicious PyPI packages. Versions prior to v0.1.8 are vulnerable to arbitrary file write when scanning a specially-crafted remote PyPI package. Extracting files using shutil.unpack_archive() from a potentially malicious tarball without validating that the destination file path is within the intended destination directory can cause files outside the destination directory to be overwritten.  This issue is patched in version 0.1.8. Potential workarounds include using a safer module, like zipfile, and validating the location of the extracted files and discarding those with malicious paths.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nUnsafe extracting using `shutil.unpack_archive()` from a remotely retrieved tarball may lead to writing the extracted file to an unintended destination.\n\n### Details\n\nExtracting files using `shutil.unpack_archive()` from a potentially malicious tarball without validating that the destination file path is within the intended destination directory can cause files outside the destination directory to be overwritten.  \n\nThe vulnerable code snippet is between [L153..158](https://github.com/DataDog/guarddog/blob/a1d064ceb09d39bb28deb6972bc0a278756ea91f/guarddog/scanners/package_scanner.py#L153..158). \n\n```python\nresponse = requests.get(url, stream=True)\n\nwith open(zippath, \"wb\") as f:\n      f.write(response.raw.read())\n\nshutil.unpack_archive(zippath, unzippedpath)\n```\nIt seems that a remotely retrieved tarball which could be with the extension `.tar.gz` happens to be unpacked using `shutil.unpack_archive()` with no destination verification/limitation of the extracted files.\n\n### PoC\n\nThe PoC provided showcases the risk of extracting the non-harmless text file `sim4n6.txt` to a parent location rather than the current folder. \n\n```bash\n> tar --list -f archive.tar\ntar: Removing leading `../../../' from member names\n../../../sim4n6.txt\n\n> python3 \nPython 3.10.6 (main, Nov  2 2022, 18:53:38) [GCC 11.3.0] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import shutil\n>>> shutil.unpack_archive(\"archive.tar\")\n>>> exit()\n\n> file ../../../sim4n6.txt\n../../../sim4n6.txt: ASCII text\n```\n\n### A Potential Attack Scenario\n\n- An attacker may craft a malicious tarball with a filename path, such as `../../../../../../../../etc/passwd`, and then serve the archive remotely, thus, providing a possibility to overwrite the system files.\n\n### Mitigation\n\nPotential mitigation could be to:\n- Use a safer module, like `zipfile`.\n- Validate the location of the extracted files and discard those with malicious paths such as a relative path `..` or absolute ones.","format":"markdown","source":"ghsa"},{"lang":"es","text":"GuardDog es una herramienta CLI para identificar paquetes PyPI maliciosos. Las versiones anteriores a la v0.1.8 son vulnerables a la escritura arbitraria de archivos al escanear un paquete PyPI remoto especialmente manipulado. Extraer archivos utilizandoshutil.unpack_archive() de un tarball potencialmente malicioso sin validar que la ruta del archivo de destino esté dentro del directorio de destino deseado puede provocar que se sobrescriban los archivos fuera del directorio de destino. Este problema está solucionado en la versión 0.1.8. Los posibles workarounds incluyen el uso de un módulo más seguro, como zipfile, y validar la ubicación de los archivos extraídos y descartar aquellos con rutas maliciosas.","source":"nvd"}],"published":"2022-12-05T23:34:43.000Z","modified":"2026-06-17T04:30:18.270Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:L","score":5.8,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:L","score":5.8,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:L","score":5.8,"rating":"LOW"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:L/VI:L/VA:L/SC:L/SI:L/SA:L","rating":"LOW"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N","score":6.5,"rating":"MEDIUM"}],"cwes":["CWE-22"],"affected":[{"ranges":[{"version":"< 0.1.8","status":"affected"}],"vendor":"DataDog","product":"guarddog","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.1.8"}],"ecosystem":"PyPI","package":"guarddog","purl":"pkg:pypi/guarddog","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"0.1.8"}],"vendor":"datadoghq","product":"guarddog","cpe":"cpe:2.3:a:datadoghq:guarddog:*:*:*:*:*:python:*:*","source":"nvd"},{"ranges":[{"type":"git","introduced":"0","status":"affected","fixed":"37c7d0767ba28f4df46117d478f97652594c491c"},{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.1.8"}],"ecosystem":"PyPI","package":"guarddog","purl":"pkg:pypi/guarddog","repo":"https://github.com/DataDog/guarddog","source":"pysec"}],"references":[{"url":"https://github.com/DataDog/guarddog/security/advisories/GHSA-78m5-jpmf-ch7v","tags":["advisory","exploit","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/DataDog/guarddog/commit/37c7d0767ba28f4df46117d478f97652594c491c","tags":["fix","patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/DataDog/guarddog/blob/a1d064ceb09d39bb28deb6972bc0a278756ea91f/guarddog/scanners/package_scanner.py#L153..158","tags":["exploit","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2022-23530","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/DataDog/guarddog","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/guarddog/PYSEC-2022-42993.yaml","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-04-17T14:34:18.663Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2022-23530","url":"https://www.cve.org/CVERecord?id=CVE-2022-23530","licence":"CVE Terms of Use","modified":"2025-04-17T14:34:26.895Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-78m5-jpmf-ch7v","url":"https://github.com/advisories/GHSA-78m5-jpmf-ch7v","licence":"CC-BY-4.0","modified":"2024-11-20T05:37:45.239Z"},{"source":"nvd","name":"NVD","id":"CVE-2022-23530","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-23530","licence":"Public domain","modified":"2026-06-17T04:30:18.270Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2022-42993","url":"https://osv.dev/vulnerability/PYSEC-2022-42993","licence":"CC-BY-4.0","modified":"2023-11-08T04:08:21.047Z"}],"updatedAt":"2026-11-25T22:58:17.652Z","epss":{"score":0.00804,"percentile":0.53623,"date":"2026-11-30T12:00:22.000Z"}}