Skip to content

Post-extraction steps follow symlinks out of the staging directory (ComfyUI source, uv bootstrap) #522

Open

Description

@rominf

Summary

The archive extractors themselves hold up: property-testing Lemonade's in-process extractor and GNU tar (used for the SDK and uv) with archives built from traversal names, absolute paths, backslashes, UNC prefixes, NUL and non-UTF-8 bytes, outward symlinks and hard links found no write outside the install root, across 3,000 cases each. The defects below are all in code that runs after extraction.

1. ComfyUI: a top-level symlink in the source archive relocates the install

first_child_dir (apps/rocm/src/comfyui.rs) picks the source directory with path.is_dir(), which follows symlinks. An archive whose single top-level entry is a link (l -> .., or l -> /some/dir) has that link chosen, renamed to source/, and install then calls create_dir_all(source/models) — creating the models folder, and every later run's state, wherever the link points.

2. uv bootstrap: the binary lookup follows links out of staging and can recurse without bound

find_binary_in (crates/rocm-core/src/uv.rs) recurses through is_dir()/is_file(), both of which follow symlinks, with no depth limit and no cycle check:

  • an entry uv -> <outside>/file is found, and make_executable then sets mode 0755 on the outside file;
  • two entries a -> . and b -> . make the search recurse effectively forever (still running after 20 s in testing);
  • a single l -> / walks the whole filesystem.

3. ComfyUI keeps world-writable modes from the archive

The tar crate drops setuid/setgid but does not apply the umask, so a 0777/0666 entry stays world-writable. Lemonade's extractor already masks modes; ComfyUI's does not.

Trust boundary — read before triaging severity

Each of these needs a forged or tampered archive:

  • The ComfyUI source is GitHub's branch tarball over HTTPS, with no checksum, cached under the app's downloads/ directory and reused without re-checking. GitHub's own archives always have a single real top-level directory, so reaching (1) needs a forged archive or an edited cached file.
  • The uv release is fetched from GitHub over HTTPS with no checksum. A malicious uv archive is executed anyway, so (2) is defence in depth rather than a new attack path.

These are hardening issues. They are filed because the fixes are small and the same code already does the right thing elsewhere.

Possible solution

Use symlink_metadata / DirEntry::file_type() (which does not follow links) in first_child_dir and find_binary_in, bound the recursion depth, and mask modes with & 0o755 in the ComfyUI unpack as Lemonade already does.

Not verified

  • Running as root: GNU tar run as root preserves ownership and setuid bits by default, which would matter for the SDK and uv paths. Not testable here.
  • Windows: bsdtar, Expand-Archive, and backslash/drive-letter handling as real separators were not exercised; the properties are Unix-only.

Environment

  • Built from main. Findings 1–3 reproduced on Linux.

Activity

  1. added a commit that references this issue on Oct 13, 2026
  2. added 2 commits that reference this issue on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions