Listen to this Post
The vulnerability exists because the `/api/session-summary` and `/api/session-events` endpoints in the token-optimizer-mcp dashboard server lack authentication and fail to sanitize user-supplied input. The `sessionId` query parameter is passed directly into the `path.join()` function, which constructs a file path to a session log file. Node.js automatically normalizes any `..` sequences in the path, making it possible for an attacker to traverse directories outside the intended `hooksDataPath` folder. Since no validation or filtering is applied to sessionId, a malicious value like `abc/../../../../etc/passwd` can be used to read arbitrary `.jsonl` files on the system. The server uses `fs.readFileSync()` to read the file and returns its content in the API response. Both endpoints are vulnerable and can be exploited remotely without any credentials. The impact is limited to files with the `.jsonl` extension, but this includes sensitive session logs containing token usage, tool outputs, and other operational data. The vulnerability is classified as medium severity because it allows unauthorized file read but does not enable code execution or privilege escalation. An attacker only needs network access to the dashboard port (default 3100) to exfiltrate data. The flaw is introduced by the direct concatenation of user input into a filesystem operation without proper validation, a classic CWE-22 path traversal issue.
DailyCVE Form:
Platform: token-optimizer-mcp
Version: 5.0.1
Vulnerability : Path Traversal CWE-22
Severity: Medium
date: 2026-08-14
Prediction: 2026-08-21
What Undercode Say:
curl -s "http://127.0.0.1:3100/api/session-events?sessionId=abc%2F..%2F..%2F..%2F..%2Ftraversal-target"
GET /api/session-events?sessionId=abc%2F..%2F..%2F..%2F..%2Ftraversal-target HTTP/1.1 Host: 127.0.0.1:3100
HTTP/1.1 200 OK
{"success":true,"sessionId":"abc/../../../../traversal-target","total":1,"offset":0,"limit":100,"events":[{"type":"PATH_TRAVERSAL_EVIDENCE","secret":"sensitive-data-outside-hooks-dir"}]}
Exploit: (Educational Purposes!)
1. Identify target dashboard URL and port.
- Craft GET request to `/api/session-events` with `sessionId` containing traversal payload.
- Encode `../` sequences as `%2F..%2F` to bypass basic string checks.
- Read any `.jsonl` file by appending its relative path after the traversal sequence.
- Receive file contents in the JSON response under `events` array.
Protection:
- Validate `sessionId` with regex `/^[a-zA-Z0-9_-]{1,64}$/` to block `..` and
/. - Use `path.basename()` to strip directory components before path join.
- Add authentication middleware to all `/api/` routes.
Impact:
Unauthenticated remote attackers can read arbitrary `.jsonl` files, exposing session logs with sensitive tool invocations, hook outputs, and token usage data.
🎯Let’s Practice Exploiting & Learn Patching For Free:
🎓 Live Courses & Certifications:
Join Undercode Academy for Verified Certifications
🚀 Request a Custom Project:
Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands
Sources:
Reported By: github.com
Extra Source Hub:
Undercode

