VulnWatch by ve1ve2
high 7.5

GHSA-5px6-fx2w-459r: Unauthenticated file read of files that begin with `index.`

Source:
Uptime Kuma releases + advisories (GitHub louislam/uptime-kuma)
Published:
Fetched:
Updated:
Affects:
louislam uptime-kuma

https://github.com/louislam/uptime-kuma/security/advisories/GHSA-5px6-fx2w-459r ↗

repo-advisoryCWE-22CWE-862securityrepo:louislam/uptime-kuma

Unauthenticated file read of files that begin with `index.` ### Summary The socket message `getPushExample` is vulnerable to unauthenticated requests, and allows for a path traversal which leads to the leakage of a file that begins with `index.`. ### Details [This code](https://github.com/louislam/uptime-kuma/blob/3b58ac3fd3712df192741b6b7bfd759d4624fd2c/server/socket-handlers/general-socket-handler.js#L93) is vulnerable to unauthenticated requests, and allows for a path traversal which leads to the leakage of a file that begins with `index.`. ```js socket.on("getPushExample", (language, callback) => { try { let dir = path.join("./extra/push-examples", language); let files = fs.readdirSync(dir); for (let file of files) { if (file.startsWith("index.")) { callback({ ok: true, code: fs.readFileSync(path.join(dir, file), "utf8"), }); return; } } } catch (e) { } callback({ ok: false, msg: "Not found", }); }); ``` By using an unauthenticated session, it is possible to request this endpoint as `checkLogin(socket);` is not called. Furthermore, `language` could be a path with a path traversal (`../`) which could read files in other directories. ### PoC By sending the following payload `420["getPushExample","../../"]`, we can obtain Uptime Kuma's index.html file. ![image](https://github.com/user-attachments/assets/71a75185-8d9a-43d9-b760-b55d69dc4338) This is in BurpSuite, but it can also be accomplished natively in JS. Steps: 1. Set a breakpoint in `login()` to capture the socket object ![image](https://github.com/user-attachments/assets/dea4b7b6-215c-4a29-b6f0-c2f943fb4030) 2. Call `emit` with `getPushExample` and the path. For example: `SOCK.emit("getPushExample", '../../', (res) => { console.log(res); });` ![image](https://github.com/user-attachments/assets/71ac32bd-3f15-47f5-8b8a-7129cf020e7e) ### Impact This vulnerability has very low impact, as the file must be named index.*. However, as it is a common filename, some sensitive files could be leaked leading to more issues. The CVSS I calculated was like so: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N Affected packages: :uptime-kuma Patched: uptime-kuma 2.0.0-beta.3

Linked vulnerabilities (1)

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

Unauthenticated file read of files that begin with `index.`

CWE: CWE-22, CWE-862