Skip to content
This repository was archived by the owner on Aug 31, 2026. It is now read-only.

fix: skip inaccessible children when listing directories - #5958

Merged
hacdias merged 2 commits into
filebrowser:masterfrom
puneetdixit200:fix/5627-skip-inaccessible-children
Jun 4, 2026
Merged

hacdias merged 2 commits into
filebrowser:masterfrom
puneetdixit200:fix/5627-skip-inaccessible-children

Conversation

@puneetdixit200

Copy link
Copy Markdown
Contributor

Description

Fixes directory listing so one inaccessible child does not make the whole parent directory fail to load.

When afero.ReadDir fails because a child cannot be statted, the listing now falls back to reading names only, stats each child separately, and skips only entries that still cannot be read. Accessible siblings continue to be returned in the listing.

Fixes #5627

Additional Information

This keeps the current fast path unchanged. The fallback is only used after the normal directory read fails.

Testing

  • Red before fix: GOMODCACHE=/tmp/filebrowser-5627-gomodcache GOCACHE=/tmp/filebrowser-5627-gocache go test ./files -run TestReadListingSkipsInaccessibleChildren -count=1 failed with permission denied
  • GOMODCACHE=/tmp/filebrowser-5627-gomodcache GOCACHE=/tmp/filebrowser-5627-gocache go test ./files -run TestReadListingSkipsInaccessibleChildren -count=1
  • GOMODCACHE=/tmp/filebrowser-5627-gomodcache GOCACHE=/tmp/filebrowser-5627-gocache go test ./files -count=1
  • test -z "$(gofmt -l files/file.go files/file_test.go)"
  • git diff --cached --check
  • GOMODCACHE=/tmp/filebrowser-5627-gomodcache GOCACHE=/tmp/filebrowser-5627-gocache go test ./...
  • GOMODCACHE=/tmp/filebrowser-5627-gomodcache GOCACHE=/tmp/filebrowser-5627-gocache go build ./...

golangci-lint is not installed in my local environment, so I could not run the repo lint config locally.

Checklist

  • I am aware the project is currently in maintenance-only mode and new feature requests won't be accepted. See README
  • I am aware that translations MUST be made through Transifex and that this PR is NOT a translation update
  • I am making a PR against the master branch.
  • I am sure File Browser can be successfully built. See builds and development.

@puneetdixit200
puneetdixit200 requested a review from a team as a code owner May 22, 2026 08:21
@puneetdixit200 puneetdixit200 changed the title Skip inaccessible children when listing directories fix: skip inaccessible children when listing directories May 22, 2026
@puneetdixit200 puneetdixit200 changed the title fix: skip inaccessible children when listing directories fix(files): skip inaccessible children when listing directories May 24, 2026
@puneetdixit200 puneetdixit200 changed the title fix(files): skip inaccessible children when listing directories fix: skip inaccessible children when listing directories May 24, 2026
@puneetdixit200 puneetdixit200 changed the title fix: skip inaccessible children when listing directories fix(files): skip inaccessible children when listing directories May 24, 2026
@puneetdixit200 puneetdixit200 changed the title fix(files): skip inaccessible children when listing directories fix: skip inaccessible children when listing directories May 26, 2026
@puneetdixit200 puneetdixit200 changed the title fix: skip inaccessible children when listing directories fix(files): skip inaccessible children when listing directories May 26, 2026
@puneetdixit200 puneetdixit200 changed the title fix(files): skip inaccessible children when listing directories fix: skip inaccessible children when listing directories May 28, 2026
@puneetdixit200
puneetdixit200 force-pushed the fix/5627-skip-inaccessible-children branch from 1f57d18 to 00c7c66 Compare June 3, 2026 13:09
@puneetdixit200

Copy link
Copy Markdown
Contributor Author

Rebased this onto current master and fixed the backend lint issue from the previous CI run (QF1008 in files/file_test.go).

Local verification on Go 1.26.3:

  • go test ./files -run TestReadListingSkipsInaccessibleChildren -count=1
  • go test ./files -count=1
  • go test ./...
  • go build ./...
  • golangci-lint run (0 issues)
  • gofmt check for files/file.go and files/file_test.go
  • git diff --check upstream/master...HEAD

GitHub has only run the title check on the new head so far; the main CI workflow has not been scheduled yet.

@puneetdixit200

Copy link
Copy Markdown
Contributor Author

Merged current master into this branch and resolved the test-file conflict by keeping both the upstream WithinScope coverage and this PR's inaccessible-child listing regression test.

Local verification on the new head 6df2c90d:

  • go test ./files -run 'Test(ReadListingSkipsInaccessibleChildren|WithinScope)' -count=1\n- go test ./files -count=1\n- go test ./...\n- go build ./...\n- gofmt check for files/file.go and files/file_test.go\n- git diff --check upstream/master...HEAD\n\nGitHub has started the title check on the refreshed branch; I do not see the main CI workflow scheduled on this head yet.

@puneetdixit200
puneetdixit200 force-pushed the fix/5627-skip-inaccessible-children branch from 6df2c90 to 1089a60 Compare June 3, 2026 13:57
@puneetdixit200

Copy link
Copy Markdown
Contributor Author

Rebased onto current master and resolved the files/file_test.go conflict by keeping the new upstream WithinScope coverage plus this PR's inaccessible-child listing regression.

Local verification after the rebase:

  • go test ./files -run 'Test(ReadListingSkipsInaccessibleChildren|WithinScope)' -count=1
  • go test ./files -count=1
  • go test ./...
  • go build ./...
  • golangci-lint run (0 issues)
  • gofmt check for files/file.go and files/file_test.go
  • git diff --check upstream/master...HEAD

The branch is mergeable again on GitHub. As before, GitHub has only scheduled the title check on the new head so far; the main CI workflow has not appeared yet.

@hacdias
hacdias merged commit 7b7ff8a into filebrowser:master Jun 4, 2026
7 checks passed
jasongainor referenced this pull request in jasongainor/filebrowser-NC Jun 13, 2026
…128)

* chore: update translations

Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com>

* chore(deps): update all non-major dependencies (#5926)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix: Fix conflict modal and add a resume transfert option (#5884)

Co-authored-by: Henrique Dias <[email protected]>

* chore(release): 2.63.3

* chore(deps): update all non-major dependencies (#5929)

* chore: sync translations

* chore: fix typo

* fix: show item shares from all users to admins (#5941)

* chore: sync translations (#5945)

* chore: revert node dependencies updates

* chore(release): 2.63.4

* fix(router): handle undefined catchAll param on root redirect (#5955)

* chore(release): 2.63.5

* chore: disable automatic major updates

* fix: remove undocumented hook auth with shell replacement

* docs: clarify hide dotfiles

* fix: incorrect access control in public directory shares via rule path rebasing

* fix: cross-user unauthorized share-link deletion

* fix: address three security disclosures (archive traversal, login DoS, symlink escape)

- http/raw.go: strip Windows backslash separators from archive entry names
  on any host. filepath.ToSlash is a no-op for "\" on Linux, so a stored
  backslash filename was emitted verbatim and could escape the extraction
  directory on Windows extractors (zip-slip). (GHSA-gxjx-7m74-hcq8)

- http/auth.go: cap the login and signup request bodies with
  http.MaxBytesReader (1 MiB). The JSON decoder previously read an
  arbitrarily large password into memory before bcrypt truncated it,
  enabling unauthenticated memory-exhaustion DoS. (GHSA-w5fm-68j4-fpc4)

- files/file.go, http/resource.go: add files.WithinScope and refuse to
  follow a symlink whose on-disk target escapes the user's scoped root,
  on both the read path (stat) and the write path (writeFile). Prevents a
  scoped user from reading/overwriting/sharing files outside their scope
  via a pre-existing escaping symlink. (GHSA-239w-m3h6-ch8v)

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix: parse csv files with uneven columns in their rows (#5965)

* chore: Updates for project File Browser (#5947)

* chore(docs): update CLI documentation

* chore(release): 2.63.6

* fix: disallow shares for non-existent paths

* chore(release): 2.63.7

* fix: check if share is within scope when creating

* chore(release): 2.63.8

* fix: force octet-stream for attachment downloads (#5942)

* fix: prevent symlink scope escape in copy/move/rename

Check WithinScope for src and dst in resourcePatchHandler before
fileutils.Copy/MoveFile, which follow symlinks and bypassed the
stat()/writeFile() guards (GHSA-239w-m3h6-ch8v).

* fix: use constant-time comparison for share access token

Compare the share token with subtle.ConstantTimeCompare instead of ==.

* fix: set X-Content-Type-Options: nosniff on raw file responses

Prevents browsers from MIME-sniffing uploaded files into a renderable type.

* chore(release): 2.63.9

* fix: allow writes when user scope resolves to filesystem root

WithinScope compared targets against root+separator, which produced
"//" when the scope resolved to "/". No path matched, so every write
was rejected with os.ErrPermission (HTTP 403), breaking saves and
uploads for root-scoped installs. Skip the appended separator when root
already ends in one.

* chore(release): 2.63.10

* fix: incomplete fix for symlinked directories let scopes users and public-share recipients read and write files outside of scope

* chore(release): 2.63.11

* fix: skip inaccessible children when listing directories (#5958)

* fix: keep mobile file sort controls visible (#5977)

* fix: await copy move conflict detection (#5978)

* chore(release): 2.63.12

* refactor: cleanup and simplify upload.ts

* fix: copy/move allow overwrite

* chore(release): 2.63.13

* fix: recursive check

* refactor: ScopedFs to avoid escaping symlinks

* chore: add symlink tests

* chore(release): 2.63.14

---------

Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Anthony Geourjon <[email protected]>
Co-authored-by: Henrique Dias <[email protected]>
Co-authored-by: mehmet turac <[email protected]>
Co-authored-by: Jose Olcese <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
Co-authored-by: Ariel Leyva <[email protected]>
Co-authored-by: Puneet Dixit <[email protected]>
Co-authored-by: Agent Overnight Tests <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Cannot list directory if at least one subfolder is inaccessible

2 participants