GHSA-JP7F-GRCV-6MJF
Vulnerability from github – Published: 2021-09-20 19:53 – Updated: 2024-07-08 14:33
VLAI?
Summary
Partial path traversal in sharpcompress
Details
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 it is not enforced that fullDestinationDirectoryPath ends with slash:
public static void WriteEntryToDirectory(IEntry entry,
string destinationDirectory,
ExtractionOptions? options,
Action<string, ExtractionOptions?> write)
{
string destinationFileName;
string file = Path.GetFileName(entry.Key);
string fullDestinationDirectoryPath = Path.GetFullPath(destinationDirectory);
...
throw new ExtractionException("Entry is trying to write a file outside of the destination directory.");
}
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.
Impact
Because of the file name and destination directory constraints the arbitrary file creation impact is limited and depends on the use case.
Severity ?
4.3 (Medium)
{
"affected": [
{
"package": {
"ecosystem": "NuGet",
"name": "SharpCompress"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.29"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2021-39208"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2021-09-17T18:37:10Z",
"nvd_published_at": "2021-09-16T15:15:00Z",
"severity": "MODERATE"
},
"details": "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 it is not enforced that fullDestinationDirectoryPath ends with slash:\n\n```csharp\npublic static void WriteEntryToDirectory(IEntry entry,\n string destinationDirectory,\n ExtractionOptions? options,\n Action\u003cstring, ExtractionOptions?\u003e write)\n{\n string destinationFileName;\n string file = Path.GetFileName(entry.Key);\n string fullDestinationDirectoryPath = Path.GetFullPath(destinationDirectory);\n...\n throw new ExtractionException(\"Entry is trying to write a file outside of the destination directory.\");\n}\n```\n\nIf 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.\n\n#### Impact\nBecause of the file name and destination directory constraints the arbitrary file creation impact is limited and depends on the use case.",
"id": "GHSA-jp7f-grcv-6mjf",
"modified": "2024-07-08T14:33:23Z",
"published": "2021-09-20T19:53:42Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/adamhathcock/sharpcompress/security/advisories/GHSA-jp7f-grcv-6mjf"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2021-39208"
},
{
"type": "WEB",
"url": "https://github.com/adamhathcock/sharpcompress/pull/614"
},
{
"type": "WEB",
"url": "https://github.com/adamhathcock/sharpcompress/commit/ea5c8dc06314c7a5068e7901c51a625224d2b288"
},
{
"type": "PACKAGE",
"url": "https://github.com/adamhathcock/sharpcompress"
},
{
"type": "WEB",
"url": "https://github.com/adamhathcock/sharpcompress/releases/tag/0.29.0"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N",
"type": "CVSS_V4"
}
],
"summary": "Partial path traversal in sharpcompress"
}
Loading…
Loading…
Sightings
| Author | Source | Type | Date |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Loading…
Loading…