Skip to content

Ensure tree traversal attack is protected against. - #2

Open
ro-savage wants to merge 1 commit into
chrisjunlee:mainfrom
ro-savage:security-tree-traversal
Open

Ensure tree traversal attack is protected against.#2
ro-savage wants to merge 1 commit into
chrisjunlee:mainfrom
ro-savage:security-tree-traversal

Conversation

@ro-savage

Copy link
Copy Markdown
Contributor

From Claude:

Vuln 1 — Path Traversal → Arbitrary File Read: src/server.mjs:66-67 (and :20-28)

Description
The static file handler builds a filesystem path by joining the public directory with the raw request path, with no normalization
or containment check:

// src/server.mjs:66
const filePath = url === "/" ? join(PUBLIC, "index.html") : join(PUBLIC, url.slice(1));
await serveStatic(res, filePath); // serveStatic() just readFile()s it, :20-28

url is req.url.split("?")[0] — Node's HTTP server does not collapse ../ dot-segments in req.url, so a request target containing ..
reaches join() verbatim. join(PUBLIC, "../../../../etc/passwd") resolves outside PUBLIC, and serveStatic reads and returns
whatever file results. The MIME map falls back to application/octet-stream for unknown extensions, so extension-less secrets are
served fine.

Exploit Scenario
Browsers normalize ../, but an attacker doesn't use a browser. Against a victim running the tool:

curl --path-as-is http://:3000/../../../../../../etc/passwd
curl --path-as-is http://:3000/../../../../../../home//.ssh/id_rsa
curl --path-as-is http://:3000/../../../../../../home//.aws/credentials

This reads any file the running user can read — SSH keys, cloud credentials, ~/.claude/ auth material, the full transcript corpus,
etc. Combined with Vuln 2 (server binds to all interfaces), this is exploitable by anyone on the same LAN/Wi-Fi, unauthenticated.

…s-is http://<victim>:3000/../../../../../../home/<user>/.ssh/id_rsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant