File System Bounds Escape
Description
ftp-srv is an open-source FTP server designed to be simple yet configurable. In ftp-srv before version 4.4.0 there is a path-traversal vulnerability. 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. 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. The issue is patched in version 4.4.0 (commit 457b859450a37cba10ff3c431eb4aa67771122e3).
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
ftp-srv before 4.4.0 on Windows allows path traversal via backslash in FTP commands, enabling escape from the user's root directory.
Root
Cause ftp-srv prior to version 4.4.0 mishandles path resolution on Windows. The path.resolve function treats backslashes as path separators without normalizing them, leaving directory traversal sequences like .. intact [1]. This allows a client to construct paths that escape the intended root folder.
Exploitation
An attacker with valid FTP credentials can issue commands such as CWD (change working directory) or UPDR (upload) with backslashes (e.g., \..\..\..). No special privileges are required beyond a standard user account. The vulnerability is specific to Windows-based servers [1].
Impact
Successful exploitation grants the attacker read and write access to any directory on the same drive as the FTP root. This can lead to unauthorized file access, data exfiltration, or even remote code execution if writable directories are reachable [2].
Mitigation
The issue is fixed in ftp-srv version 4.4.0, which adds proper path validation and normalization before resolving paths [2]. All users are advised to upgrade immediately. No reliable workaround is available.
AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
ftp-srvnpm | < 4.4.0 | 4.4.0 |
Affected products
3- autovance/ftp-srvv5Range: < 4.4.0
Patches
1457b859450a3fix(fs): check resolved path against root (#224)
3 files changed · +52 −20
src/fs.js+19 −14 modified@@ -6,10 +6,13 @@ const {createReadStream, createWriteStream, constants} = require('fs'); const fsAsync = require('./helpers/fs-async'); const errors = require('./errors'); +const UNIX_SEP_REGEX = /\//g; +const WIN_SEP_REGEX = /\\/g; + class FileSystem { constructor(connection, {root, cwd} = {}) { this.connection = connection; - this.cwd = nodePath.normalize(cwd ? nodePath.join(nodePath.sep, cwd) : nodePath.sep); + this.cwd = nodePath.normalize((cwd || '/').replace(WIN_SEP_REGEX, '/')); this._root = nodePath.resolve(root || process.cwd()); } @@ -18,19 +21,21 @@ class FileSystem { } _resolvePath(path = '.') { - const clientPath = (() => { - path = nodePath.normalize(path); - if (nodePath.isAbsolute(path)) { - return nodePath.join(path); - } else { - return nodePath.join(this.cwd, path); - } - })(); - - const fsPath = (() => { - const resolvedPath = nodePath.join(this.root, clientPath); - return nodePath.resolve(nodePath.normalize(nodePath.join(resolvedPath))); - })(); + // Unix separators normalize nicer on both unix and win platforms + const resolvedPath = path.replace(WIN_SEP_REGEX, '/'); + + // Join cwd with new path + const joinedPath = nodePath.isAbsolute(resolvedPath) + ? nodePath.normalize(resolvedPath) + : nodePath.join('/', this.cwd, resolvedPath); + + // Create local filesystem path using the platform separator + const fsPath = nodePath.resolve(nodePath.join(this.root, joinedPath) + .replace(UNIX_SEP_REGEX, nodePath.sep) + .replace(WIN_SEP_REGEX, nodePath.sep)); + + // Create FTP client path using unix separator + const clientPath = joinedPath.replace(WIN_SEP_REGEX, '/'); return { clientPath,
test/fs.spec.js+29 −2 modified@@ -36,7 +36,7 @@ describe('FileSystem', function () { describe('#_resolvePath', function () { it('gets correct relative path', function () { - const result = fs._resolvePath(); + const result = fs._resolvePath('.'); expect(result).to.be.an('object'); expect(result.clientPath).to.equal( nodePath.normalize('/file/1/2/3')); @@ -53,6 +53,15 @@ describe('FileSystem', function () { nodePath.resolve('/tmp/ftp-srv/file/1/2')); }); + it('gets correct relative path', function () { + const result = fs._resolvePath('other'); + expect(result).to.be.an('object'); + expect(result.clientPath).to.equal( + nodePath.normalize('/file/1/2/3/other')); + expect(result.fsPath).to.equal( + nodePath.resolve('/tmp/ftp-srv/file/1/2/3/other')); + }); + it('gets correct absolute path', function () { const result = fs._resolvePath('/other'); expect(result).to.be.an('object'); @@ -62,7 +71,7 @@ describe('FileSystem', function () { nodePath.resolve('/tmp/ftp-srv/other')); }); - it('cannot escape root', function () { + it('cannot escape root - unix', function () { const result = fs._resolvePath('../../../../../../../../../../..'); expect(result).to.be.an('object'); expect(result.clientPath).to.equal( @@ -71,6 +80,24 @@ describe('FileSystem', function () { nodePath.resolve('/tmp/ftp-srv')); }); + it('cannot escape root - win', function () { + const result = fs._resolvePath('.\\..\\..\\..\\..\\..\\..\\'); + expect(result).to.be.an('object'); + expect(result.clientPath).to.equal( + nodePath.normalize('/')); + expect(result.fsPath).to.equal( + nodePath.resolve('/tmp/ftp-srv')); + }); + + it('cannot escape root - backslash prefix', function () { + const result = fs._resolvePath('\\/../../../../../../'); + expect(result).to.be.an('object'); + expect(result.clientPath).to.equal( + nodePath.normalize('/')); + expect(result.fsPath).to.equal( + nodePath.resolve('/tmp/ftp-srv')); + }); + it('resolves to file', function () { const result = fs._resolvePath('/cool/file.txt'); expect(result).to.be.an('object');
test/start.js+4 −4 modified@@ -9,16 +9,16 @@ const server = new FtpServer({ pasv_min: 8881, greeting: ['Welcome', 'to', 'the', 'jungle!'], tls: { - key: fs.readFileSync(`${process.cwd()}/test/cert/server.key`), - cert: fs.readFileSync(`${process.cwd()}/test/cert/server.crt`), - ca: fs.readFileSync(`${process.cwd()}/test/cert/server.csr`) + key: fs.readFileSync(`${__dirname}/cert/server.key`), + cert: fs.readFileSync(`${__dirname}/cert/server.crt`), + ca: fs.readFileSync(`${__dirname}/cert/server.csr`) }, file_format: 'ep', anonymous: 'sillyrabbit' }); server.on('login', ({username, password}, resolve, reject) => { if (username === 'test' && password === 'test' || username === 'anonymous') { - resolve({root: require('os').homedir()}); + resolve({root: __dirname}); } else reject('Bad username or password'); }); server.listen();
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
8- github.com/advisories/GHSA-pmw4-jgxx-pcq9ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2020-26299ghsaADVISORY
- github.com/autovance/ftp-srv/commit/457b859450a37cba10ff3c431eb4aa67771122e3ghsax_refsource_MISCWEB
- github.com/autovance/ftp-srv/issues/167ghsax_refsource_MISCWEB
- github.com/autovance/ftp-srv/issues/225ghsax_refsource_MISCWEB
- github.com/autovance/ftp-srv/pull/224ghsax_refsource_MISCWEB
- github.com/autovance/ftp-srv/security/advisories/GHSA-pmw4-jgxx-pcq9ghsax_refsource_CONFIRMWEB
- www.npmjs.com/package/ftp-srvghsax_refsource_MISCWEB
News mentions
0No linked articles in our index yet.