Skip to content

Add safe-links handling and tests - #1132

Merged
oferchen merged 2 commits into
masterfrom
implement-missing-components-for-oc-rsync
Oct 25, 2025
Merged

oferchen merged 2 commits into
masterfrom
implement-missing-components-for-oc-rsync

Conversation

@oferchen

@oferchen oferchen commented Oct 25, 2025 •

Copy link
Copy Markdown
Owner

Summary

  • wire the --safe-links flag through the CLI configuration and remote fallback arguments
  • ensure the core fallback launcher and client events honour skipped unsafe symlinks
  • cover safe symlink acceptance and rejection in the engine's local copy tests

Testing

  • cargo test -p rsync-cli
  • cargo test -p rsync-core
  • cargo test -p rsync-engine --lib

@oferchen
oferchen merged commit 2804fbc into master Oct 25, 2025
@oferchen
oferchen deleted the implement-missing-components-for-oc-rsync branch October 25, 2025 19:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +7951 to +7973
let mut depth: i64 = 0;
for component in link_relative.components() {
match component {
Component::ParentDir => depth = 0,
Component::CurDir => {}
Component::Normal(_) => depth += 1,
Component::RootDir | Component::Prefix(_) => depth = 0,
}
}

for component in target.components() {
match component {
Component::ParentDir => {
depth -= 1;
if depth < 0 {
return false;
}
}
Component::CurDir => {}
Component::Normal(_) => depth += 1,
Component::RootDir | Component::Prefix(_) => return false,
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Safe-links allows '../' symlinks to escape root

The safety check bases its starting depth on link_relative.components() including the symlink file name. For a link at the transfer root (link_relative = "link") that points to ../etc/passwd, depth starts at 1, the single ParentDir never drives it negative, and symlink_target_is_safe returns true. The caller therefore copies the symlink even though --safe-links should skip it because it points outside the destination tree. Any symlink in a subdirectory with exactly one extra .. component is also misclassified as safe. The depth should be computed from the link’s parent directory, not including the file name, so that a single .. from the root triggers an unsafe result.

Useful? React with 👍 / 👎.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant