Skip to content

fix(files): skip directory symlinks that loop back onto the scanned path - #63868

Open
nikaiw wants to merge 1 commit into
nextcloud:masterfrom
nikaiw:fix/scanner-symlink-loops
Open

fix(files): skip directory symlinks that loop back onto the scanned path#63868
nikaiw wants to merge 1 commit into
nextcloud:masterfrom
nikaiw:fix/scanner-symlink-loops

Conversation

@nikaiw

@nikaiw nikaiw commented Sep 1, 2026

Copy link
Copy Markdown

SUMMARY

On a local storage, symlinks to a directories are followed even
if the directory is a parent directory or the directory itself.

Under these conditions, the Nextcloud metadata scanner
continues traversing the tree until it reaches the limit.
Re-entering the same tree in loop.

Basically it will fill the oc_filecache SQL table with a new entry
until the path reach the limit of oc_filecache.path column varchar(4000)

Impact

We had a server crash because Nextcloud filled the database disk
by creating 30M row in this table and producing a 185 GB database.
This is a DoS to become that can be triggered just by creating a symlink.

History

The bug is known since at least 2017 see #6395 (SMB), #20197, #23022
A previous fix #21723 was closed unmerged.

Proposed Fix

Local::getDirectoryContent() will skip a symlink whose target is
the directory being listed or a parent directory.
We are comparing both path after resolution so that we also catches
cycles ( a -> b, b->a ).

@nikaiw
nikaiw requested a review from a team as a code owner September 1, 2026 00:14
@nikaiw
nikaiw requested review from Altahrim, icewind1991, leftybournes and sorbaugh and removed request for a team September 1, 2026 00:14
@joshtrichards

Copy link
Copy Markdown
Member

Also #41563

@joshtrichards joshtrichards added bug 3. to review Waiting for reviews hotspot: filename handling Filenames - invalid, portable, blacklisting, etc. community pull requests from community feature: filesystem labels Sep 1, 2026
@susnux

susnux commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution!

Please follow our AI policy: https://github.com/nextcloud/.github/blob/master/AI_POLICY.md#disclosure
You commit is missing the AI disclosure. Moreover communication has to be done by a human meaning please use your own words for the PR summary and commit message - it shows you reviewed and understood the AI output.

SUMMARY

On a local storage, symlinks to a directories are followed even
if the directory is a parent directory or the directory itself.

Under these conditions, the Nextcloud metadata scanner
continues traversing the tree until it reaches the limit.
Re-entering the same tree in loop.

Basically it will fill the oc_filecache SQL table with a new entry
until the path reach the limit of oc_filecache.path column varchar(4000)

Impact

We had a server crash because Nextcloud filled the database disk
by creating 30M row in this table and producing a 185 GB database.
This is a DoS to become that can be triggered just by creating a symlink.

History

The bug is known since at least 2017 see nextcloud#6395 (SMB), nextcloud#20197, nextcloud#23022
A previous fix nextcloud#21723 was closed unmerged.

Proposed Fix

Local::getDirectoryContent() will skip a symlink whose target is
the directory being listed or a parent directory.
We are comparing both path after resolution so that we also catches
cycles ( a -> b, b->a ).

Signed-off-by: NK <nicolas.devillers@airbus.com>
Assisted-by: ClaudeCode:claude-fable-5
@nikaiw
nikaiw force-pushed the fix/scanner-symlink-loops branch from 2b4ab6f to ea4a989 Compare September 1, 2026 21:39
@nikaiw

nikaiw commented Sep 1, 2026

Copy link
Copy Markdown
Author

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted bug community pull requests from community feature: filesystem hotspot: filename handling Filenames - invalid, portable, blacklisting, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: files:scan follows symlink -> endless loop

3 participants