CVE-2008-2942: Mercurial Path Traversal Vulnerability

MODERATE
Advisory Identifier: GHSA-v2gw-x5jf-pgwv
CWE-22
Published
Advisory Summary

CVE-2008-2942 is a MODERATE path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Mercurial libraries in the PyPI ecosystem. The issue involves mercurial directory traversal vulnerability. Remediation is available by upgrading affected packages to version 1.0.2.

CVE-2008-2942 at a Glance

CVE Identifier CVE-2008-2942
GHSA Identifier GHSA-v2gw-x5jf-pgwv
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Mercurial
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2008-2942

To remediate this vulnerability, upgrade all affected Mercurial dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

mercurial fixed: 1.0.2
pip install mercurial>=1.0.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show mercurial

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2008-2942, inspect your installed packages using pip:

pip show mercurial

Analyze the terminal output to locate any version of Mercurial in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.0.2), your application is affected.

Note: The pip show mercurial command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Mercurial, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Directory traversal vulnerability in patch.py in Mercurial before 1.0.2 allows user-assisted attackers to modify arbitrary files via ".." (dot dot) sequences in a patch file.

CVE-2008-2942 Affected Mercurial Versions

1 component(s)
Fixed Versions:
1.0.2
Product / Package Ecosystem Affected Versions Fixed Version
mercurial
PyPI
< 1.0.2
1.0.2

References

Frequently Asked Questions

What is CVE-2008-2942?
CVE-2008-2942 is a security vulnerability in Mercurial involving Mercurial Directory traversal vulnerability under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Mercurial versions are affected?
Affected versions include releases prior to 1.0.2 across affected packages: mercurial.
What version fixes CVE-2008-2942?
Upgrading to 1.0.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mercurial affected?
Yes, mercurial is affected in releases prior to 1.0.2. Upgrade your dependency to 1.0.2 or later.
What CWE is associated with CVE-2008-2942?
CVE-2008-2942 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check PyPI dependencies for CVE-2008-2942?
Run the dependency tree command: 'pip show mercurial'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-v2gw-x5jf-pgwv",
  "modified" : "2023-09-22T22:26:38Z",
  "published" : "2022-05-01T23:55:06Z",
  "aliases" : [ "CVE-2008-2942" ],
  "summary" : "Mercurial Directory traversal vulnerability",
  "details" : "Directory traversal vulnerability in patch.py in Mercurial before 1.0.2 allows user-assisted attackers to modify arbitrary files via \"..\" (dot dot) sequences in a patch file.",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "mercurial"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.0.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2008-2942"
  }, {
    "type" : "WEB",
    "url" : "https://exchange.xforce.ibmcloud.com/vulnerabilities/43551"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/dscho/hg"
  }, {
    "type" : "WEB",
    "url" : "https://issues.rpath.com/browse/RPL-2633"
  }, {
    "type" : "WEB",
    "url" : "http://lists.opensuse.org/opensuse-security-announce/2008-07/msg00006.html"
  }, {
    "type" : "WEB",
    "url" : "http://secunia.com/advisories/31108"
  }, {
    "type" : "WEB",
    "url" : "http://secunia.com/advisories/31110"
  }, {
    "type" : "WEB",
    "url" : "http://secunia.com/advisories/31167"
  }, {
    "type" : "WEB",
    "url" : "http://security.gentoo.org/glsa/glsa-200807-09.xml"
  }, {
    "type" : "WEB",
    "url" : "http://wiki.rpath.com/Advisories:rPSA-2008-0211"
  }, {
    "type" : "WEB",
    "url" : "http://www.openwall.com/lists/oss-security/2008/06/30/1"
  }, {
    "type" : "WEB",
    "url" : "http://www.openwall.com/lists/oss-security/2008/07/01/1"
  }, {
    "type" : "WEB",
    "url" : "http://www.securityfocus.com/archive/1/493881/100/0/threaded"
  }, {
    "type" : "WEB",
    "url" : "http://www.securityfocus.com/bid/30072"
  }, {
    "type" : "WEB",
    "url" : "http://www.selenic.com/hg/rev/87c704ac92d4"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-09-22T22:26:38Z",
    "nvd_published_at" : "2008-06-30T20:41:00Z"
  }
}