Bug/Security: chown() failures during metadata restoration are silently ignored #169

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

Description

file_restore_metadata() in src/shared/metadata.c:100 calls chown(path, metadata->uid, metadata->gid) but explicitly casts away the return value. If chown() fails (e.g., insufficient privileges, invalid uid/gid), the failure is silently ignored, and the caller believes metadata was fully restored. When the server runs as an unprivileged user, it may also unintentionally apply a uid/gid from a different machine that has no meaning locally.

Location

  • src/shared/metadata.c:100-101int chown_ret = chown(...); (void)chown_ret;

Suggested fix

  1. Check chown_ret and log/return an error on failure.
  2. Consider whether restoring uid/gid from a remote peer is appropriate at all; at minimum, it should only be attempted when the receiver is running as root and the caller has opted in.

Severity

Low

Category

bug, security


This issue was automatically generated by the issue-creator agent.

## Description `file_restore_metadata()` in `src/shared/metadata.c:100` calls `chown(path, metadata->uid, metadata->gid)` but explicitly casts away the return value. If `chown()` fails (e.g., insufficient privileges, invalid uid/gid), the failure is silently ignored, and the caller believes metadata was fully restored. When the server runs as an unprivileged user, it may also unintentionally apply a `uid`/`gid` from a different machine that has no meaning locally. ## Location - `src/shared/metadata.c:100-101` — `int chown_ret = chown(...); (void)chown_ret;` ## Suggested fix 1. Check `chown_ret` and log/return an error on failure. 2. Consider whether restoring `uid`/`gid` from a remote peer is appropriate at all; at minimum, it should only be attempted when the receiver is running as root and the caller has opted in. ## Severity Low ## Category bug, security --- _This issue was automatically generated by the issue-creator agent._
TapTap added the bugsecurityneeds-triage labels 2026-07-29 18:36:34 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#169