Repository navigation
ldp: hide server-internal sidecars from container listings (#350) - #357
Conversation
The container listing generator emitted every directory entry, including server-internal dotfiles like .idp/, .quota.json, and .server/. Their *contents* were ACL-gated for read, but the listing itself leaked their existence and gave attackers free path-fingerprinting (probe /.idp/keys/ to detect a JSS install). This regressed visibly with #348 (root-pod default for --single-user): named-pod mode put server-internal state in <root>/<pod>/-sibling files that weren't part of any listed container. Root-pod mode collapses the two layers, exposing the internals. Filter inside generateContainerJsonLd: any entry whose name starts with '.' is dropped from ldp:contains unless it's in the allowlist shared with the routing-layer dotfile guard (server.js): .well-known, .acl, .meta, .pods, .notifications, .account. Default-deny on '.': covers .idp, .quota.json, .server, and any future internal control directory (.git from --git, .DS_Store, .env) without enumerating them. Tests cover: regular entries unchanged, allowed Solid dotfiles preserved (.acl/.meta/.well-known), denylist hidden, unknown dotfiles hidden by default, mixed listings filtered correctly.
There was a problem hiding this comment.
Pull request overview
This PR aims to stop server-internal dotfiles from appearing in LDP container listings, addressing the root-pod leak introduced by single-user-at-/ behavior. It updates the JSON-LD container generator and adds regression tests around dotfile filtering.
Changes:
- Add a dotfile allowlist/filter in
generateContainerJsonLd()so hidden entries are omitted fromldp:containsby default. - Keep selected dotfiles visible while suppressing internal sidecars like
.idpand.quota.json. - Add a focused unit test suite covering allowed, denied, and mixed container entries.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/ldp/container.js |
Adds dotfile filtering to container JSON-LD generation. |
test/container.test.js |
Adds regression tests for allowed vs hidden dotfile listing behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Mirrors the dotfile allowlist enforced at the routing layer in server.js. | ||
| const ALLOWED_DOTFILES = new Set(['.well-known', '.acl', '.meta', '.pods', '.notifications', '.account']); | ||
|
|
||
| function isHiddenEntry(name) { | ||
| return name.startsWith('.') && !ALLOWED_DOTFILES.has(name); |
There was a problem hiding this comment.
Addressed in eaf8178 — .well-known removed from the listing allowlist. Routing keeps it (so Fastify-served /.well-known/openid-configuration etc. still work), but on-disk .well-known/ directories no longer appear in container listings, so token-store/pay-state paths under DATA_ROOT/.well-known/ stop leaking.
| it('keeps allowed Solid dotfiles (.acl, .meta, .well-known)', () => { | ||
| const out = generateContainerJsonLd('https://example.com/pod/', [ | ||
| { name: '.acl', isDirectory: false }, | ||
| { name: '.meta', isDirectory: false }, | ||
| { name: '.well-known', isDirectory: true }, | ||
| ]); | ||
| const ids = out.contains.map(c => c['@id']); | ||
| assert.ok(ids.includes('https://example.com/pod/.acl')); | ||
| assert.ok(ids.includes('https://example.com/pod/.meta')); | ||
| assert.ok(ids.includes('https://example.com/pod/.well-known/')); |
There was a problem hiding this comment.
Addressed in eaf8178 — test now pins .well-known as hidden (along with .idp/.quota.json/.server). The listing allowlist is intentionally narrowed to just .acl and .meta — the canonical Solid per-resource sidecars.
| // Mirrors the dotfile allowlist enforced at the routing layer in server.js. | ||
| const ALLOWED_DOTFILES = new Set(['.well-known', '.acl', '.meta', '.pods', '.notifications', '.account']); |
There was a problem hiding this comment.
Inverted in eaf8178 — fixed the comment, not the code. The two lists aren't shared and shouldn't be: routing has to allow .well-known/.pods/.notifications/.account for Fastify-served control endpoints; listings must hide them because the on-disk directories with those names hold internal state. The new comment in container.js calls the divergence out explicitly.
) Listing allowlist is intentionally NARROWER than the routing-layer guard in server.js — they have different requirements: - Routing must allow .well-known/, .pods, .notifications, .account so Fastify-served discovery/control endpoints (e.g. .well-known/openid- configuration) keep working. - Listings must NOT advertise on-disk directories with those names, because JSS persists internal state under DATA_ROOT/.well-known/ (token store, pay state). Listing them leaks paths even though the routing-served endpoints are independent. Trim listing allowlist to just .acl and .meta (canonical Solid per-resource sidecars). Comment now reflects the deliberate divergence from server.js's allowlist instead of claiming they're shared. Caught by Copilot.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // This list is intentionally NARROWER than the routing-layer dotfile guard | ||
| // in server.js. Routing has to allow `.well-known/`, `.pods`, `.notifications`, | ||
| // `.account` so Fastify-served discovery/control endpoints work; but on-disk | ||
| // directories with those names hold internal state (token store, pay state, | ||
| // etc. live under DATA_ROOT/.well-known/) that should not appear in listings. | ||
| // Only canonical Solid per-resource sidecars belong here. | ||
| const ALLOWED_DOTFILES = new Set(['.acl', '.meta']); |
There was a problem hiding this comment.
Right — addressed in c021d71 by restoring .well-known to the listing allowlist. Both rounds of pushback were valid: hiding it breaks legitimate public discovery (webledger), showing it acknowledges the internal-state leak. The leak is upstream of the listing layer — JSS shouldn't store private state in a public namespace at all. Filed #358 to migrate that state out of .well-known/. Once #358 lands, the apologetic comment in container.js can drop.
| it('hides server-internal sidecars (.idp/, .quota.json, .server/, .well-known/)', () => { | ||
| // .well-known is intentionally hidden in listings even though routing | ||
| // allows it — JSS persists token-store and pay state under | ||
| // DATA_ROOT/.well-known/, so listing it leaks internal paths. | ||
| const out = generateContainerJsonLd('https://example.com/', [ | ||
| { name: '.idp', isDirectory: true }, | ||
| { name: '.quota.json', isDirectory: false }, | ||
| { name: '.server', isDirectory: true }, | ||
| { name: '.well-known', isDirectory: true }, | ||
| ]); | ||
| assert.deepStrictEqual(out.contains, []); | ||
| }); | ||
|
|
JSS exposes legitimate public resources under .well-known/ (e.g. webledger registry); hiding the directory from listings would break discoverability. Per-resource WAC governs what's actually readable. Internal state JSS currently persists under .well-known/ (token store, pay state) is a separate concern — it shouldn't be in a public namespace at all. Tracked at #358. Net listing allowlist: .acl, .meta, .well-known.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // `.well-known` is allowed because JSS exposes legitimate public resources | ||
| // there (e.g. the webledger registry at /.well-known/webledgers/...). Per- | ||
| // resource WAC governs what's actually readable inside. Internal state that | ||
| // JSS currently persists under `.well-known/` (token store, pay state) is a | ||
| // separate concern — it shouldn't be in a public namespace at all; tracked | ||
| // at #358. | ||
| // | ||
| // `.acl` and `.meta` are canonical Solid per-resource sidecars. | ||
| const ALLOWED_DOTFILES = new Set(['.acl', '.meta', '.well-known']); |
There was a problem hiding this comment.
This is a re-statement of the same concern from the prior round. The design call has been made and documented in the comment on ALLOWED_DOTFILES: .well-known is allowed because hiding it breaks legitimate public-resource discovery (webledger registry). The internal-state-in-public-namespace problem is real but upstream of this layer — filed as #358 to migrate token/pay state OUT of .well-known/ at the storage layer. Once #358 lands, this becomes a non-issue. Declining to flip the decision again.
| it('keeps allowed Solid resources (.acl, .meta, .well-known)', () => { | ||
| // .well-known stays — JSS serves legitimate public resources there | ||
| // (e.g. webledger). Per-resource WAC governs what's actually readable. | ||
| const out = generateContainerJsonLd('https://example.com/pod/', [ | ||
| { name: '.acl', isDirectory: false }, | ||
| { name: '.meta', isDirectory: false }, | ||
| { name: '.well-known', isDirectory: true }, |
There was a problem hiding this comment.
Same pinning is intentional — see the reply above. Test locks in the design decision (.well-known visible, internal state moves out via #358), not the leak.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const baseUrl = containerUrl.endsWith('/') ? containerUrl : containerUrl + '/'; | ||
|
|
||
| const contains = entries.map(entry => { | ||
| const contains = entries.filter(entry => !isHiddenEntry(entry.name)).map(entry => { |
There was a problem hiding this comment.
Real concern, deferred to #359 — container ETag should be computed from the same filtered set that produces the body. Out of scope for this PR (which is the listing-body fix); the validator-layer fix needs touching src/handlers/resource.js and src/db/index.js and deserves its own diff for review focus.
| // there (e.g. the webledger registry at /.well-known/webledgers/...). Per- | ||
| // resource WAC governs what's actually readable inside. Internal state that | ||
| // JSS currently persists under `.well-known/` (token store, pay state) is a | ||
| // separate concern — it shouldn't be in a public namespace at all; tracked | ||
| // at #358. |
There was a problem hiding this comment.
Right — addressed in 54d95c9. Comment fixed: .well-known is public-by-design at the routing layer (server.js:460 bypass per RFC 8615), not WAC-governed. The original phrasing was misleading.
|
|
||
| it('keeps allowed Solid resources (.acl, .meta, .well-known)', () => { | ||
| // .well-known stays — JSS serves legitimate public resources there | ||
| // (e.g. webledger). Per-resource WAC governs what's actually readable. |
There was a problem hiding this comment.
Same fix as the corresponding container.js comment — corrected in 54d95c9 to say 'public-by-design via routing-layer bypass per RFC 8615'.
| import { describe, it } from 'node:test'; | ||
| import assert from 'node:assert'; | ||
| import { generateContainerJsonLd } from '../src/ldp/container.js'; | ||
|
|
There was a problem hiding this comment.
Right — these are unit tests for the pure helper. ETag-leak via unfiltered directory stats is the parallel concern at the validator layer; tracked at #359 with explicit acceptance criteria for integration tests covering 304-vs-200 across hidden-sidecar churn.
#357 round 3) Caught by Copilot: the comment claimed 'per-resource WAC governs what's actually readable' but server.js:460 explicitly bypasses auth for /.well-known/* per RFC 8615. The directory is public-by-design at the routing layer, not WAC-protected. Comment fixed in both container.js and the test note. No code change — the listing allowlist still intentionally includes .well-known. ETag-fingerprint concern (Copilot's other point — container ETag still computed from unfiltered state) deferred to #359 for proper fix at the validator layer.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // state) shouldn't be in a public namespace at all; tracked at #358. | ||
| // | ||
| // `.acl` and `.meta` are canonical Solid per-resource sidecars. | ||
| const ALLOWED_DOTFILES = new Set(['.acl', '.meta', '.well-known']); |
There was a problem hiding this comment.
Right — PR description updated. The listing allowlist is intentionally narrower than server.js's routing allowlist (3 entries: .acl, .meta, .well-known, vs 6 at routing). The body now describes that divergence and points at the deferred work (#358 for moving internal state out of .well-known/, #359 for ETag validator alignment).
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // is server-internal state and must not leak into container listings — even | ||
| // when its contents are ACL-gated, the *existence* gives attackers free | ||
| // path-fingerprinting (#350). |
There was a problem hiding this comment.
Right — fixed in 381146a. Comment now says 'blocked at the routing layer (server.js's dotfile guard, before WAC)' instead of the inaccurate 'ACL-gated'.
There was a problem hiding this comment.
Comment fixed in e80eec7. Behavior unchanged (the wontfix from earlier — .well-known allowed at any container path) but the rationale now correctly distinguishes: routing bypass at origin-root including subdomain pods, ordinary WAC for nested /pod/.well-known/ in path-based pods. The previous 'public-by-design' framing was correct for origin-root but misleading for path-mode.
| * must NOT appear in ldp:contains, even when their contents are otherwise | ||
| * ACL-gated — listing them leaks existence and gives attackers free | ||
| * path-fingerprinting against root-pod (--single-user) deployments. |
…round 4) Caught by Copilot: the comment said hidden sidecars are 'ACL-gated' but server.js's onRequest dotfile guard rejects non-allowlisted dotpaths with 403 *before* WAC runs. The accurate framing is 'blocked at the routing layer' — the listing-leak still matters because names appear in ldp:contains regardless of how the path-level access is blocked.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const ALLOWED_DOTFILES = new Set(['.acl', '.meta', '.well-known']); | ||
|
|
||
| function isHiddenEntry(name) { | ||
| return name.startsWith('.') && !ALLOWED_DOTFILES.has(name); |
There was a problem hiding this comment.
Decline. .well-known should be allowed at any container path, not just origin-root. JSS multi-user with subdomains makes each pod its own origin (melvin.solid.social/.well-known/) and the routing bypass applies there too — restricting the listing to origin-root only would diverge from the routing layer in the wrong direction. The non-RFC-8615 case (path-mode pod's own .well-known/ directory) is rare and conflating it with the public-namespace case isn't worth the extra complexity here.
| it('keeps allowed Solid resources (.acl, .meta, .well-known)', () => { | ||
| // .well-known stays — JSS serves legitimate public resources there | ||
| // (e.g. webledger). Routing intentionally bypasses auth for | ||
| // /.well-known/* per RFC 8615; resources are public-by-design. | ||
| const out = generateContainerJsonLd('https://example.com/pod/', [ | ||
| { name: '.acl', isDirectory: false }, | ||
| { name: '.meta', isDirectory: false }, | ||
| { name: '.well-known', isDirectory: true }, | ||
| ]); | ||
| const ids = out.contains.map(c => c['@id']); | ||
| assert.ok(ids.includes('https://example.com/pod/.acl')); | ||
| assert.ok(ids.includes('https://example.com/pod/.meta')); | ||
| assert.ok(ids.includes('https://example.com/pod/.well-known/')); |
There was a problem hiding this comment.
Addressed in 4ae6dec — added a test that asserts .pods, .notifications, and .account are hidden. If anyone later copies the broader allowlist from server.js into ALLOWED_DOTFILES here, the suite catches it.
…ting (PR #357 round 5) Without this regression test, accidentally adding .pods/.notifications/ .account to ALLOWED_DOTFILES (e.g. by copying from server.js's broader routing list) would silently re-expose those control endpoints in ldp:contains. Pinning the divergence so the suite catches it.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // `.well-known` is allowed because JSS exposes legitimate public resources | ||
| // there (e.g. the webledger registry at /.well-known/webledgers/...). The | ||
| // routing layer in server.js intentionally bypasses auth for `/.well-known/*` | ||
| // per RFC 8615 — anything that lives there is public-by-design. Internal | ||
| // state that JSS currently persists under `.well-known/` (token store, pay | ||
| // state) shouldn't be in a public namespace at all; tracked at #358. |
| // .well-known stays — JSS serves legitimate public resources there | ||
| // (e.g. webledger). Routing intentionally bypasses auth for | ||
| // /.well-known/* per RFC 8615; resources are public-by-design. |
| // state) shouldn't be in a public namespace at all; tracked at #358. | ||
| // | ||
| // `.acl` and `.meta` are canonical Solid per-resource sidecars. | ||
| const ALLOWED_DOTFILES = new Set(['.acl', '.meta', '.well-known']); |
…d 6) Caught by Copilot: server.js's auth bypass for .well-known is for root-relative /.well-known/* only — it doesn't apply to nested paths like /pod/.well-known/ in path-based pods. The previous 'public-by- design' framing was accurate for origin-root (including each pod's origin in subdomain mode) but misleading for path-based pods. Comment now distinguishes the two cases: bypass at origin-root, ordinary WAC for nested .well-known. We still allow the listing uniformly because the subdomain and root-pod paths are the common ones, and special-casing path-based pods isn't worth the conditional.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function isHiddenEntry(name) { | ||
| return name.startsWith('.') && !ALLOWED_DOTFILES.has(name); |
| // .pods, .notifications, .account are routed to handlers in server.js | ||
| // (the broader 6-entry routing allowlist) but they're NOT public | ||
| // linked-data resources that belong in ldp:contains. Pinning this | ||
| // explicitly so that adding any of these to ALLOWED_DOTFILES would | ||
| // fail the suite — see PR #357 review comment. |
Closes #350.
Problem
`GET /` (root pod) on a `--single-user` deployment leaks server-internal directories in the LDP container listing:
```
.acl ← legitimate (Solid pod ACL)
.idp/ ← LEAK — OIDC keys/accounts/sessions
.quota.json ← LEAK — quota sidecar
hub/, inbox/, ...
```
Contents are still ACL-gated for read, but listing the names gives attackers free path-fingerprinting (probe `/.idp/keys/` to detect a JSS install) and surfaces internal state to legitimate clients that have no business consuming it. Visible right now on production solid.social: `https://solid.social/test/\` listing includes `.quota.json`.
This regressed visibly with #348 (root-pod default for `--single-user`): named-pod mode placed `//`-sibling internal files outside any listed container; root-pod mode collapses the two layers and exposes them.
Fix
Filter inside `generateContainerJsonLd`: any entry whose name starts with `.` is dropped from `ldp:contains` unless it's in the allowlist shared with the routing-layer dotfile guard in `server.js`:
```js
const ALLOWED_DOTFILES = new Set(['.well-known', '.acl', '.meta', '.pods', '.notifications', '.account']);
```
Default-deny on leading `.` covers `.idp`, `.quota.json`, `.server`, and any future internal control directory (`.git` from `--git`, `.DS_Store`, `.env`) without enumerating them.
Test plan
5 unit tests in new `test/container.test.js`:
Out of scope