Security: Scanner follows symlinks and can traverse outside source tree #192

Closed
opened 2026-07-30 18:34:46 +02:00 by TapTap · 0 comments
Owner

Severity: medium
Category: security
Location: src/client/scanner.c:102-109

Description:
directory_scanner_next() uses stat() instead of lstat(). This causes two problems:

  1. Symlinks are followed transparently. A symlink in the source tree can point outside the source directory, causing the client to read and transfer files it was not asked to access.
  2. A symlink cycle can cause infinite recursion and stack exhaustion during directory traversal.

Suggested fix:

  1. Use lstat() to identify symlinks.
  2. Add a --links / -l option (see feature issue) to preserve symlinks as symlinks instead of following them.
  3. Until symlink preservation is implemented, detect symlinks and skip them by default, or follow them with a depth/recursion limit and cycle detection.

Labels: security, traversal

**Severity:** medium **Category:** security **Location:** `src/client/scanner.c:102-109` **Description:** `directory_scanner_next()` uses `stat()` instead of `lstat()`. This causes two problems: 1. Symlinks are followed transparently. A symlink in the source tree can point outside the source directory, causing the client to read and transfer files it was not asked to access. 2. A symlink cycle can cause infinite recursion and stack exhaustion during directory traversal. **Suggested fix:** 1. Use `lstat()` to identify symlinks. 2. Add a `--links` / `-l` option (see feature issue) to preserve symlinks as symlinks instead of following them. 3. Until symlink preservation is implemented, detect symlinks and skip them by default, or follow them with a depth/recursion limit and cycle detection. **Labels:** security, traversal
TapTap added the securityneeds-triage labels 2026-07-30 18:34:46 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#192