Skip to content
Heist/ feed
Back to feed
Medium

Security advisory

Type: advisorySources: OSVCVE: CVE-2021-39208

SharpCompress is a fully managed C# library to deal with many compression types and formats. Versions prior to 0.29.0 are vulnerable to partial path traversal. SharpCompress recreates a hierarchy of directories under destinationDirectory if ExtractFullPath is set to true in options. In order to prevent extraction outside the destination directory the destinationFileName path is verified to begin with fullDestinationDirectoryPath. However, prior to version 0.29.0, it is not enforced that fullDestinationDirectoryPath ends with slash. If the destinationDirectory is not slash terminated like `/home/user/dir` it is possible to create a file with a name thats begins as the destination directory one level up from the directory, i.e. `/home/user/dir.sh`. Because of the file name and destination directory constraints the arbitrary file creation impact is limited and depends on the use case. This issue is fixed in SharpCompress version 0.29.0.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2021-39208
Confirmed fixed CVEs
Not specified
Updated in this feed
31 Oct 2026, 11:53 UTC · Revision 1

Source evidence

CVE-2021-39208

core-osv · Original source

Published 16 Sept 2021, 15:15 UTC

SharpCompress is a fully managed C# library to deal with many compression types and formats. Versions prior to 0.29.0 are vulnerable to partial path traversal. SharpCompress recreates a hierarchy of directories under destinationDirectory if ExtractFullPath is set to true in options. In order to prevent extraction outside the destination directory the destinationFileName path is verified to begin with fullDestinationDirectoryPath. However, prior to version 0.29.0, it is not enforced that fullDestinationDirectoryPath ends with slash. If the destinationDirectory is not slash terminated like `/home/user/dir` it is possible to create a file with a name thats begins as the destination directory one level up from the directory, i.e. `/home/user/dir.sh`. Because of the file name and destination directory constraints the arbitrary file creation impact is limited and depends on the use case. This issue is fixed in SharpCompress version 0.29.0.

osv:CVE-2021-39208
Complete source record
{
  "id": "e83a6edd6e8624012a62fbd8d3118cbc76eaa6b66c9e2bcd897aabf386953dec",
  "url": "https://osv.dev/vulnerability/CVE-2021-39208",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "CVE-2021-39208",
    "summary": "SharpCompress is a fully managed C# library to deal with many compression types and formats. Versions prior to 0.29.0 are vulnerable to partial path traversal. SharpCompress recreates a hierarchy of directories under destinationDirectory if ExtractFullPath is set to true in options. In order to prevent extraction outside the destination directory the destinationFileName path is verified to begin with fullDestinationDirectoryPath. However, prior to version 0.29.0, it is not enforced that fullDestinationDirectoryPath ends with slash. If the destinationDirectory is not slash terminated like `/home/user/dir` it is possible to create a file with a name thats begins as the destination directory one level up from the directory, i.e. `/home/user/dir.sh`. Because of the file name and destination directory constraints the arbitrary file creation impact is limited and depends on the use case. This issue is fixed in SharpCompress version 0.29.0.",
    "evidence": "osv:CVE-2021-39208",
    "products": [],
    "severity": "medium",
    "structured": {
      "id": "CVE-2021-39208",
      "aliases": [
        "CVE-2021-39208",
        "GHSA-jp7f-grcv-6mjf"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/adamhathcock/sharpcompress",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "ea5c8dc06314c7a5068e7901c51a625224d2b288"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:sharpcompress_project:sharpcompress:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "0.29.0"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "range": [
                      {
                        "fixed": "ea5c8dc06314c7a5068e7901c51a625224d2b288"
                      }
                    ],
                    "source": "REFERENCES_TAG",
                    "original_tag": "0.29.0"
                  }
                ]
              }
            }
          ],
          "versions": [
            "0.28.3",
            "0.28.2",
            "0.28.1",
            "0.28",
            "0.27.1",
            "0.27",
            "0.26",
            "0.25.1",
            "0.25",
            "0.24",
            "0.23",
            "0.22",
            "0.21.1",
            "0.21.0",
            "0.21",
            "0.20.0",
            "0.19.2",
            "0.19.1",
            "0.19",
            "0.18.2",
            "0.18.1",
            "0.18",
            "0.17.1",
            "0.17.0",
            "0.16.2",
            "0.16.1",
            "0.16.0",
            "0.15.2",
            "0.15.1",
            "0.15.0",
            "0.14.1",
            "0.14.0",
            "0.13.1",
            "0.13.0",
            "0.12.4",
            "0.12.3",
            "0.12.2",
            "0.12.1",
            "0.12.0",
            "0.11.6",
            "0.11.5",
            "0.11.4",
            "0.11.2",
            "0.11.3",
            "0.11.1",
            "0.11",
            "0.10.3",
            "0.10.2",
            "0.10.1.3",
            "0.10.1.2",
            "0.10.1.1",
            "0.10.1",
            "0.10",
            "0.9"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2021-39208.json"
          }
        }
      ],
      "modified": "2026-10-20T10:54:53.601683446Z",
      "provider": "osv",
      "references": [
        "https://github.com/adamhathcock/sharpcompress/releases/tag/0.29.0",
        "https://github.com/adamhathcock/sharpcompress/pull/614",
        "https://github.com/adamhathcock/sharpcompress/security/advisories/GHSA-jp7f-grcv-6mjf"
      ],
      "provider_metadata": {}
    },
    "related_cves": [
      {
        "value": "CVE-2021-39208",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 386386,
  "published_at": "2021-09-16T15:15:07.39+00:00"
}