Skip to content

fix(daemon): route the log-file open onto the ownership walk - #7441

Merged
oferchen merged 1 commit into
masterfrom
fix/daemon-log-file-ownership-walk
Aug 22, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/daemon-log-file-ownership-walk

Conversation

@oferchen

Copy link
Copy Markdown
Owner

What

The daemon opened its log file with a plain path-based
OpenOptions::new().create(true).append(true). Upstream opens every log file
through the ownership walk:

logfile_fp = fdopen(open_no_attacker_symlinks(logfile_name,
                    O_WRONLY|O_APPEND|O_CREAT, 0644), "a");

log.c:169-170, reached by log_init() for both the client --log-file and the
daemon's log sink. The reason is stated at log.c:165: these are
operator-supplied paths that may transit attacker-writable directories, and a
symlink planted at any component redirects a root daemon's log into a file of the
attacker's choosing. The walk refuses symlink components not owned by uid 0 or
our euid.

The client --log-file was already routed through the walk, but requested mode
0666 where upstream passes 0644. Both sinks now pass 0644.

Why 0644 and not 0666

Upstream wraps its open in umask(022 | orig_umask) (log.c:163) so a permissive
umask can never produce a group- or world-writable log. Requesting 0644 reaches
the same fixed point without the dance - 0644 holds no group or other write bit
for a umask to have to clear.

Tests

tests/log_file_created_with_upstream_mode.rs pins both sinks, each with the
spawned child's umask pinned to 0 via pre_exec.

The umask pin is what makes the assertion mean anything: umask(2) can only
clear bits, so under the usual 022 a 0666 request also lands as 0644 and
the two spellings become indistinguishable. Under umask 0, 0666 stays 0666
and only a genuine 0644 request reads back as 0644 - so the same assertion
also discriminates routing, since an open that passes no mode at all cannot
produce 0644.

A third test (pinning_the_child_umask_takes_effect) validates that instrument
directly, so the pair cannot pass vacuously if the pin ever stops applying.

Proven RED three ways, each with the others staying green:

mutation result
both mode constants -> 0o666 both mode tests fail, control green
daemon open -> plain OpenOptions daemon test fails, client + control green
(unmutated) 3/3 green

Verification

  • cargo fmt --all -- --check, workspace clippy -D warnings: clean
  • Windows GNU cross-check (-D warnings, --all-targets) on daemon + cli: clean
  • cargo nextest run -p daemon --all-features: 1814 passed, 0 failed
  • log-file sweep across cli + root integration tests: 27 passed, 0 failed

The daemon opened its log file with a plain path-based
`OpenOptions::new().create(true).append(true)`, while upstream opens
every log file through `open_no_attacker_symlinks()`:

    logfile_fp = fdopen(open_no_attacker_symlinks(logfile_name,
                        O_WRONLY|O_APPEND|O_CREAT, 0644), "a");

(log.c:169-170). The reason is stated at log.c:165 - `--log-file` and
`log file =` are operator-supplied paths that may transit
attacker-writable directories, and a symlink planted at any component
redirects a root daemon's log into a file of the attacker's choosing.
The walk refuses symlink components not owned by uid 0 or our euid.

The client `--log-file` was already routed, but requested mode `0666`
where upstream passes `0644`. Upstream additionally wraps its open in
`umask(022 | orig_umask)` (log.c:163) so a permissive umask can never
yield a group- or world-writable log; `0644` reaches the same fixed
point without the dance, because it holds no group or other write bit
for a umask to have to clear. Both sinks now pass `0644`.

Tests pin both sinks with the child's umask pinned to 0, which is what
makes the assertion discriminating: umask can only clear bits, so under
the usual 022 a `0666` request also lands as `0644` and the two
spellings are indistinguishable. A third test validates that instrument
directly, so the pair cannot pass vacuously if the umask pin ever stops
applying.
@github-actions github-actions Bot added the bug Something isn't working label Aug 22, 2026
@oferchen
oferchen merged commit 01544c1 into master Aug 22, 2026
72 checks passed
@oferchen
oferchen deleted the fix/daemon-log-file-ownership-walk branch August 22, 2026 14:55
oferchen added a commit that referenced this pull request Aug 24, 2026
…7477)

The docs were last refreshed at #7423; 55 PRs have merged since, and the
testsuite figures they quote had drifted far enough to understate the
current state by roughly half.

CHANGELOG: fill in Unreleased for everything merged since #7423. The
dominant theme is routing every operator-named auxiliary file open onto
the ownership walk - upstream's open_no_attacker_symlinks() applied at the
call sites upstream applies it - plus a daemon hardening batch and an
alt-dest correctness batch.

README and SECURITY: the per-leg outcome tables were re-derived from the
committed expect manifests rather than carried forward. Failures fell and
the corpus grew, so every figure moved:

  non-root pipe  43 -> 21 fail   (345 -> 349 corpus)
  root pipe      62 -> 29 fail   (345 -> 349 corpus)
  non-root tcp   42 -> 29 fail   (155 -> 158 corpus)
  root tcp       55 -> 38 fail   (155 -> 158 corpus)

Distinct divergences: 64 -> 31 across the two full-corpus legs, 89 -> 55
across all four.

SECURITY, two CVE rows that had gone stale:
- CVE-2026-53790 said "under audit". The refusal has since been applied at
  the live sink - oc-rsync's own single-character config expander, which
  upstream does not have, so an upstream-shaped port alone would have been
  inert (#7465, #7430, #7445).
- CVE-2026-53795 listed only the staging family. The auxiliary-file family
  followed it onto the walk (#7421-#7426, #7439, #7441-#7443, #7459,
  #7463); what remains is the per-option-family confinement.
oferchen added a commit that referenced this pull request Aug 24, 2026
…7477)

The docs were last refreshed at #7423; 55 PRs have merged since, and the
testsuite figures they quote had drifted far enough to understate the
current state by roughly half.

CHANGELOG: fill in Unreleased for everything merged since #7423. The
dominant theme is routing every operator-named auxiliary file open onto
the ownership walk - upstream's open_no_attacker_symlinks() applied at the
call sites upstream applies it - plus a daemon hardening batch and an
alt-dest correctness batch.

README and SECURITY: the per-leg outcome tables were re-derived from the
committed expect manifests rather than carried forward. Failures fell and
the corpus grew, so every figure moved:

  non-root pipe  43 -> 21 fail   (345 -> 349 corpus)
  root pipe      62 -> 29 fail   (345 -> 349 corpus)
  non-root tcp   42 -> 29 fail   (155 -> 158 corpus)
  root tcp       55 -> 38 fail   (155 -> 158 corpus)

Distinct divergences: 64 -> 31 across the two full-corpus legs, 89 -> 55
across all four.

SECURITY, two CVE rows that had gone stale:
- CVE-2026-53790 said "under audit". The refusal has since been applied at
  the live sink - oc-rsync's own single-character config expander, which
  upstream does not have, so an upstream-shaped port alone would have been
  inert (#7465, #7430, #7445).
- CVE-2026-53795 listed only the staging family. The auxiliary-file family
  followed it onto the walk (#7421-#7426, #7439, #7441-#7443, #7459,
  #7463); what remains is the per-option-family confinement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant