The static resolver's traversal guard compared paths lexically, and the read that followed it resolved symlinks, so a link inside the root such as `public/leak -> /etc/hosts` served a file outside it. Containment now compares real paths. The root's real path is resolved on the first request and cached (a failed lookup is not, so a root created after boot still starts serving); the requested file and a directory's `index.html` are each realpath'd and must lie at or beneath it, with the `root + sep` rule keeping a sibling such as `root-evil` out. The lexical guard stays in front, since it rejects `..` without a syscall. An escape or a dangling link is a plain miss: 404 through `onError`, or 405/204 where the path has routes. Not 403, so a probe cannot tell a file outside the root from one that does not exist. Re-pointing a root symlink at runtime needs a restart. The realpath-to-read race is left open and marked; closing it needs per-component O_NOFOLLOW, which is not portable across Node, Deno and Bun. Closes #106 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
1 line
10 B
Plaintext
1 line
10 B
Plaintext
TOP SECRET |