CVE-2020-26299: Ftp srv File System Bounds Escape Vulnerability

MODERATE
Advisory Identifier: GHSA-pmw4-jgxx-pcq9
CWE-22
Published
Advisory Summary

CVE-2020-26299 is a MODERATE file system bounds escape vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Ftp srv libraries in the npm ecosystem. The issue involves file system bounds escape. Remediation is available by upgrading affected packages to version 4.4.0.

CVE-2020-26299 at a Glance

CVE Identifier CVE-2020-26299
GHSA Identifier GHSA-pmw4-jgxx-pcq9
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 Ftp srv
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2020-26299

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

ftp-srv fixed: 4.4.0
npm install ftp-srv@4.4.0
Verify Direct and Transitive Dependencies

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

npm ls ftp-srv

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2020-26299, inspect your project dependencies using npm:

npm ls ftp-srv

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

Note: The npm ls ftp-srv command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

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 Ftp srv, 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

### Impact Clients of FTP servers utilizing `ftp-srv` hosted on Windows machines can escape the FTP user's defined root folder using the expected FTP commands, for example, `CWD` and `UPDR`. ### Background When windows separators exist within the path (`\`), `path.resolve` leaves the upper pointers intact and allows the user to move beyond the root folder defined for that user. We did not take that into account when creating the path resolve function. ![Screen Shot 2020-12-15 at 6 42 52 PM](https://user-images.githubusercontent.com/3375444/102293941-5a75fb80-3f05-11eb-9d71-0c190a8dcc75.png) ### Patches None at the moment. ### Workarounds There are no workarounds for windows servers. Hosting the server on a different OS mitigates the issue. ### References Issues: https://github.com/autovance/ftp-srv/issues/167 https://github.com/autovance/ftp-srv/issues/225 ### For more information If you have any questions or comments about this advisory: Open an issue at https://github.com/autovance/ftp-srv. Please email us directly; security@autovance.com.

CVE-2020-26299 Affected Ftp srv Versions

1 component(s)
Fixed Versions:
4.4.0
Product / Package Ecosystem Affected Versions Fixed Version
ftp-srv
npm
< 4.4.0
4.4.0

References

Frequently Asked Questions

What is CVE-2020-26299?
CVE-2020-26299 is a security vulnerability in Ftp srv involving File System Bounds Escape under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Ftp srv versions are affected?
Affected versions include releases prior to 4.4.0 across affected packages: ftp-srv.
What version fixes CVE-2020-26299?
Upgrading to 4.4.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is ftp-srv affected?
Yes, ftp-srv is affected in releases prior to 4.4.0. Upgrade your dependency to 4.4.0 or later.
What CWE is associated with CVE-2020-26299?
CVE-2020-26299 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 npm dependencies for CVE-2020-26299?
Run the dependency tree command: 'npm ls ftp-srv'. 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-pmw4-jgxx-pcq9",
  "modified" : "2021-02-11T17:04:52Z",
  "published" : "2021-02-10T18:11:34Z",
  "aliases" : [ "CVE-2020-26299" ],
  "summary" : "File System Bounds Escape",
  "details" : "### Impact\n\nClients of FTP servers utilizing `ftp-srv` hosted on Windows machines can escape the  FTP user's defined root folder using the expected FTP commands, for example, `CWD` and `UPDR`.\n\n### Background\n\nWhen windows separators exist within the path (`\\`), `path.resolve` leaves the upper pointers intact and allows the user to move beyond the root folder defined for that user. We did not take that into account when creating the path resolve function.\n\n![Screen Shot 2020-12-15 at 6 42 52 PM](https://user-images.githubusercontent.com/3375444/102293941-5a75fb80-3f05-11eb-9d71-0c190a8dcc75.png)\n\n### Patches\nNone at the moment.\n\n### Workarounds\nThere are no workarounds for windows servers. Hosting the server on a different OS mitigates the issue.\n\n### References\n\nIssues: \nhttps://github.com/autovance/ftp-srv/issues/167\nhttps://github.com/autovance/ftp-srv/issues/225\n\n### For more information\nIf you have any questions or comments about this advisory:\nOpen an issue at https://github.com/autovance/ftp-srv.\nPlease email us directly; security@autovance.com.",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "ftp-srv"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.4.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/autovance/ftp-srv/security/advisories/GHSA-pmw4-jgxx-pcq9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-26299"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/autovance/ftp-srv/issues/167"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/autovance/ftp-srv/issues/225"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/autovance/ftp-srv/pull/224"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/autovance/ftp-srv/commit/457b859450a37cba10ff3c431eb4aa67771122e3"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/ftp-srv"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-02-10T18:11:21Z",
    "nvd_published_at" : "2021-02-10T18:15:00Z"
  }
}