GHSA-mc8w-wjhw-45x5: Etherpad: Pre-auth arbitrary file read
- Source:
- OSV.dev
- Published:
- Fetched:
- Updated:
- Affects:
- ep_etherpad-lite
https://osv.dev/vulnerability/GHSA-mc8w-wjhw-45x5 ↗
Etherpad: Pre-auth arbitrary file read ### Summary An unauthenticated path‑traversal / arbitrary file read vulnerability in Etherpad's /static/* handler allows any remote, unauthenticated user to read any file on the server's filesystem (e.g. GET /static/plugins/ep_etherpad-lite/static/..%5C..%5C..%5C..%5C..%5C..%5C..%5Cetc/passwd returns /etc/passwd) available to the user running the etherpad software. Because the endpoint is mounted before the authentication middleware, no credentials, session, or configuration change are required. The read primitive could escalate to a full server compromise: on a typical deployment by disclosing settings.json / credentials.json / /proc/self/environ, which contain the admin password, giving an attacker an admin session and, through the admin plugin installer, remote code execution. ### Details Etherpad serves plugin static assets through src/node/utils/Minify.ts. The request path is first passed through the canonical sanitizer src/node/utils/sanitizePathname.ts, which is careful to convert backslashes to forward slashes only on Windows: ``` // src/node/utils/sanitizePathname.ts:11-20 p = pathApi.normalize(p); if (pathApi.isAbsolute(p)) throw new Error(`absolute paths are forbidden: ${p}`); if (p.split(pathApi.sep)[0] === '..') throw new Error(`directory traversal: ${p}`); // THIS CONVERSION MUST ONLY BE DONE ON WINDOWS, otherwise on POSIXish systems '..\\' in the input // pathname would not be normalized away before being converted to '../'. if (pathApi.sep === '\\') p = p.replace(/\\/g, '/'); ``` On Linux a backslash is an ordinary filename byte, so an input segment like ..\..\..\test contains no ./.. path components and passes every check in sanitizePathname unchanged. The project's own test suite confirms this: src/tests/backend-new/specs/sanitizePathname.ts:62 lists ['posix', '..\\foo'] among the accepted paths (returned unchanged). The vulnerability is that Minify.ts then performs that Windows‑only conversion unconditionally, after the sanitizer has run, justified by a comment asserting the opposite of the invariant above: ``` // src/node/utils/Minify.ts:171-186 const match = filename.match(/^plugins\/([^/]+)(\/(?:(static\/.*)|.*))?$/); if (match) { const library = match[1]; const libraryPath = match[2] || ''; if (plugins.plugins[library] && match[3]) { const plugin = plugins.plugins[library]; const pluginPath = plugin.package.realPath; // for 'ep_etherpad-lite' == /src filename = path.join(pluginPath, libraryPath); // -> absolute path, backslashes preserved // ... "This conversion does not introduce a directory // traversal vulnerability because all '..\\' substrings have already been removed by // sanitizePathname." // <-- FALSE on POSIX filename = filename.replace(/\\/g, '/'); // <-- reintroduces ../ AFTER the check } ``` After line 186 the string becomes a real traversal ( /src/static/../../../../etc/passwd) with no re‑normalization and no containment check before the filesyst Affected: npm:ep_etherpad-lite Fixed in: 3.3.3 References: https://github.com/ether/etherpad/security/advisories/GHSA-mc8w-wjhw-45x5 https://github.com/ether/etherpad/pull/8081 https://github.com/ether/etherpad/commit/9c8d16d50e2fdfd9693ab35c43280410cb4db2fc https://github.com/ether/etherpad