Repository navigation
WAC-exempt app subtrees: unhandled paths are 404, never an LDP read or write (#611) - #637
Conversation
…r write (#611) A request under an app prefix (appPaths, a plugin prefix, a reservePath claim) skips the WAC hook because the app owns auth there. The LDP wildcards sit beneath every app route, so a path the app did not register fell through to pod storage with WAC already skipped: an anonymous PUT wrote the file once the container existed, GET served it, DELETE removed it (reproduced on 0.0.224). The WAC hook now marks such requests and the wildcard handlers answer 404 for them. Sibling LDP paths are unchanged. Tests: app-paths (createServer appPaths and a plugin prefix, all methods, nothing written, the app's own route still answers, siblings still 401) and plugin-reservepath (a widened method at an unhandled reserved path).
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
A critical active finding remains in src/server.js where globally exempting OPTIONS from the WAC hook prevents app-path exemption detection, allowing wildcard preflight handling to still call storage.stat under app-owned subtrees and potentially leak existence/type information contrary to the intended access restrictions.
1 open issue
What changed in this PR
This pull request addresses a security gap where requests under WAC-exempt, application-owned URL subtrees (via appPaths, plugin prefix, or reservePath) could fall through to the LDP wildcard routes when no app route matched—allowing unintended pod storage reads/writes without WAC enforcement.
Changes:
- Mark app-subtree WAC exemptions on the request (
request.appPathExempt) to distinguish them from built-in exemptions. - Add an LDP wildcard-route guard (
preHandler) to return 404 for unhandled paths inside app-owned namespaces, preventing storage access. - Add regression tests for unhandled app-subtree paths (including plugin prefix cases) and a widened-method
reservePathresidual, plus documentation clarifying the behavior change.
| File | Notes |
|---|---|
test/plugin-reservepath.test.js |
Adds a regression test ensuring an unhandled reserved-path method widening returns 404 and does not write to storage. |
test/app-paths.test.js |
Adds cases ensuring unhandled paths under app prefixes return 404 (no reads/writes), while sibling LDP paths still enforce WAC and app routes still work. |
src/server.js |
Implements request flagging for app-subtree exemptions and blocks LDP wildcard fallthrough with a 404 guard; critical review note: OPTIONS is globally exempted from the WAC hook so the flag is not set for preflights, meaning OPTIONS /* under app subtrees may still reach handleOptions() and touch storage.stat(...). |
docs/configuration.md |
Documents that unhandled paths under app prefixes are 404 and should not be served from pod storage (place app-served pod files outside the app prefix where WAC applies). |
Review effort: Balanced
…h no storage lookup; fixed 404 message; temp fixture dir Both reviewers (Copilot and a Claude cloud review) pointed at the same gap: OPTIONS is exempted from WAC before any app-path check, so a preflight below an app prefix still ran handleOptions and its storage.stat, disclosing through Link headers whether a file or container exists in pod storage. The app-path check now runs first, so preflights carry the flag, and the OPTIONS wildcard answers them 204 with the CORS headers from the onRequest hook and nothing else. A test compares the headers for an existing file, a missing file, a container and a missing container below the prefix: identical. Also: the 404 body no longer echoes the request URL; the plugin fixture lives in a per-run temp dir that is removed afterwards; HEAD is covered.
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟢 Approval recommended
The change is narrowly scoped to blocking LDP wildcard storage access under app-exempt namespaces and is backed by targeted regression tests plus documentation clarifying the new 404/OPTIONS behavior, with no remaining issues indicated.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
Changes since 0.0.224: - Security: the dotfile guard decodes path segments before checking them, and the storage lookup refuses a segment that only becomes a dotfile by decoding, so `%2Egit/config` can no longer reach `.git/config`. Malformed percent-encoding and an encoded path separator (`%2F`) are refused with 400. New src/utils/dotfiles.js holds the shared rule. (#639, PR #640) - Conditional writes are atomic: PUT and DELETE join PATCH under the per-resource queue and cross-process lock file, so If-Match and If-None-Match are checked and acted on as one step. Two clients racing with the same ETag get one 2xx and one 412. The lock holder heartbeats so a slow write is never mistaken for a dead one; a stale lock is broken by rename and inode check, never a blind unlink; a request that cannot take the lock within 30 s gets 503 with Retry-After: 1. (#600, PR #638) - WAC-exempt app subtrees: a path under an app prefix that the app did not register answers 404 instead of falling through to pod storage with WAC skipped. OPTIONS under an app path is a bare 204. (#611, PR #637) - docs/security.md: Dotfiles and Conditional writes sections.

Fixes #611. Follows #607 (method-gated reservePath) and #582 (plugin prefixes join appPaths).
The hole
A request under an app prefix (createServer
appPaths, a plugin entryprefix, areservePathclaim) skips the WAC hook because the app owns auth there. The LDP wildcards (/*) sit beneath every app route, so a path the app did not register fell through to pod storage with WAC already skipped.Reproduced on 0.0.224 with a plugin at
/myapphandling only/myapp/echo, oncemyapp/existed in the data root:PUT /myapp/planted.txt→ 201, file writtenGET /myapp/secret.txt→ 200, private file servedDELETE /myapp/secret.txt→ 204PUT /elsewhere.txt→ 401 (correct)The fix
Two small pieces in
src/server.js:request.appPathExempt = true) instead of just returning. The built-in exemptions (/idp,/storage/,/db, …) are unchanged.preHandler: a flagged GET, HEAD, PUT, POST, PATCH or DELETE is answered 404 (no route in application namespace). Nothing is read or written. A flagged OPTIONS is answered with a bare 204 so CORS preflights for app routes keep working, without runninghandleOptionsand its storage lookup, so nothing about pod storage below the prefix is disclosed (review finding from Copilot and a Claude cloud review, second commit).A flag rather than the scoped fallback routes the issue sketches: fallback routes collide with apps that register their own
prefix/*wildcard (the existing app-paths test does exactly that) and depend on registration order. The flag has neither problem and also closes the #607 residual, a widened method at an unhandled reserved path.Behaviour change to note: an operator who listed a prefix in
appPathsand relied on LDP serving pod files below it without WAC now gets 404 there. That was an unauthenticated write hole as much as a read convenience; files an app wants served from the pod belong outside its prefix (/public/apps/<name>/), where WAC applies. docs/configuration.md says so.Tests
test/app-paths.test.js: six new cases, for both the createServerappPathsshape and a real plugin fixture: anonymous PUT is 404 and writes nothing; GET, HEAD, DELETE and PATCH are 404 and the file is untouched; OPTIONS is a bare 204 with identical headers for an existing file, a missing file, a container and a missing container; the app's own route still answers 200; a sibling LDP path is still 401. They fail on current gh-pages (4 of 13).test/plugin-reservepath.test.js: a widened POST at an unhandled reserved path is 404 and writes nothing.Full suite: 1103 pass, 0 fail.