Skip to content

Contain nested wheel-data symlinks - #20431

Open
zanieb wants to merge 1 commit into
astral-sh:mainfrom
zaniebot:zb/bughunt100/096-nested-data-symlink-containment
Open

Contain nested wheel-data symlinks#20431
zanieb wants to merge 1 commit into
astral-sh:mainfrom
zaniebot:zb/bughunt100/096-nested-data-symlink-containment

Conversation

@zanieb

@zanieb zanieb commented Jul 15, 2026

Copy link
Copy Markdown
Member

A nested symlink beneath tool.uv.build-backend.data can package files outside the source tree or files excluded from the source and wheel, even after the data root is contained. Resolve each data file against the source tree, reject escaped targets, and apply both exclusion sets before adding it to the wheel.

#20397 contained data roots but left this nested-symlink path open. #15243 documents that the backend already follows external file symlinks, so this closes that path into an artifact.

@zanieb
zanieb requested a review from konstin July 15, 2026 15:49
@astral-sh-bot

astral-sh-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

uv test inventory changes

This PR changes the tests when compared with the latest main baseline.

  • Added tests: 1
  • Removed tests: 0
  • Changed suites: 1
uv::build: +1 / -0

Added:

  • uv::build::build_backend::wheel_data_nested_symlink_containment

Removed: none

@konstin konstin added bug Something isn't working and removed security labels Jul 21, 2026
if entry.file_type().is_symlink()
&& let Some((exclude_matcher, source_tree)) = exclude_matcher
{
let canonical_source_tree = source_tree.simple_canonicalize()?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we cache this?

/// Either an absolute path or a parent path through `..`.
#[error("The path for the data directory {} must be inside the project: {}", name, path.user_display())]
InvalidDataRoot { name: String, path: PathBuf },
#[error("The path for the data file must be inside the project: {}", _0.user_display())]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
#[error("The path for the data file must be inside the project: {}", _0.user_display())]
#[error("The data file is a link to a file outside the project: {}", _0.user_display())]

@konstin

konstin commented Jul 21, 2026

Copy link
Copy Markdown
Member

I hope nobody uses this for something like including data files from elsewhere in the repo.

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.

2 participants